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