Skip to content

Commit

Permalink
[lld] [MinGW] Support targeting ARM64EC (#78911)
Browse files Browse the repository at this point in the history
'arm64ecpe' was chosen arbitrarily as gcc MinGW doesn't provide EC
support.
  • Loading branch information
bylaws authored Jan 30, 2024
1 parent b52fe2d commit a9ffdc1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lld/Common/DriverDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ static cl::TokenizerCallback getDefaultQuotingStyle() {
}

static bool isPETargetName(StringRef s) {
return s == "i386pe" || s == "i386pep" || s == "thumb2pe" || s == "arm64pe";
return s == "i386pe" || s == "i386pep" || s == "thumb2pe" || s == "arm64pe" ||
s == "arm64ecpe";
}

static std::optional<bool> isPETarget(llvm::ArrayRef<const char *> args) {
Expand Down
3 changes: 3 additions & 0 deletions lld/MinGW/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,

if (args.getLastArgValue(OPT_m) != "thumb2pe" &&
args.getLastArgValue(OPT_m) != "arm64pe" &&
args.getLastArgValue(OPT_m) != "arm64ecpe" &&
args.hasFlag(OPT_disable_dynamicbase, OPT_dynamicbase, false))
add("-dynamicbase:no");
if (args.hasFlag(OPT_disable_high_entropy_va, OPT_high_entropy_va, false))
Expand Down Expand Up @@ -409,6 +410,8 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
add("-machine:arm");
else if (s == "arm64pe")
add("-machine:arm64");
else if (s == "arm64ecpe")
add("-machine:arm64ec");
else
error("unknown parameter: -m" + s);
}
Expand Down
6 changes: 6 additions & 0 deletions lld/test/MinGW/driver.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ ARM64-SAME: -machine:arm64
ARM64-SAME: -alternatename:__image_base__=__ImageBase
ARM64-SAME: foo.o

RUN: ld.lld -### foo.o -m arm64ecpe 2>&1 | FileCheck -check-prefix=ARM64EC %s
ARM64EC: -out:a.exe
ARM64EC-SAME: -machine:arm64ec
ARM64EC-SAME: -alternatename:__image_base__=__ImageBase
ARM64EC-SAME: foo.o

RUN: ld.lld -### foo.o -m i386pep -shared 2>&1 | FileCheck -check-prefix=SHARED %s
RUN: ld.lld -### foo.o -m i386pep --shared 2>&1 | FileCheck -check-prefix=SHARED %s
RUN: ld.lld -### foo.o -m i386pep --dll 2>&1 | FileCheck -check-prefix=SHARED %s
Expand Down

0 comments on commit a9ffdc1

Please sign in to comment.