-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb][cmake] Add clang resource dir to LLDB shell tests config #136761
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
[lldb][cmake] Add clang resource dir to LLDB shell tests config #136761
Conversation
@llvm/pr-subscribers-lldb Author: Chelsea Cassanova (chelcassanova) ChangesWe want to be able to access the Clang resources directory in LLDB shell tests, this commit adds the ability to do this by populating the Full diff: https://github.com/llvm/llvm-project/pull/136761.diff 2 Files Affected:
diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake
index 471aeaaad3c0d..2fcc8f2f36f29 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -121,7 +121,7 @@ add_custom_command(TARGET liblldb POST_BUILD
if(NOT APPLE_EMBEDDED)
if (TARGET clang-resource-headers)
add_dependencies(liblldb clang-resource-headers)
- set(clang_resource_headers_dir $<TARGET_PROPERTY:clang-resource-headers,INTERFACE_INCLUDE_DIRECTORIES>)
+ get_target_property(clang_resource_headers_dir clang-resource-headers INTERFACE_INCLUDE_DIRECTORIES)
else()
set(clang_resource_headers_dir ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}/include)
if(NOT EXISTS ${clang_resource_headers_dir})
@@ -135,6 +135,8 @@ if(NOT APPLE_EMBEDDED)
$<TARGET_FILE_DIR:liblldb>/Resources/Clang/include
COMMENT "LLDB.framework: copy clang vendor-specific headers"
)
+
+ set(CLANG_RESOURCE_DIR ${clang_resource_headers_dir} CACHE FILEPATH "")
endif()
# Add an rpath pointing to the directory where LLDB.framework is installed.
diff --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in
index 31a6d68618b77..7e03938b12b23 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -35,6 +35,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
# The shell tests use their own module caches.
config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-shell")
+config.clang_resource_dir = os.path.join("@CLANG_RESOURCE_DIR@")
import lit.llvm
lit.llvm.initialize(lit_config, config)
|
@@ -135,6 +135,8 @@ if(NOT APPLE_EMBEDDED) | |||
$<TARGET_FILE_DIR:liblldb>/Resources/Clang/include | |||
COMMENT "LLDB.framework: copy clang vendor-specific headers" | |||
) | |||
|
|||
set(CLANG_RESOURCE_DIR ${clang_resource_headers_dir} CACHE FILEPATH "") |
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 code path will be taken when we build the LLDB.framework for apple platforms, but it won't work if you do things on Linux. We should find another place to put this logic.
My suggestion would be LLDBConfig.cmake
since that handles all of the dependency management. You'll still want to keep the copy step here, but the logic to actually find the clang headers should be moved.
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.
Looked into this a little and it turns out that the code that handles searching for the clang headers in LLDBFramework.cmake
looks to be overlapping with similar code in lldb/source/API/CMakeLists.txt
. This should be a good opportunity to clean up that overlap.
c7d22d4
to
d5760f9
Compare
I redid this PR to just add the Clang resource dir to the CMake file for the LLDB shell tests so that lit can pick it up since it's not necessary that the variable be in the CMake cache, just the scope that the lit config exists in. |
lldb/test/Shell/CMakeLists.txt
Outdated
@@ -1,6 +1,8 @@ | |||
add_custom_target(lldb-shell-test-deps) | |||
set_target_properties(lldb-shell-test-deps PROPERTIES FOLDER "LLDB/Tests") | |||
add_dependencies(lldb-shell-test-deps lldb-test-depends) | |||
get_target_property(clang_resource_headers_dir clang-resource-headers INTERFACE_INCLUDE_DIRECTORIES) |
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.
The clang-resource-headers
target may not exist if you build LLDB standalone (that is, with a prebuilt LLVM/Clang). See the end of cmake/modules/LLDBStandalone.cmake
d5760f9
to
b073c45
Compare
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.
Looking better, but I don't think the shell test's CMake file is the right place to calculate the resource directory. It's already calculated in LLDBStandalone
. I think we should hoist this logic into LLDB's configuration more generally (e.g. LLDBConfig.cmake
or top-level CMakeLists.txt, somewhere like that).
lldb/test/Shell/CMakeLists.txt
Outdated
@@ -1,6 +1,12 @@ | |||
add_custom_target(lldb-shell-test-deps) | |||
set_target_properties(lldb-shell-test-deps PROPERTIES FOLDER "LLDB/Tests") | |||
add_dependencies(lldb-shell-test-deps lldb-test-depends) | |||
if(LLDB_BUILT_STANDALONE) | |||
get_target_property(CLANG_RESOURCE_DIR clang-resource-headers INTERFACE_INCLUDE_DIRECTORIES) | |||
set(CLANG_RESOURCE_DIR "${CLANG_RESOURCE_DIR}/..") |
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.
Why do you move up a directory here?
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.
Getting the directory in a standalone build (using the get_target_property
call) gives us this: <prefix>/llvm-build/./lib/../lib/clang/21/include/
whereas getting in a non-standalone build (using the get_clang_resource_dir
call) gives us this: <prefix>/lib/clang/21
. I'm moving the standalone value up a directory so that both values match regardless of how the build was done. I can add a comment to clarify this.
lldb/test/Shell/CMakeLists.txt
Outdated
@@ -1,6 +1,12 @@ | |||
add_custom_target(lldb-shell-test-deps) | |||
set_target_properties(lldb-shell-test-deps PROPERTIES FOLDER "LLDB/Tests") | |||
add_dependencies(lldb-shell-test-deps lldb-test-depends) | |||
if(LLDB_BUILT_STANDALONE) | |||
get_target_property(CLANG_RESOURCE_DIR clang-resource-headers INTERFACE_INCLUDE_DIRECTORIES) |
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.
In LLDBStandalone.cmake
we already compute the clang resource dir and put it into the variable LLDB_EXTERNAL_CLANG_RESOURCE_DIR
. You could probably just reference that variable instead of recalculating it here.
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 actually only happens if the clang-resource-dir
target doesn't exist. When I built standalone, that target did exist so the LLDB_EXTERNAL_CLANG_RESOURCE_DIR
is never populated. I changed it so that if that target doesn't exist when we're trying to set CLANG_RESOURCE_DIR
, we use LLDB_EXTERNAL_CLANG_RESOURCE_DIR
.
We want to be able to access the Clang resources directory in LLDB shell tests, this commit adds the ability to do this by adding the `CLANG_RESOURCE_DIR` CMake variable to the config for LLDB lit tests
b073c45
to
b8fec72
Compare
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 alright with this
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/15300 Here is the relevant piece of the build log for the reference
|
…#136761) We want to be able to access the Clang resources directory in LLDB shell tests, this commit adds the ability to do this by populating the `CLANG_RESOURCE_DIR` variable in LLDBConfig.cmake.
…#136761) We want to be able to access the Clang resources directory in LLDB shell tests, this commit adds the ability to do this by populating the `CLANG_RESOURCE_DIR` variable in LLDBConfig.cmake.
…#136761) We want to be able to access the Clang resources directory in LLDB shell tests, this commit adds the ability to do this by populating the `CLANG_RESOURCE_DIR` variable in LLDBConfig.cmake.
…#136761) We want to be able to access the Clang resources directory in LLDB shell tests, this commit adds the ability to do this by populating the `CLANG_RESOURCE_DIR` variable in LLDBConfig.cmake.
…#136761) We want to be able to access the Clang resources directory in LLDB shell tests, this commit adds the ability to do this by populating the `CLANG_RESOURCE_DIR` variable in LLDBConfig.cmake.
We want to be able to access the Clang resources directory in LLDB shell tests, this commit adds the ability to do this by populating the
CLANG_RESOURCE_DIR
CMake cache variable and adding it to the LLDB lit config.