[libc-commits] [libc] [libc][cmake] Suppress -Wpsabi note on GCC and clean up resource-dir check. (PR #227968)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Thu Oct 1 04:08:37 PDT 2026
================
@@ -127,44 +127,85 @@ set(LIBC_TEST_HERMETIC_ONLY "" OFF CACHE BOOL "Only enable hermetic tests.")
list(APPEND LIBC_COMPILE_OPTIONS_DEFAULT ${LIBC_COMMON_TUNE_OPTIONS})
-# Check --print-resource-dir to find the compiler resource dir if this flag
-# is supported by the compiler.
-execute_process(
- OUTPUT_STRIP_TRAILING_WHITESPACE
- COMMAND ${CMAKE_CXX_COMPILER} --print-resource-dir
- RESULT_VARIABLE COMMAND_RETURN_CODE
- OUTPUT_VARIABLE COMPILER_RESOURCE_DIR
-)
-# Retrieve the host compiler's resource dir.
-if(COMMAND_RETURN_CODE EQUAL 0)
- set(COMPILER_RESOURCE_DIR
- "${COMPILER_RESOURCE_DIR}" CACHE PATH "path to compiler resource dir"
- )
- message(STATUS "Set COMPILER_RESOURCE_DIR to "
- "${COMPILER_RESOURCE_DIR} using --print-resource-dir")
-else()
- # Try with GCC option: -print-search-dirs, which will output in the form:
- # install: <path>
- # programs: ........
- # So we try to capture the <path> after "install: " in the first line of the
- # output.
- execute_process(
- OUTPUT_STRIP_TRAILING_WHITESPACE
- COMMAND ${CMAKE_CXX_COMPILER} -print-search-dirs
- RESULT_VARIABLE COMMAND_RETURN_CODE
- OUTPUT_VARIABLE COMPILER_RESOURCE_DIR
- )
- if(COMMAND_RETURN_CODE EQUAL 0)
- string(REPLACE " " ";" COMPILER_RESOURCE_DIR ${COMPILER_RESOURCE_DIR})
- string(REPLACE "\n" ";" COMPILER_RESOURCE_DIR "${COMPILER_RESOURCE_DIR}")
- list(GET COMPILER_RESOURCE_DIR 1 COMPILER_RESOURCE_DIR)
- message(STATUS "Set COMPILER_RESOURCE_DIR to "
- "${COMPILER_RESOURCE_DIR} using --print-search-dirs")
+# Find the compiler resource dir for compilers that support it.
+if(NOT DEFINED COMPILER_RESOURCE_DIR OR "${COMPILER_RESOURCE_DIR}" STREQUAL "")
----------------
labath wrote:
```suggestion
if(NOT COMPILER_RESOURCE_DIR)
```
Optional, but maybe it'd be okay to accept other false-ish values: https://cmake.org/cmake/help/latest/command/if.html#variable
https://github.com/llvm/llvm-project/pull/227968
More information about the libc-commits
mailing list