Skip to content

Commit 39eeb2e

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 39eeb2e

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
@@ -4697,7 +4697,7 @@ 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, const ArgList &Args,
47014701
ArgStringList &CmdArgs) {
47024702
unsigned RTOptionID = options::OPT__SLASH_MT;
47034703

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

47654771
void Clang::ConstructJob(Compilation &C, const JobAction &JA,
@@ -7015,7 +7021,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
70157021

70167022
if (Triple.isWindowsMSVCEnvironment() && !D.IsCLMode() &&
70177023
Args.hasArg(options::OPT_fms_runtime_lib_EQ))
7018-
ProcessVSRuntimeLibrary(Args, CmdArgs);
7024+
ProcessVSRuntimeLibrary(getToolChain(), Args, CmdArgs);
70197025

70207026
// Handle -fgcc-version, if present.
70217027
VersionTuple GNUCVer;
@@ -8134,7 +8140,7 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
81348140
ArgStringList &CmdArgs) const {
81358141
bool isNVPTX = getToolChain().getTriple().isNVPTX();
81368142

8137-
ProcessVSRuntimeLibrary(Args, CmdArgs);
8143+
ProcessVSRuntimeLibrary(getToolChain(), Args, CmdArgs);
81388144

81398145
if (Arg *ShowIncludes =
81408146
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)