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

Mateusz Mikuła via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 2 08:14:28 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");
+  }
----------------
mati865 wrote:

> My preference would be to put the check closer to where the field in `_load_config_used` is being set, and given that `Writer::prepareLoadConfig` already does other checks on `_load_config_used`, it just seems to me to be the more logical place to add the check.

Sure, I don't have a strong option here for either approach.

> In addition, the current code would emit one warning per every `/dependentloadflag` flag specified (when multiple are passed, only the last one would take effect).

Oh, that's right. I'll see what I can do about it.

> Also, I just noticed the typo – the warning message refers to "/delayloadflag" instead of `/dependentloadflag`.

Dang, good catch!

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


More information about the llvm-commits mailing list