Skip to content

Conversation

@daveinglis
Copy link
Contributor

@daveinglis daveinglis commented Nov 4, 2025

  • remove the platform specifics from computeLibraryArgs (we cannot assume
    that all libraries have a lib prefix and what there suffix is.) So we
    now use the FileType prefix and remove any suffix when using
    searchPathFlagsForLD, moving this into the LinkerSpec.LibrarySpecifier
    extension, this allows for proper searching of libraries, and linking
    of dynamic libraries (especially on Windows).

@daveinglis
Copy link
Contributor Author

@swift-ci test

@daveinglis daveinglis force-pushed the building_tests_fixes_windows branch 8 times, most recently from c224e9e to 843e629 Compare November 10, 2025 16:21
@daveinglis daveinglis changed the title Change how libraries are specified to the linker Change how libraries are specified to the linker when using searched libs Nov 10, 2025
@daveinglis daveinglis force-pushed the building_tests_fixes_windows branch 5 times, most recently from e6674c3 to 3d422f3 Compare November 11, 2025 16:39
@daveinglis
Copy link
Contributor Author

@swift-ci test

@daveinglis daveinglis force-pushed the building_tests_fixes_windows branch from 3d422f3 to 27d13e5 Compare November 11, 2025 19:40
@daveinglis
Copy link
Contributor Author

@swift-ci test

@daveinglis daveinglis force-pushed the building_tests_fixes_windows branch from 27d13e5 to 4fe5921 Compare November 11, 2025 21:06
@daveinglis
Copy link
Contributor Author

@swift-ci test

@daveinglis daveinglis marked this pull request as ready for review November 12, 2025 01:24
}

if specifier.useSearchPaths, basename.hasPrefix("lib"), basename.hasSuffix(".a") {
if specifier.useSearchPaths {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we emit some kind of warning here if the library name doesn't have one of the prefixes we think will allow it to be found via search paths?

fileprivate extension LinkerSpec.LibrarySpecifier {
func searchPathFlagsForLd(_ name: String) -> [String] {
func searchPathFlagsForLd() -> [String] {
let strippedName: String
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question here, should we warn if we get a filename format we don't recognize here / don't think will be found?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, rethinking this.... I think we need to fallback to using absolute path linking when that happens, this would be the same as how it was before....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are also tests that would have this warning (and fail due to it), but since we will fallback to an absolute path, not sure the warning it necessary now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

falling back w/ no warning makes sense to me

self.dsymPath = dsymPath
self.xcframeworkSourcePath = xcframeworkSourcePath
self.privacyFile = privacyFile
self.libPrefix = prefixes.first
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we only consider the first element here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya, I was thinking about that and I just couldn't think of a case where there would ever be more that one so I forego the extract logic of handling multiple and just went with the lazy handle one method. Do you feel its worth handling multiple?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Only handling one sounds ok to me, but I think we should then either only allow one in the spec or error out if we parse more than one

@owenv
Copy link
Collaborator

owenv commented Nov 12, 2025

overall this looks great, just have a few questions

@owenv
Copy link
Collaborator

owenv commented Nov 12, 2025

we should also run this through cross-repo testing before merging

@daveinglis daveinglis force-pushed the building_tests_fixes_windows branch 2 times, most recently from 16c3a12 to d788510 Compare November 12, 2025 16:06
…libs

- remove the platform specifics from computeLibraryArgs (we cannot assume
  that all libraries have a lib prefix and what there suffix is.) So we
  now use the FileType prefix and remove any suffix when using
  searchPathFlagsForLD, moving this into the LinkerSpec.LibrarySpecifier
  extension, this allows for proper searching of libraries, and linking
  of dynamic libraries (especially on Windows).
@daveinglis daveinglis force-pushed the building_tests_fixes_windows branch from d788510 to cdcfe04 Compare November 12, 2025 16:19
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.

2 participants