Skip to content

Commit 45432ee

Browse files
[ARM64EC] Add softintrin.lib as an implicit dependency to object files. (#89171)
This copies MSVC behavior, and avoids weird link errors in certain cases.
1 parent 5232cec commit 45432ee

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4733,7 +4733,7 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
47334733
Output.getFilename());
47344734
}
47354735

4736-
static void ProcessVSRuntimeLibrary(const ArgList &Args,
4736+
static void ProcessVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
47374737
ArgStringList &CmdArgs) {
47384738
unsigned RTOptionID = options::OPT__SLASH_MT;
47394739

@@ -4796,6 +4796,12 @@ static void ProcessVSRuntimeLibrary(const ArgList &Args,
47964796
// implemented in clang.
47974797
CmdArgs.push_back("--dependent-lib=oldnames");
47984798
}
4799+
4800+
// All Arm64EC object files implicitly add softintrin.lib. This is necessary
4801+
// even if the file doesn't actually refer to any of the routines because
4802+
// the CRT itself has incomplete dependency markings.
4803+
if (TC.getTriple().isWindowsArm64EC())
4804+
CmdArgs.push_back("--dependent-lib=softintrin");
47994805
}
48004806

48014807
void Clang::ConstructJob(Compilation &C, const JobAction &JA,
@@ -7051,7 +7057,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
70517057

70527058
if (Triple.isWindowsMSVCEnvironment() && !D.IsCLMode() &&
70537059
Args.hasArg(options::OPT_fms_runtime_lib_EQ))
7054-
ProcessVSRuntimeLibrary(Args, CmdArgs);
7060+
ProcessVSRuntimeLibrary(getToolChain(), Args, CmdArgs);
70557061

70567062
// Handle -fgcc-version, if present.
70577063
VersionTuple GNUCVer;
@@ -8178,7 +8184,7 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
81788184
ArgStringList &CmdArgs) const {
81798185
bool isNVPTX = getToolChain().getTriple().isNVPTX();
81808186

8181-
ProcessVSRuntimeLibrary(Args, CmdArgs);
8187+
ProcessVSRuntimeLibrary(getToolChain(), Args, CmdArgs);
81828188

81838189
if (Arg *ShowIncludes =
81848190
Args.getLastArg(options::OPT__SLASH_showIncludes,

clang/test/Driver/cl-options.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@
790790
// RUN: %clang_cl -vctoolsdir "" /arm64EC /c -### -- %s 2>&1 | FileCheck --check-prefix=ARM64EC %s
791791
// ARM64EC-NOT: /arm64EC has been overridden by specified target
792792
// ARM64EC: "-triple" "arm64ec-pc-windows-msvc19.33.0"
793+
// ARM64EC-SAME: "--dependent-lib=softintrin"
793794

794795
// RUN: %clang_cl -vctoolsdir "" /arm64EC /c -target x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck --check-prefix=ARM64EC_OVERRIDE %s
795796
// ARM64EC_OVERRIDE: warning: /arm64EC has been overridden by specified target: x86_64-pc-windows-msvc; option ignored

0 commit comments

Comments
 (0)