-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LIBCLC] Modify libclc-remangler cmds for cross-compile support #16182
base: sycl
Are you sure you want to change the base?
Conversation
Because libclc-remangler commands executed in cmake use `libclc::libclc-remangler`, builds where `CMAKE_CROSSCOMPILING=ON` do not work correctly since cmake assumes the target is not executable on the host machine. This change modifies the custom commands to use the cache variable `LIBCLC_REMANGLER_PATH` instead, where this variable is set in a similar way as llvm tools such as `llvm-config` by calling `compile_native_tool`. Signed-off-by: Jack Myers <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC @hvdijk who fixed cross-compilation issues upstream
if(CMAKE_CROSSCOMPILING) | ||
if(LLVM_NATIVE_TOOL_DIR AND NOT LIBCLC_REMANGLER_PATH) | ||
if(EXISTS "${LLVM_NATIVE_TOOL_DIR}/libclc-remangler${LLVM_HOST_EXECUTABLE_SUFFIX}") | ||
set(LLVM_CONFIG_PATH "${LLVM_NATIVE_TOOL_DIR}/libclc-remangler${LLVM_HOST_EXECUTABLE_SUFFIX}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be setting LIBCLC_REMANGLER_PATH
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should've but I have decided to not do all the cross compiling logic manually, instead using setup_host_tool
.
libclc/cmake/modules/AddLibclc.cmake
Outdated
@@ -456,7 +456,7 @@ function(add_libclc_builtin_set) | |||
"${LIBCLC_LIBRARY_OUTPUT_INTDIR}/remangled-${long_width}-${signedness}_char.${obj_suffix_mangled}" ) | |||
add_custom_command( OUTPUT "${builtins_remangle_path}" | |||
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_LIBRARY_OUTPUT_INTDIR} | |||
COMMAND libclc::libclc-remangler | |||
COMMAND ${LIBCLC_REMANGLER_PATH} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the variable should be named libclc-remangler_exe
like the other tools: clang_exe
, llvm-link_exe
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing as my previous comment above, but yes:
Yes it should've but I have decided to not do all the cross compiling logic manually, instead using
setup_host_tool
.
add_dependencies(libclc-remangler NativeLibCLCRemangler) | ||
endif() | ||
else() | ||
set(LIBCLC_REMANGLER_PATH "${CMAKE_CURRENT_BINARY_DIR}/bin/libclc-remangler" CACHE STRING "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure relying on the path like this is the best idea. Perhaps we can get the path to the binary using the libclc-remangler
target itself? Does $<TARGET_PROPERTY:libclc-remangler,TARGET_FILE>
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referencing again 😅:
Same thing as my previous comment above, but yes:
Yes it should've but I have decided to not do all the cross compiling logic manually, instead using
setup_host_tool
.
else() | ||
set(LIBCLC_REMANGLER_PATH "${CMAKE_CURRENT_BINARY_DIR}/bin/libclc-remangler" CACHE STRING "") | ||
endif() | ||
|
||
# If we've not already imported a libclc-remangler tool from an external build, | ||
# set it up now. | ||
if(NOT TARGET libclc::libclc-remangler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment makes me realise this PR breaks the ability to import libclc-remangler
from another build, using LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR
. We should keep that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is actually a bit confusing to me. I found PR #13743 that introduced this, but as far as I can tell, this breaks the LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR
functionality since the target is never imported through anything like find_package
.
I'm realizing now that this might be because I was testing everything with CMAKE_CROSSCOMPILING
enabled which may have messed with the target import.
Regardless, the libclc::libclc-remangler
pattern seems to be unique among the rest of LLVM where other tools used during the build that are also built as a part of LLVM use things like compile_native_tool
or setup_host_tool
+ LLVM_NATIVE_TOOL_DIR
which is assigned automatically if needed.
My latest commit uses libclc-remangler_target
which is populated by setup_host_tool
. But I think LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR
might still be broken.
I see why LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR
is used since it can be built as a standalone. I'm wondering if in the case that it has not been set, then it should be set to LLVM_NATIVE_TOOL_DIR
if it has been set. Thoughts?
Because libclc-remangler commands executed in cmake use `libclc::libclc-remangler`, builds where `CMAKE_CROSSCOMPILING=ON` do not work correctly since cmake assumes the target is not executable on the host machine. This change modifies the custom commands to use the cache variable `LIBCLC_REMANGLER_PATH` instead, where this variable is set in a similar way as llvm tools such as `llvm-config` by calling `compile_native_tool`. Signed-off-by: Jack Myers <[email protected]>
Because libclc-remangler commands executed in cmake use `libclc::libclc-remangler`, builds where `CMAKE_CROSSCOMPILING=ON` do not work correctly since cmake assumes the target is not executable on the host machine. This change modifies the custom commands to use the cache variable `LIBCLC_REMANGLER_PATH` instead, where this variable is set in a similar way as llvm tools such as `llvm-config` by calling `compile_native_tool`. Signed-off-by: Jack Myers <[email protected]>
Because libclc-remangler commands executed in cmake use
libclc::libclc-remangler
, builds whereCMAKE_CROSSCOMPILING=ON
do not work correctly since cmake assumes the target is not executable on the host machine.This change modifies the custom commands to use the cache variable
LIBCLC_REMANGLER_PATH
instead, where this variable is set in a similar way as llvm tools such asllvm-config
by callingcompile_native_tool
.