Author: Joseph Huber Date: 2026-01-07T08:21:45-06:00 New Revision: 9315747fb31b5dcf7e5879a0138d39098c30cea3
URL: https://github.com/llvm/llvm-project/commit/9315747fb31b5dcf7e5879a0138d39098c30cea3 DIFF: https://github.com/llvm/llvm-project/commit/9315747fb31b5dcf7e5879a0138d39098c30cea3.diff LOG: [libclc] Initial support for cross-compiling OpenCL libraries (#174022) Summary: The other GPU enabled libraries, (openmp, flang-rt, compiler-rt, libc, libcxx, libcxx-abi) all support builds through a runtime cross-build. In these builds we use a separate CMake build that cross-compiles to a single target. This patch provides basic support for this with the `libclc` libraries. Changes include adding support for the more standard GPU compute triples (amdgcn-amd-amdhsa, nvptx64-nvidia-cuda) and building only one target in this mode. Some things left to do: This patch does not change the compiler invocations, this method would allow us to use standard CMake routines but this keeps it minimal. The prebuild support is questionable and doesn't fit into this scheme because it's a host executable, I'm ignoring it for now. The installed location should just use the triple with no `libclc/` subdirectory handling I believe. Added: Modified: libclc/CMakeLists.txt Removed: ################################################################################ diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 0694cbc4f4000..d060b71f3db11 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -38,7 +38,12 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS set( LIBCLC_MIN_LLVM 3.9.0 ) -set( LIBCLC_TARGETS_TO_BUILD "all" +# A runtimes cross-build should only use the requested target. +set( LIBCLC_DEFAULT_TARGET "all" ) +if( LLVM_RUNTIMES_BUILD AND LLVM_DEFAULT_TARGET_TRIPLE MATCHES "^nvptx|^amdgcn" ) + set( LIBCLC_DEFAULT_TARGET ${LLVM_DEFAULT_TARGET_TRIPLE} ) +endif() +set( LIBCLC_TARGETS_TO_BUILD ${LIBCLC_DEFAULT_TARGET} CACHE STRING "Semicolon-separated list of libclc targets to build, or 'all'." ) option( ENABLE_RUNTIME_SUBNORMAL "Enable runtime linking of subnormal support." OFF ) @@ -82,7 +87,10 @@ else() # In-tree configuration set( LIBCLC_STANDALONE_BUILD FALSE ) - set( LLVM_PACKAGE_VERSION ${LLVM_VERSION} ) + if( NOT LLVM_PACKAGE_VERSION ) + set( LLVM_PACKAGE_VERSION ${LLVM_VERSION} ) + endif() + set( PACKAGE_VERSION ${LLVM_PACKAGE_VERSION} ) # Note that we check this later (for both build types) but we can provide a # more useful error message when built in-tree. We assume that LLVM tools are _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
