@@ -198,28 +198,6 @@ extension DarwinToolchain {
198
198
sanitizers: Set < Sanitizer > ,
199
199
targetInfo: FrontendTargetInfo
200
200
) throws -> AbsolutePath {
201
-
202
- // FIXME: If we used Clang as a linker instead of going straight to ld,
203
- // we wouldn't have to replicate a bunch of Clang's logic here.
204
-
205
- // Always link the regular compiler_rt if it's present. Note that the
206
- // regular libclang_rt.a uses a fat binary for device and simulator; this is
207
- // not true for all compiler_rt build products.
208
- //
209
- // Note: Normally we'd just add this unconditionally, but it's valid to build
210
- // Swift and use it as a linker without building compiler_rt.
211
- let targetTriple = targetInfo. target. triple
212
- let darwinPlatformSuffix =
213
- targetTriple. darwinPlatform!. with ( . device) !. libraryNameSuffix
214
- let compilerRTPath =
215
- try clangLibraryPath (
216
- for: targetTriple,
217
- parsedOptions: & parsedOptions)
218
- . appending ( component: " libclang_rt. \( darwinPlatformSuffix) .a " )
219
- if try fileSystem. exists ( compilerRTPath) {
220
- commandLine. append ( . path( compilerRTPath) )
221
- }
222
-
223
201
// Set up for linking.
224
202
let linkerTool : Tool
225
203
switch linkerOutputType {
@@ -229,6 +207,28 @@ extension DarwinToolchain {
229
207
fallthrough
230
208
case . executable:
231
209
linkerTool = . dynamicLinker
210
+
211
+ // FIXME: If we used Clang as a linker instead of going straight to ld,
212
+ // we wouldn't have to replicate a bunch of Clang's logic here.
213
+
214
+ // Always link the regular compiler_rt if it's present. Note that the
215
+ // regular libclang_rt.a uses a fat binary for device and simulator; this is
216
+ // not true for all compiler_rt build products.
217
+ //
218
+ // Note: Normally we'd just add this unconditionally, but it's valid to build
219
+ // Swift and use it as a linker without building compiler_rt.
220
+ let targetTriple = targetInfo. target. triple
221
+ let darwinPlatformSuffix =
222
+ targetTriple. darwinPlatform!. with ( . device) !. libraryNameSuffix
223
+ let compilerRTPath =
224
+ try clangLibraryPath (
225
+ for: targetTriple,
226
+ parsedOptions: & parsedOptions)
227
+ . appending ( component: " libclang_rt. \( darwinPlatformSuffix) .a " )
228
+ if try fileSystem. exists ( compilerRTPath) {
229
+ commandLine. append ( . path( compilerRTPath) )
230
+ }
231
+
232
232
let fSystemArgs = parsedOptions. arguments ( for: . F, . Fsystem)
233
233
for opt in fSystemArgs {
234
234
commandLine. appendFlag ( . F)
0 commit comments