Skip to content

Commit acf675b

Browse files
authored
[LLD] [MinGW] Interpret an empty -entry option as no entry point (#96055)
This fixes #93309, and seems to match how GNU ld handles this case.
1 parent b9ad0b6 commit acf675b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lld/MinGW/Driver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
223223
StringRef s = a->getValue();
224224
if (args.getLastArgValue(OPT_m) == "i386pe" && s.starts_with("_"))
225225
add("-entry:" + s.substr(1));
226-
else
226+
else if (!s.empty())
227227
add("-entry:" + s);
228+
else
229+
add("-noentry");
228230
}
229231

230232
if (args.hasArg(OPT_major_os_version, OPT_minor_os_version,

lld/test/MinGW/driver.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ RUN: ld.lld -### foo.o -m i386pep --entry bar 2>&1 | FileCheck -check-prefix=ENT
6060
RUN: ld.lld -### foo.o -m i386pep -entry=bar 2>&1 | FileCheck -check-prefix=ENTRY %s
6161
RUN: ld.lld -### foo.o -m i386pep --entry=bar 2>&1 | FileCheck -check-prefix=ENTRY %s
6262
ENTRY: -entry:bar
63+
RUN: ld.lld -### foo.o -m i386pep -e bar -entry= 2>&1 | FileCheck -check-prefix=NOENTRY --implicit-check-not=-entry %s
64+
NOENTRY: -noentry
6365

6466
RUN: ld.lld -### foo.o -m i386pep -mllvm bar -mllvm baz 2>&1 | FileCheck -check-prefix=MLLVM %s
6567
MLLVM: -mllvm:bar -mllvm:baz

0 commit comments

Comments
 (0)