[PATCH] D125827: [cmake] Don't try creating an executable when detecting the linker
Louis Dionne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 17 12:08:17 PDT 2022
ldionne created this revision.
Herald added a subscriber: mgorny.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
On most platforms, the linker detection command that we run ends up being
something like `clang++ -Wl,-v` or `clang++ -Wl,--version`. This usually
fails with a missing reference to `_main` because we don't have any input
file. However, when compiling for a target that is implicitly freestanding,
the invocation actually succeeds and a dummy `a.out` file is created in
the current working directory. This is extremely annoying because it
creates a `a.out` file at the root of the monorepo when running CMake
configuration from the root.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125827
Files:
llvm/cmake/modules/AddLLVM.cmake
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -178,10 +178,10 @@
endif()
if(LLVM_USE_LINKER)
- set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} ${version_flag})
+ set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} ${version_flag} -o /dev/null)
else()
separate_arguments(flags UNIX_COMMAND "${CMAKE_EXE_LINKER_FLAGS}")
- set(command ${CMAKE_C_COMPILER} ${flags} ${version_flag})
+ set(command ${CMAKE_C_COMPILER} ${flags} ${version_flag} -o /dev/null)
endif()
execute_process(
COMMAND ${command}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125827.430153.patch
Type: text/x-patch
Size: 693 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220517/4f460c29/attachment.bin>
More information about the llvm-commits
mailing list