-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prefix linker flags with -Xlinker #7588
base: main
Are you sure you want to change the base?
Conversation
Currently SwiftPM fowards unsafe flags under linker settings directly to swiftc un-prefixed. These flags should instead be prefixed with -Xlinker, swiftc flags can instead be passed as unsafe flags under Swift settings. This commit updates SwiftPM to prefix unsafe linker flags with -Xlinker if the package the target is part of uses tools version 6.0.
Open for discussion! |
@@ -390,7 +390,13 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription | |||
// Other linker flags. | |||
for target in self.staticTargets { | |||
let scope = self.buildParameters.createScope(for: target) | |||
flags += scope.evaluate(.OTHER_LDFLAGS) | |||
let additionalFlags = scope.evaluate(.OTHER_LDFLAGS) | |||
// FIXME: this should be based on the target package's tools version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC our current convention was to base all behavior on root package's tools version? @neonichu do I understand that correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends. Mostly we try to apply the specific package's tools-version, but there are some behaviors that are more far reaching where we look at root packages.
I think for more build related things like this that should be localized to the package itself, looking at the specific package is the most appropriate.
Overall makes sense to me, but this needs tests and that |
Currently SwiftPM fowards unsafe flags under linker settings directly to swiftc un-prefixed. These flags should instead be prefixed with -Xlinker, swiftc flags can instead be passed as unsafe flags under Swift settings.
This commit updates SwiftPM to prefix unsafe linker flags with -Xlinker if the package the target is part of uses tools version 6.0.