@@ -1016,6 +1016,17 @@ static void getRuntimeLibraryPath(SmallVectorImpl<char> &runtimeLibPath,
10161016 getPlatformNameForTriple (TC.getTriple ()));
10171017}
10181018
1019+ // / Get the runtime library link path with the target triple's specific arch
1020+ // / library folder.
1021+ static void getRuntimeLibraryPathWithArch (SmallVectorImpl<char > &runtimeLibPath,
1022+ const llvm::opt::ArgList &args,
1023+ const ToolChain &TC) {
1024+ getRuntimeLibraryPath (runtimeLibPath, args, TC);
1025+ llvm::sys::path::append (runtimeLibPath,
1026+ swift::getMajorArchitectureName (TC.getTriple ()));
1027+
1028+ }
1029+
10191030static void getClangLibraryPathOnDarwin (SmallVectorImpl<char > &libPath,
10201031 const ArgList &args,
10211032 const ToolChain &TC) {
@@ -1037,8 +1048,8 @@ static void getClangLibraryPathOnLinux(SmallVectorImpl<char> &libPath,
10371048// / Get the runtime library link path for static linking,
10381049// / which is platform-specific and found relative to the compiler.
10391050static void getRuntimeStaticLibraryPath (SmallVectorImpl<char > &runtimeLibPath,
1040- const llvm::opt::ArgList &args,
1041- const ToolChain &TC) {
1051+ const llvm::opt::ArgList &args,
1052+ const ToolChain &TC) {
10421053 // FIXME: Duplicated from CompilerInvocation, but in theory the runtime
10431054 // library link path and the standard library module import path don't
10441055 // need to be the same.
@@ -1056,6 +1067,18 @@ static void getRuntimeStaticLibraryPath(SmallVectorImpl<char> &runtimeLibPath,
10561067 getPlatformNameForTriple (TC.getTriple ()));
10571068}
10581069
1070+ // / Get the runtime library path with the target triple's arch specific
1071+ // / directory.
1072+ static void getRuntimeStaticLibraryPathWithArch (
1073+ SmallVectorImpl<char > &runtimeLibPath,
1074+ const llvm::opt::ArgList &args,
1075+ const ToolChain &TC) {
1076+ getRuntimeStaticLibraryPath (runtimeLibPath, args, TC);
1077+ llvm::sys::path::append (runtimeLibPath,
1078+ swift::getMajorArchitectureName (TC.getTriple ()));
1079+
1080+ }
1081+
10591082ToolChain::InvocationInfo
10601083toolchains::Darwin::constructInvocation (const InterpretJobAction &job,
10611084 const JobContext &context) const {
@@ -1477,7 +1500,7 @@ toolchains::GenericUnix::constructInvocation(const InterpretJobAction &job,
14771500 InvocationInfo II = ToolChain::constructInvocation (job, context);
14781501
14791502 SmallString<128 > runtimeLibraryPath;
1480- getRuntimeLibraryPath (runtimeLibraryPath, context.Args , *this );
1503+ getRuntimeLibraryPathWithArch (runtimeLibraryPath, context.Args , *this );
14811504
14821505 addPathEnvironmentVariableIfNeeded (II.ExtraEnvironment , " LD_LIBRARY_PATH" ,
14831506 " :" , options::OPT_L, context.Args ,
@@ -1610,10 +1633,10 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
16101633 }
16111634
16121635 SmallString<128 > SharedRuntimeLibPath;
1613- getRuntimeLibraryPath (SharedRuntimeLibPath, context.Args , *this );
1636+ getRuntimeLibraryPathWithArch (SharedRuntimeLibPath, context.Args , *this );
16141637
16151638 SmallString<128 > StaticRuntimeLibPath;
1616- getRuntimeStaticLibraryPath (StaticRuntimeLibPath, context.Args , *this );
1639+ getRuntimeStaticLibraryPathWithArch (StaticRuntimeLibPath, context.Args , *this );
16171640
16181641 // Add the runtime library link path, which is platform-specific and found
16191642 // relative to the compiler.
@@ -1627,8 +1650,6 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
16271650 }
16281651
16291652 SmallString<128 > swiftrtPath = SharedRuntimeLibPath;
1630- llvm::sys::path::append (swiftrtPath,
1631- swift::getMajorArchitectureName (getTriple ()));
16321653 llvm::sys::path::append (swiftrtPath, " swiftrt.o" );
16331654 Arguments.push_back (context.Args .MakeArgString (swiftrtPath));
16341655
@@ -1664,6 +1685,7 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
16641685 Arguments.push_back (context.Args .MakeArgString (StaticRuntimeLibPath));
16651686
16661687 SmallString<128 > linkFilePath = StaticRuntimeLibPath;
1688+ llvm::sys::path::remove_filename (linkFilePath); // remove arch name
16671689 llvm::sys::path::append (linkFilePath, " static-executable-args.lnk" );
16681690 auto linkFile = linkFilePath.str ();
16691691
@@ -1677,6 +1699,7 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
16771699 Arguments.push_back (context.Args .MakeArgString (StaticRuntimeLibPath));
16781700
16791701 SmallString<128 > linkFilePath = StaticRuntimeLibPath;
1702+ llvm::sys::path::remove_filename (linkFilePath); // remove arch name
16801703 llvm::sys::path::append (linkFilePath, " static-stdlib-args.lnk" );
16811704 auto linkFile = linkFilePath.str ();
16821705 if (llvm::sys::fs::is_regular_file (linkFile)) {
@@ -1711,6 +1734,7 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
17111734
17121735 if (context.Args .hasArg (options::OPT_profile_generate)) {
17131736 SmallString<128 > LibProfile (SharedRuntimeLibPath);
1737+ llvm::sys::path::remove_filename (LibProfile); // remove arch name
17141738 llvm::sys::path::remove_filename (LibProfile); // remove platform name
17151739 llvm::sys::path::append (LibProfile, " clang" , " lib" );
17161740
0 commit comments