[lld] acf675b - [LLD] [MinGW] Interpret an empty -entry option as no entry point (#96055)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 01:20:21 PDT 2024


Author: Martin Storsjö
Date: 2024-06-20T11:20:16+03:00
New Revision: acf675b63f9426e61aac2155e29280f7d21f9421

URL: https://github.com/llvm/llvm-project/commit/acf675b63f9426e61aac2155e29280f7d21f9421
DIFF: https://github.com/llvm/llvm-project/commit/acf675b63f9426e61aac2155e29280f7d21f9421.diff

LOG: [LLD] [MinGW] Interpret an empty -entry option as no entry point (#96055)

This fixes https://github.com/llvm/llvm-project/issues/93309, and seems
to match how GNU ld handles this case.

Added: 
    

Modified: 
    lld/MinGW/Driver.cpp
    lld/test/MinGW/driver.test

Removed: 
    


################################################################################
diff  --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index 0d55d5b3672a4..35fd478a21905 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -223,8 +223,10 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
     StringRef s = a->getValue();
     if (args.getLastArgValue(OPT_m) == "i386pe" && s.starts_with("_"))
       add("-entry:" + s.substr(1));
-    else
+    else if (!s.empty())
       add("-entry:" + s);
+    else
+      add("-noentry");
   }
 
   if (args.hasArg(OPT_major_os_version, OPT_minor_os_version,

diff  --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index 619fee8dee7c1..b723c0ad98749 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -60,6 +60,8 @@ RUN: ld.lld -### foo.o -m i386pep --entry bar 2>&1 | FileCheck -check-prefix=ENT
 RUN: ld.lld -### foo.o -m i386pep -entry=bar 2>&1 | FileCheck -check-prefix=ENTRY %s
 RUN: ld.lld -### foo.o -m i386pep --entry=bar 2>&1 | FileCheck -check-prefix=ENTRY %s
 ENTRY: -entry:bar
+RUN: ld.lld -### foo.o -m i386pep -e bar -entry= 2>&1 | FileCheck -check-prefix=NOENTRY --implicit-check-not=-entry %s
+NOENTRY: -noentry
 
 RUN: ld.lld -### foo.o -m i386pep -mllvm bar -mllvm baz 2>&1 | FileCheck -check-prefix=MLLVM %s
 MLLVM: -mllvm:bar -mllvm:baz


        


More information about the llvm-commits mailing list