Skip to content

Conversation

@hvdijk
Copy link
Contributor

@hvdijk hvdijk commented Dec 3, 2024

When performing cross builds, we need native versions of various tools, we cannot assume the cross builds that are part of the current build are executable. LLVM provides the setup_host_tool function to handle this, either picking up versions of tools from LLVM_NATIVE_TOOL_DIR, or implicitly building native versions as needed. Use this in more places.

This applies the changes from LLVM #97392 and #97811 and adapts them to DPC++, and makes the same changes in other places that are only needed for DPC++.

Tested with a suitable cross compilation toolchain file:

$ mkdir build
$ cat >build/aarch64-linux.cmake <<EOF
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc" CACHE STRING "")
set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++" CACHE STRING "")
set(PKG_CONFIG_EXECUTABLE "aarch64-linux-gnu-pkg-config" CACHE STRING "")

set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
EOF
$ python3 buildbot/configure.py -o build/aarch64-linux    \
  --cmake-opt=--toolchain=$PWD/build/aarch64-linux.cmake  \
  --cmake-opt=-DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu

@hvdijk hvdijk requested review from a team as code owners December 3, 2024 09:24
Copy link
Contributor

@frasercrmck frasercrmck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to duplicate some work from #16182 - is that right?

Do we know why llvm/llvm-project#97811 and llvm/llvm-project#97392 weren't pulled down correctly? Were those commits just silently dropped?

@hvdijk
Copy link
Contributor Author

hvdijk commented Dec 3, 2024

This seems to duplicate some work from #16182 - is that right?

Yes, it looks like this includes the changes from #16182.

Do we know why llvm/llvm-project#97811 and llvm/llvm-project#97392 weren't pulled down correctly? Were those commits just silently dropped?

I suspect the many non-trivial differences between upstream LLVM and DPC++ in libclc's CMake made it easy to miss what did and didn't need to be updated.

@steffenlarsen steffenlarsen changed the title Fix cross builds [SYCL][libclc] Fix cross builds Dec 3, 2024
Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Libclc and runtime-related changes LGTM, but I agree with upstreaming as much as possible. 😉

When performing cross builds, we need native versions of various tools,
we cannot assume the cross builds that are part of the current build are
executable. LLVM provides the setup_host_tool function to handle this,
either picking up versions of tools from LLVM_NATIVE_TOOL_DIR, or
implicitly building native versions as needed. Use this in more places.

This applies the changes from LLVM #97392 and #97811 and adapts them to
DPC++, and makes the same changes in other places that are only needed
for DPC++.
@hvdijk hvdijk force-pushed the fix-cross-compilation branch from 4387ef1 to e152215 Compare December 4, 2024 13:18
@cperkinsintel cperkinsintel removed their request for review December 4, 2024 18:25
@hvdijk
Copy link
Contributor Author

hvdijk commented Dec 17, 2024

@intel/llvm-gatekeepers This should be good to merge, thanks.

For upstreaming, it looks like upstream LLVM will want these changes only when they also get sycl to make use of it. I think we cannot upstream it just yet, but I will leave llvm/llvm-project#118635 open and others can comment on it if they wish.

@sommerlukas sommerlukas merged commit 2444c91 into intel:sycl Dec 19, 2024
14 checks passed
@hvdijk hvdijk deleted the fix-cross-compilation branch December 19, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants