[lld] [LLD] [MinGW] Interpret an empty -entry option as no entry point (PR #96055)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 05:59:07 PDT 2024
https://github.com/mstorsjo updated https://github.com/llvm/llvm-project/pull/96055
>From 95b091f31f8e1d9dd3c26d5eab97c8fe261925df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Wed, 19 Jun 2024 13:55:59 +0300
Subject: [PATCH] [LLD] [MinGW] Interpret an empty -entry option as no entry
point
This fixes https://github.com/llvm/llvm-project/issues/93309,
and seems to match how GNU ld handles this case.
Also treat a missing -entry argument as no entry point; this
also is what GNU ld does in this case.
---
lld/MinGW/Driver.cpp | 4 +++-
lld/test/MinGW/driver.test | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
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