Skip to content

Begin adding support for using swiftc as a linker driver #236

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

Merged
merged 1 commit into from
Apr 2, 2025

Conversation

owenv
Copy link
Collaborator

@owenv owenv commented Feb 27, 2025

This is controlled via the LINKER_DRIVER setting

This is enough to at least link a basic CLI tool on macOS. It needs some more work and tests still

@owenv
Copy link
Collaborator Author

owenv commented Feb 27, 2025

@swift-ci test

args += ["-compatibility_version", compatibilityVersion]
switch scope.evaluate(BuiltinMacros.LINKER_DRIVER) {
case .clang:
args += ["-compatibility_version", compatibilityVersion]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to prefer the driver option at all vs just using Xlinker? Does -compatibility_version at the clang level actually do anything?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have any behavior I know of but I'd prefer to use driver options whenever possible for maximum compatibility

@owenv owenv force-pushed the swiftc-linker-driver branch from 3729cde to 4506efc Compare March 26, 2025 20:41
@owenv
Copy link
Collaborator Author

owenv commented Mar 26, 2025

@swift-ci test Linux

@owenv owenv force-pushed the swiftc-linker-driver branch from 4506efc to 9022e09 Compare March 26, 2025 21:02
@owenv
Copy link
Collaborator Author

owenv commented Mar 26, 2025

@swift-ci test

@owenv owenv force-pushed the swiftc-linker-driver branch from 9022e09 to 8aa2101 Compare March 26, 2025 23:00
@owenv
Copy link
Collaborator Author

owenv commented Mar 26, 2025

@swift-ci test

@owenv owenv force-pushed the swiftc-linker-driver branch from 8aa2101 to 7354e45 Compare March 26, 2025 23:18
@owenv
Copy link
Collaborator Author

owenv commented Mar 26, 2025

@swift-ci test

@owenv owenv force-pushed the swiftc-linker-driver branch from 7354e45 to f48504d Compare March 26, 2025 23:38
@owenv
Copy link
Collaborator Author

owenv commented Mar 26, 2025

@swift-ci test

@owenv owenv force-pushed the swiftc-linker-driver branch from f48504d to 647b134 Compare March 26, 2025 23:45
@owenv
Copy link
Collaborator Author

owenv commented Mar 26, 2025

@swift-ci test linux

@owenv owenv force-pushed the swiftc-linker-driver branch from 647b134 to 14f6908 Compare March 26, 2025 23:54
@owenv
Copy link
Collaborator Author

owenv commented Mar 26, 2025

@swift-ci test linux

@owenv owenv force-pushed the swiftc-linker-driver branch from 14f6908 to 64337e3 Compare March 27, 2025 00:04
@owenv
Copy link
Collaborator Author

owenv commented Mar 27, 2025

@swift-ci test linux

@owenv owenv force-pushed the swiftc-linker-driver branch from 64337e3 to eed2eb1 Compare March 27, 2025 00:13
@owenv
Copy link
Collaborator Author

owenv commented Mar 27, 2025

@swift-ci test linux

@owenv
Copy link
Collaborator Author

owenv commented Mar 27, 2025

@swift-ci test macOS

@owenv
Copy link
Collaborator Author

owenv commented Mar 27, 2025

@swift-ci test windows

@owenv owenv force-pushed the swiftc-linker-driver branch from eed2eb1 to 3a36033 Compare March 27, 2025 16:20
@owenv
Copy link
Collaborator Author

owenv commented Mar 27, 2025

@swift-ci test

@owenv
Copy link
Collaborator Author

owenv commented Mar 27, 2025

@swift-ci test Windows

@owenv owenv force-pushed the swiftc-linker-driver branch from 3a36033 to c1ed45a Compare March 27, 2025 17:13
@owenv
Copy link
Collaborator Author

owenv commented Mar 27, 2025

@swift-ci test

@owenv owenv force-pushed the swiftc-linker-driver branch from c1ed45a to 54ef5be Compare March 27, 2025 20:02
@owenv
Copy link
Collaborator Author

owenv commented Mar 27, 2025

@swift-ci test Windows

1 similar comment
@owenv
Copy link
Collaborator Author

owenv commented Mar 27, 2025

@swift-ci test Windows

@owenv
Copy link
Collaborator Author

owenv commented Mar 27, 2025

@swift-ci test Windows

@owenv
Copy link
Collaborator Author

owenv commented Mar 29, 2025

@swift-ci test

@owenv owenv force-pushed the swiftc-linker-driver branch from 54ef5be to 6473758 Compare March 31, 2025 17:32
@owenv
Copy link
Collaborator Author

owenv commented Mar 31, 2025

@swift-ci test Windows

@owenv owenv force-pushed the swiftc-linker-driver branch from 6473758 to 71c9bc5 Compare March 31, 2025 18:20
@owenv
Copy link
Collaborator Author

owenv commented Mar 31, 2025

@swift-ci test Windows

@owenv owenv force-pushed the swiftc-linker-driver branch from 71c9bc5 to 8c23c59 Compare April 1, 2025 21:28
@owenv
Copy link
Collaborator Author

owenv commented Apr 1, 2025

@swift-ci test Windows

@owenv owenv force-pushed the swiftc-linker-driver branch from 8c23c59 to 52923db Compare April 2, 2025 04:48
@owenv
Copy link
Collaborator Author

owenv commented Apr 2, 2025

@swift-ci test

This is controlled via the LINKER_DRIVER setting
@owenv owenv force-pushed the swiftc-linker-driver branch from 52923db to 47e61e8 Compare April 2, 2025 05:30
@owenv
Copy link
Collaborator Author

owenv commented Apr 2, 2025

@swift-ci test

@owenv owenv marked this pull request as ready for review April 2, 2025 06:10
@@ -234,7 +234,13 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
public static let identifier = "com.apple.pbx.linkers.ld"

public override func computeExecutablePath(_ cbc: CommandBuildContext) -> String {
return cbc.producer.hostOperatingSystem.imageFormat.executableName(basename: "clang")
// TODO: We should also provide an "auto" option which chooses based on the source files in the target
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do remember there being some subtle differences between linker drivers for C sources as well, so "auto" could result in surprises.

@owenv owenv merged commit f05dee0 into main Apr 2, 2025
3 checks passed
@owenv owenv deleted the swiftc-linker-driver branch April 2, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants