-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc] Support multilib with runtimes build #115357
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
Conversation
This adds minimal support for multilibs akin to libc++.
@llvm/pr-subscribers-libc Author: Petr Hosek (petrhosek) ChangesThis adds minimal support for multilibs akin to libc++. Full diff: https://github.com/llvm/llvm-project/pull/115357.diff 2 Files Affected:
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index c393d23a3b33d4..77b659b2ef2322 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -248,10 +248,17 @@ foreach(config_path IN LISTS LIBC_CONFIG_JSON_FILE_LIST)
load_libc_config(${config_path}/config.json ${cmd_line_conf})
endforeach()
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+ set(LIBC_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
+ if(LIBC_LIBDIR_SUBDIR)
+ string(APPEND LIBC_TARGET_SUBDIR /${LIBC_LIBDIR_SUBDIR})
+ endif()
+endif()
+
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND (LIBC_ENABLE_USE_BY_CLANG OR LIBC_TARGET_OS_IS_GPU))
set(LIBC_INCLUDE_DIR ${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE})
set(LIBC_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
- set(LIBC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
+ set(LIBC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBC_TARGET_SUBDIR})
else()
if(NOT LIBC_ENABLE_USE_BY_CLANG)
set(LIBC_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
@@ -277,8 +284,7 @@ endif()
if(LIBC_TARGET_TRIPLE)
set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBC_TARGET_TRIPLE})
elseif(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
- set(LIBC_INSTALL_LIBRARY_DIR
- lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
+ set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBC_TARGET_SUBDIR})
else()
set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX})
endif()
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 9da1f926817a8b..57a56c6a604153 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -635,6 +635,7 @@ if(build_runtimes)
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
-DLLVM_RUNTIMES_PREFIX=${name}/
-DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
+ ${extra_cmake_args}
BASE_NAME ${name}
EXTRA_ARGS TARGET_TRIPLE ${name})
endforeach()
|
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR) | ||
set(LIBC_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE}) | ||
if(LIBC_LIBDIR_SUBDIR) | ||
string(APPEND LIBC_TARGET_SUBDIR /${LIBC_LIBDIR_SUBDIR}) |
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.
So things will be installed in lib/x86_64-unknown-linux-gnu/<feature>
for example? How does the compiler know where to find it.
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 is set by the bootstrapping build here:
llvm-project/llvm/runtimes/CMakeLists.txt
Line 636 in 7b5e285
-DLLVM_RUNTIMES_PREFIX=${name}/ |
The name comes from
LLVM_RUNTIME_MULTILIBS
.
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.
Overall LGTM
@@ -635,6 +635,7 @@ if(build_runtimes) | |||
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} | |||
-DLLVM_RUNTIMES_PREFIX=${name}/ | |||
-DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib} | |||
${extra_cmake_args} |
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.
is this related or is it debug code that snuck in?
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 is needed to passthrough the hdrgen CMake variables and matches the non-multilib case:
llvm-project/llvm/runtimes/CMakeLists.txt
Line 627 in 7b5e285
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} ${extra_cmake_args} |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/3515 Here is the relevant piece of the build log for the reference
|
This adds minimal support for multilibs akin to libc++.