[libc-commits] [libc] [libc] Stop passing `--version` to compiler when detecting target (PR #176680)

Nico Weber via libc-commits libc-commits at lists.llvm.org
Sun Jan 18 17:41:58 PST 2026


https://github.com/nico created https://github.com/llvm/llvm-project/pull/176680

This reverts c267501c155f9, and also adds a `-c` flag.

Both gcc and clang print the `Target:` line that we're trying to find just find with just `-v`.

When passing `--version`, gcc passes `--version` to the system linker, and when using gcc on macOS, the system linker does not understand `--version`. Since `--version` does not seem to be necessary, drop it.

Also, passing `-c` lets gcc not print linker details, so add that too, as a belt-and-suspenders fix.

---

Makes `cmake` succeed for me on my mac with `/Applications/CMake.app/Contents/bin/cmake ../llvm-project/llvm -G Ninja -DLLVM_ENABLE_PROJECTS="libc" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc-12 -DCMAKE_CXX_COMPILER=g++-12` (with gcc-12 from homebrew).

>From b520f283a628cb5463e009732259e02e5c9d0a4c Mon Sep 17 00:00:00 2001
From: Nico Weber <thakis at chromium.org>
Date: Sun, 18 Jan 2026 20:38:49 -0500
Subject: [PATCH] [libc] Stop passing `--version` to compiler when detecting
 target

This reverts c267501c155f9, and also adds a `-c` flag.

Both gcc and clang print the `Target:` line that we're trying to
find just find with just `-v`.

When passing `--version`, gcc passes `--version` to the system
linker, and when using gcc on macOS, the system linker does not
understand `--version`. Since `--version` does not seem to be
necessary, drop it.

Also, passing `-c` lets gcc not print linker details, so add that
too, as a belt-and-suspenders fix.
---
 libc/cmake/modules/LLVMLibCArchitectures.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index 939fc1226a4e9..d9b1fa5a85842 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -78,7 +78,7 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
   set(${sys_var} ${target_sys} PARENT_SCOPE)
 endfunction(get_arch_and_system_from_triple)
 
-execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version -v
+execute_process(COMMAND ${CMAKE_CXX_COMPILER} -v
                 RESULT_VARIABLE libc_compiler_info_result
                 OUTPUT_VARIABLE libc_compiler_info
                 ERROR_VARIABLE libc_compiler_info)



More information about the libc-commits mailing list