Skip to content

Conversation

@compnerd
Copy link
Member

Handle -use-ld= from the configuration in the selection of the librarian. We do not honour the -Xmanifest or -Xswiftc flags being passed on the command line rather than the plist as we cannot pre-compute the flags.

// TODO(5719) use `lld-link` if the build requests lld.
// TODO(5719) handle `-Xmanifest` vs `-Xswiftc`.
// `-use-ld=` is always joined in Swift.
if let ld = extraSwiftFlags.first(where: { $0.starts(with: "-use-ld=") }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems a bit unfortunate to have to parse the flags like this, can/should we ask users to configure alternative linkers more explicitly?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree it is unfortunate. How would you recommend that we set that up? The general mechanism for this is -use-ld=... which with CMake you would pass via CMAKE_Swift_FLAGS and that is honoured everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

if we have to parse, could we use argument parser to help make this more reliable?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if that is going to be any better because we will need to consider the case of -Xswiftc or -Xclang-linker where the option itself is made opaque. We would need to process both the driver and frontend flags and possibly non-swift-tool flags.

Copy link
Contributor

Choose a reason for hiding this comment

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

this does seems very brittle. any other ideas on how to make it less so? argument parser was the only one I could think of.

@tomerd
Copy link
Contributor

tomerd commented Dec 21, 2022

can we add a test?

@compnerd
Copy link
Member Author

BTW, I think that this might be something we want to pull into 5.8

@compnerd
Copy link
Member Author

@swift-ci please smoke test

@compnerd
Copy link
Member Author

@swift-ci please smoke test Linux platform

@compnerd
Copy link
Member Author

compnerd commented Feb 1, 2023

@swift-ci please smoke test

@compnerd
Copy link
Member Author

compnerd commented Feb 1, 2023

can we add a test?

Done

@compnerd
Copy link
Member Author

compnerd commented Feb 1, 2023

@swift-ci please smoke test

@compnerd compnerd changed the title PackageModel: partially address #5712 PackageModel: partially address #5719 Feb 1, 2023
@compnerd
Copy link
Member Author

compnerd commented Feb 1, 2023

@swift-ci please smoke test

@compnerd
Copy link
Member Author

compnerd commented Feb 1, 2023

@swift-ci please smoke test

@compnerd
Copy link
Member Author

compnerd commented Feb 1, 2023

@swift-ci please smoke test

@compnerd
Copy link
Member Author

compnerd commented Feb 1, 2023

@swift-ci please smoke test

return librarian.basename
}
// TODO(5719) use `lld-link` if the build requests lld.
// TODO(5719) handle `-Xmanifest` vs `-Xswiftc`
Copy link
Contributor

Choose a reason for hiding this comment

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

is this comment relevant?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is, we still need to refine it further for more ways that the flags can be specified.

// TODO(5719) use `lld-link` if the build requests lld.
// TODO(5719) handle `-Xmanifest` vs `-Xswiftc`
// `-use-ld=` is always joined in Swift.
if let ld = extraSwiftFlags.first(where: { $0.starts(with: "-use-ld=") }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

string parsing seems fragile, is there a better way?

Copy link
Member Author

Choose a reason for hiding this comment

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

I really don't see a better way unfortunately. The driver flags, frontend flags, and non-Swift tool flags are all intertwined and will impact this. I think that this might be the best approach (at least for now).

Copy link
Member Author

Choose a reason for hiding this comment

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

@compnerd
Copy link
Member Author

compnerd commented Feb 2, 2023

@swift-ci please smoke test

@tomerd
Copy link
Contributor

tomerd commented Feb 3, 2023

would rather see a more idiomatic solution, but fine with this change if it only impact building on windows.

@compnerd
Copy link
Member Author

compnerd commented Feb 3, 2023

@swift-ci please smoke test

@compnerd
Copy link
Member Author

@swift-ci please smoke test

1 similar comment
@compnerd
Copy link
Member Author

@swift-ci please smoke test

Handle `-use-ld=` from the configuration in the selection of the
librarian.  We do not honour the `-Xmanifest` or `-Xswiftc` flags being
passed on the command line rather than the plist as we cannot
pre-compute the flags.
@compnerd
Copy link
Member Author

@swift-ci please smoke test

@compnerd compnerd enabled auto-merge (rebase) February 14, 2023 23:05
@compnerd compnerd merged commit e5301b7 into swiftlang:main Feb 15, 2023
@compnerd compnerd deleted the 5712 branch April 4, 2023 14:27
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.

4 participants