File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -181,13 +181,23 @@ extension GenericUnixToolchain {
181181 }
182182
183183 if !isEmbeddedEnabled && !parsedOptions. hasArgument ( . nostartfiles) {
184- let swiftrtPath = VirtualPath . lookup ( targetInfo. runtimeResourcePath. path)
185- . appending (
186- components: targetTriple. platformName ( ) ?? " " ,
187- String ( majorArchitectureName ( for: targetTriple) ) ,
188- " swiftrt.o "
189- )
190- commandLine. appendPath ( swiftrtPath)
184+ let rsrc : VirtualPath
185+ // Prefer the swiftrt.o runtime file from the SDK, if it's specified
186+ // with a separate C/C++ sysroot.
187+ if let sdk = targetInfo. sdkPath && parsedOptions. hasArgument ( . sysroot) {
188+ let swiftDir : String
189+ if staticStdlib || staticExecutable {
190+ swiftDir = " swift_static "
191+ } else {
192+ swiftDir = " swift "
193+ }
194+ rsrc = VirtualPath . lookup ( sdk. path) . appending ( components: " usr " , " lib " , swiftDir)
195+ } else {
196+ rsrc = VirtualPath . lookup ( targetInfo. runtimeResourcePath. path)
197+ }
198+ let platform : String = targetTriple. platformName ( ) ?? " "
199+ let architecture : String = majorArchitectureName ( for: targetTriple)
200+ commandLine. appendPath ( rsrc. appending ( components: platform, architecture, " swiftrt.o " ) )
191201 }
192202
193203 // If we are linking statically, we need to add all
You can’t perform that action at this time.
0 commit comments