[lld] [LLD] [COFF] Print a warning when using /dependentloadflag without load config (PR #117400)

via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 23 01:51:09 PST 2024


================
@@ -2307,8 +2307,11 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
 
   // Handle /dependentloadflag
   for (auto *arg :
-       args.filtered(OPT_dependentloadflag, OPT_dependentloadflag_opt))
+       args.filtered(OPT_dependentloadflag, OPT_dependentloadflag_opt)) {
     parseDependentLoadFlags(arg);
+    if (!ctx.symtab.findUnderscore("_load_config_used"))
+      warn("_load_config_used not found, /delayloadflag will have no effect");
+  }
----------------
alvinhochun wrote:

Is it right to check for the symbol so early? I thought at this point the objects/libraries haven't even been loaded yet so the symbol will always be missing.

I think the check should be added here instead: https://github.com/llvm/llvm-project/blob/3a31427224d4fa49d7ef737b21f6027dc4928ecf/lld/COFF/Writer.cpp#L2604-L2611
It can probably just check for a non-zero value, like in https://github.com/llvm/llvm-project/blob/3a31427224d4fa49d7ef737b21f6027dc4928ecf/lld/COFF/Writer.cpp#L2634-L2635

https://github.com/llvm/llvm-project/pull/117400


More information about the llvm-commits mailing list