Skip to content

Commit 380457c

Browse files
nettlepaciidgh
authored andcommitted
[BuildPlan] Moved -Xcxx flags to the end of the chain of arguments (#1380)
* [BuildPlan] In reference to SR-6164, moved -Xcxx flags to the end of the chain of arguments. - https://bugs.swift.org/browse/SR-6164 * Commented the constraints for argument ordering to allow user overrides of -Xswiftc, -Xlinker, -Xcc and -Xcxx. - https://bugs.swift.org/browse/SR-6164
1 parent d92b355 commit 380457c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,6 @@ public final class ClangTargetDescription {
179179
args += buildParameters.toolchain.extraCCFlags
180180
args += optimizationArguments
181181

182-
// Add extra C++ flags if this target contains C++ files.
183-
if clangTarget.isCXX {
184-
args += self.buildParameters.flags.cxxCompilerFlags
185-
}
186-
187182
// Only enable ARC on macOS.
188183
#if os(macOS)
189184
args += ["-fobjc-arc"]
@@ -196,7 +191,14 @@ public final class ClangTargetDescription {
196191
args += ["-I", clangTarget.includeDir.asString]
197192
args += additionalFlags
198193
args += moduleCacheArgs
194+
195+
// User arguments (from -Xcc and -Xcxx below) should follow generated arguments to allow user overrides
199196
args += buildParameters.flags.cCompilerFlags
197+
198+
// Add extra C++ flags if this target contains C++ files.
199+
if clangTarget.isCXX {
200+
args += self.buildParameters.flags.cxxCompilerFlags
201+
}
200202
return args
201203
}
202204

@@ -286,6 +288,8 @@ public final class SwiftTargetDescription {
286288
args += ["-j\(SwiftCompilerTool.numThreads)", "-DSWIFT_PACKAGE"]
287289
args += additionalFlags
288290
args += moduleCacheArgs
291+
292+
// User arguments (from -Xswiftc) should follow generated arguments to allow user overrides
289293
args += buildParameters.swiftCompilerFlags
290294
return args
291295
}
@@ -417,6 +421,8 @@ public final class ProductBuildDescription {
417421
args += ["-Xlinker", "-rpath=$ORIGIN"]
418422
#endif
419423
args += objects.map({ $0.asString })
424+
425+
// User arguments (from -Xlinker and -Xswiftc) should follow generated arguments to allow user overrides
420426
args += buildParameters.linkerFlags
421427
args += stripInvalidArguments(buildParameters.swiftCompilerFlags)
422428
return args

0 commit comments

Comments
 (0)