[PATCH] D51635: clang-cl: Pass /Brepro to linker if it was passed to the compiler
Nico Weber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 4 08:18:59 PDT 2018
thakis created this revision.
thakis added a reviewer: hans.
/Brepro currently is just an alias for -mno-incremental-linker-compatible and before this patch only controlled if we write a timestamp into the output obj file. But cl.exe also passes it on to link.exe (where it controls whether the final PE image timestamp really is a timestamp or a hash of the output).
It's a bit weird to overload -mno-incremental-linker-compatible to also pass /Brepro to the linker, but all alternatives are a bit weird too. Open for suggestions though :-)
https://reviews.llvm.org/D51635
Files:
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/Driver/msvc-link.c
Index: clang/test/Driver/msvc-link.c
===================================================================
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -3,6 +3,7 @@
// BASIC: "-out:a.exe"
// BASIC: "-defaultlib:libcmt"
// BASIC: "-nologo"
+// BASIC-NOT: "-Brepro"
// RUN: %clang -target i686-pc-windows-msvc -shared -o a.dll -### %s 2>&1 | FileCheck --check-prefix=DLL %s
// DLL: link.exe"
@@ -16,3 +17,14 @@
// LIBPATH: "-libpath:/usr/lib"
// LIBPATH: "-nologo"
+// RUN: %clang_cl /Brepro -### %s 2>&1 | FileCheck --check-prefix=REPRO %s
+// REPRO: link.exe"
+// REPRO: "-out:msvc-link.exe"
+// REPRO: "-nologo"
+// REPRO: "-Brepro"
+
+// RUN: %clang_cl /Brepro- -### %s 2>&1 | FileCheck --check-prefix=NOREPRO %s
+// NOREPRO: link.exe"
+// NOREPRO: "-out:msvc-link.exe"
+// NOREPRO: "-nologo"
+// NOREPRO-NOT: "-Brepro"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===================================================================
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -355,6 +355,15 @@
options::OPT__SLASH_Zd))
CmdArgs.push_back("-debug");
+ // Pass on /Brepro if it was passed to the compiler.
+ // Note that /Brepro maps to -mno-incremental-linker-compatible.
+ bool DefaultIncrementalLinkerCompatible =
+ C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
+ if (!Args.hasFlag(options::OPT_mincremental_linker_compatible,
+ options::OPT_mno_incremental_linker_compatible,
+ DefaultIncrementalLinkerCompatible))
+ CmdArgs.push_back("-Brepro");
+
bool DLL = Args.hasArg(options::OPT__SLASH_LD, options::OPT__SLASH_LDd,
options::OPT_shared);
if (DLL) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51635.163829.patch
Type: text/x-patch
Size: 1759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180904/4fc8c416/attachment.bin>
More information about the cfe-commits
mailing list