Skip to content

Commit 617b140

Browse files
committed
[ARM64EC] Add softintrin.lib as an implicit dependency to object files.
This copies MSVC behavior, and avoids weird link errors in certain cases.
1 parent 349327f commit 617b140

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4697,7 +4697,8 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
46974697
Output.getFilename());
46984698
}
46994699

4700-
static void ProcessVSRuntimeLibrary(const ArgList &Args,
4700+
static void ProcessVSRuntimeLibrary(const ToolChain &TC,
4701+
const ArgList &Args,
47014702
ArgStringList &CmdArgs) {
47024703
unsigned RTOptionID = options::OPT__SLASH_MT;
47034704

@@ -4760,6 +4761,12 @@ static void ProcessVSRuntimeLibrary(const ArgList &Args,
47604761
// implemented in clang.
47614762
CmdArgs.push_back("--dependent-lib=oldnames");
47624763
}
4764+
4765+
// All Arm64EC object files implicitly add softintrin.lib. This is necessary
4766+
// even if the file doesn't actually refer to any of the routines because
4767+
// the CRT itself has incomplete dependency markings.
4768+
if (TC.getTriple().isWindowsArm64EC())
4769+
CmdArgs.push_back("--dependent-lib=softintrin");
47634770
}
47644771

47654772
void Clang::ConstructJob(Compilation &C, const JobAction &JA,
@@ -7015,7 +7022,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
70157022

70167023
if (Triple.isWindowsMSVCEnvironment() && !D.IsCLMode() &&
70177024
Args.hasArg(options::OPT_fms_runtime_lib_EQ))
7018-
ProcessVSRuntimeLibrary(Args, CmdArgs);
7025+
ProcessVSRuntimeLibrary(getToolChain(), Args, CmdArgs);
70197026

70207027
// Handle -fgcc-version, if present.
70217028
VersionTuple GNUCVer;
@@ -8134,7 +8141,7 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
81348141
ArgStringList &CmdArgs) const {
81358142
bool isNVPTX = getToolChain().getTriple().isNVPTX();
81368143

8137-
ProcessVSRuntimeLibrary(Args, CmdArgs);
8144+
ProcessVSRuntimeLibrary(getToolChain(), Args, CmdArgs);
81388145

81398146
if (Arg *ShowIncludes =
81408147
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)