[llvm] [llvm] Pass `/Brepro` via `add_link_options()` (PR #227416)
Fabrice de Gans via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 11:55:34 PDT 2026
https://github.com/Steelskin updated https://github.com/llvm/llvm-project/pull/227416
>From 37f3e7ee2df929a4d6482700d8551d3128ed0e88 Mon Sep 17 00:00:00 2001
From: Fabrice de Gans <steelskin at gmail.com>
Date: Tue, 29 Sep 2026 20:08:44 +0200
Subject: [PATCH 1/2] [llvm] Pass `/Brepro` via `add_link_options()`
In modern CMake, editing `CMAKE_` variables directly is discouraged.
`/Brepro` should be passed via `add_link_options()` with a `LINKER:`
prefix to be portable.
This fixes issues for downstream consumers like Swift whose linker
driver needs the linker arguments to be prefixed.
---
llvm/cmake/modules/HandleLLVMOptions.cmake | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 34b4580c84e65..e0bd211a1209b 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -708,7 +708,8 @@ if( MSVC )
has_msvc_incremental_no_flag("${CMAKE_SHARED_LINKER_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${CMAKE_SHARED_LINKER_FLAGS}" NO_INCR_SHARED)
if (NO_INCR_EXE AND NO_INCR_MODULE AND NO_INCR_SHARED)
# The /Brepro flag in `clang-cl` omits the timestamp for .obj files while the linker flag omits the timestamp for .exe and .dll files.
- append("/Brepro" CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+ append("/Brepro" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ add_link_options("LINKER:/Brepro")
else()
message(WARNING "/Brepro not compatible with /INCREMENTAL linking - builds will be non-deterministic")
endif()
>From f342d83e0b01e3bb2baa9bdddf5fb7939b3b7cbd Mon Sep 17 00:00:00 2001
From: Fabrice de Gans <Steelskin at users.noreply.github.com>
Date: Tue, 29 Sep 2026 20:55:19 +0200
Subject: [PATCH 2/2] Update llvm/cmake/modules/HandleLLVMOptions.cmake
Co-authored-by: Saleem Abdulrasool <compnerd at compnerd.org>
---
llvm/cmake/modules/HandleLLVMOptions.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index e0bd211a1209b..943418f7ec0da 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -708,7 +708,7 @@ if( MSVC )
has_msvc_incremental_no_flag("${CMAKE_SHARED_LINKER_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${CMAKE_SHARED_LINKER_FLAGS}" NO_INCR_SHARED)
if (NO_INCR_EXE AND NO_INCR_MODULE AND NO_INCR_SHARED)
# The /Brepro flag in `clang-cl` omits the timestamp for .obj files while the linker flag omits the timestamp for .exe and .dll files.
- append("/Brepro" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:/Brepro>")
add_link_options("LINKER:/Brepro")
else()
message(WARNING "/Brepro not compatible with /INCREMENTAL linking - builds will be non-deterministic")
More information about the llvm-commits
mailing list