[Comgr] test-unit: prefer LLVM-installed gtest over find_package#2618
Open
lamb-j wants to merge 1 commit into
Open
[Comgr] test-unit: prefer LLVM-installed gtest over find_package#2618lamb-j wants to merge 1 commit into
lamb-j wants to merge 1 commit into
Conversation
Reorder the GTest discovery in amd/comgr/test-unit/CMakeLists.txt so the NO_DEFAULT_PATH find_library scan of LLVM_LIBRARY_DIRS runs before the unscoped find_package(GTest CONFIG). The previous order let find_package(GTest CONFIG) intercept first and pick up a system gtest at /usr/local that wasn't built with -fPIC, breaking the PIE link of the test-unit binaries when building Comgr standalone with -DADDRESS_SANITIZER=On against an installed ROCm (#2505). The new order keeps every existing path working: 1. In-tree llvm_gtest target (LLVM monorepo build, e.g. CI) - unchanged 2. LLVM-installed gtest in LLVM_LIBRARY_DIRS (NO_DEFAULT_PATH) - now runs before find_package, so a standalone Comgr build picks the LLVM-supplied gtest when LLVM was built with -DLLVM_INSTALL_GTEST=ON 3. find_package(GTest CONFIG) - still the path TheRock uses to find therock-googletest via CMAKE_PREFIX_PATH; no change for superproject builds since TheRock's amd-llvm doesn't ship llvm_gtest No source/test changes; CMake-only.
chinmaydd
reviewed
May 20, 2026
chinmaydd
left a comment
There was a problem hiding this comment.
Makes sense. I believe it shouldnt have any impact on Windows builds either, will keep an eye out on the CI
chinmaydd
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2505.
amd/comgr/test-unit/CMakeLists.txtranfind_package(GTest CONFIG)before scanningLLVM_LIBRARY_DIRS.find_packagesearches CMake's default paths and picks up a system gtest at/usr/localthat isn't-fPIC, breaking PIE link of the test binaries on standalone Comgr ASAN builds.Swap paths #2 and #3 so the
NO_DEFAULT_PATHscan ofLLVM_LIBRARY_DIRSruns first. New order:llvm_gtesttarget (CI) — unchanged.LLVM_LIBRARY_DIRS(NO_DEFAULT_PATH) — now ahead offind_package, so it can never grab/usr/local.find_package(GTest CONFIG)— TheRock's path (therock-googletestviaCMAKE_PREFIX_PATH), unchanged for superproject builds since TheRock'samd-llvmdoesn't shipllvm_gtest.CMake-only. Standalone Comgr builds need LLVM rebuilt with
-DLLVM_INSTALL_GTEST=ONto use path #2.