Skip to content

Commit 3d7260b

Browse files
authored
[LLD] [MinGW] Implement --dependent-load-flag option (#113814)
Implement MSVC's `/DEPENDENTLOADFLAG` as `--dependent-load-flag` and forward it to COFF. ld.bfd doesn't support it, yet at least, but if they later add support for something similar, hopefully they’d agree to the same option name. There is no solid need for it yet, but it's being considered: msys2/MINGW-packages#22216 (comment)
1 parent 28bba0d commit 3d7260b

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

lld/MinGW/Driver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
407407
OPT_no_allow_multiple_definition, false))
408408
add("-force:multiple");
409409

410+
if (auto *a = args.getLastArg(OPT_dependent_load_flag))
411+
add("-dependentloadflag:" + StringRef(a->getValue()));
412+
410413
if (auto *a = args.getLastArg(OPT_icf)) {
411414
StringRef s = a->getValue();
412415
if (s == "all")

lld/MinGW/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def _HASH_HASH_HASH : Flag<["-"], "###">,
202202
HelpText<"Print (but do not run) the commands to run for this compilation">;
203203
def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">;
204204
defm delayload: Eq<"delayload", "DLL to load only on demand">;
205+
defm dependent_load_flag: EEq<"dependent-load-flag", "Override default LibraryLoad flags">;
205206
defm mllvm: EqNoHelp<"mllvm">;
206207
defm pdb: Eq<"pdb", "Output PDB debug info file, chosen implicitly if the argument is empty">;
207208
defm Xlink : Eq<"Xlink", "Pass <arg> to the COFF linker">, MetaVarName<"<arg>">;

lld/test/MinGW/driver.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,6 @@ RUN: ld.lld -### foo.o -m i386pep --rpath foo 2>&1 | FileCheck -check-prefix=WAR
462462
RUN: ld.lld -### foo.o -m i386pep -rpath=foo 2>&1 | FileCheck -check-prefix=WARN_RPATH %s
463463
RUN: ld.lld -### foo.o -m i386pep --rpath=foo 2>&1 | FileCheck -check-prefix=WARN_RPATH %s
464464
WARN_RPATH: warning: parameter -{{-?}}rpath has no effect on PE/COFF targets
465+
466+
RUN: ld.lld -### foo.o -m i386pe --dependent-load-flag=0x800 2>&1 | FileCheck -check-prefix=DEPENDENT_LOAD_FLAG %s
467+
DEPENDENT_LOAD_FLAG: -dependentloadflag:0x800

0 commit comments

Comments
 (0)