[lld] [LLD] [COFF] Print a warning when using /dependentloadflag without load config (PR #117400)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 27 02:25:16 PST 2024
================
@@ -29,3 +30,4 @@ FAIL: lld-link: error: /dependentloadflag: invalid argument: zz
FAIL-RANGE: lld-link: error: /dependentloadflag: invalid argument: 0xf0000
FAIL-NOARG: lld-link: error: /dependentloadflag: no argument specified
+WARN-NOBASE: lld-link: warning: _load_config_used not found, /delayloadflag will have no effect
----------------
mstorsjo wrote:
FWIW, I also felt a little skeptic that this would be enough, as we're only scanning the files that are mentioned directly on the command line:
https://github.com/llvm/llvm-project/blob/llvmorg-19.1.4/lld/COFF/Driver.cpp#L2134-L2169
As technically, the `_load_config_used` struct can be brought in at a later stage as well, here: https://github.com/llvm/llvm-project/blob/llvmorg-19.1.4/lld/COFF/Driver.cpp#L2397-L2448
I tried to adjust the testcase even further, so that we have two files on the command line - an entry point object, and a library. The entry point object references the library, and the object in the library has got an embedded `/defaultlib:` directive, pointing to another library, which has got the `_load_config_used` struct. But even then, the warning works as expected - not warning for this.
I also tested with real MSVC libraries (where there's usually a somewhat deep nested structure of `/defaultlib:` directives between msvcrt/ucrt/vcruntime etc), but there, the `_load_config_used` is also in a toplevel library, and linking a regular hello world, with `/dependentloadflag:0`, doesn't produce any warning here.
So with that, I think this may cover enough of the practical cases and keeps the code simple. Or what do you think @alvinhochun?
https://github.com/llvm/llvm-project/pull/117400
More information about the llvm-commits
mailing list