Skip to content

Conversation

daveinglis
Copy link
Contributor

  • the also changes the source modules on Windows to be a static lib since pre-linked .o is not supported.

depends on: swiftlang/swift-build#795

case .staticLibrary, .executable:
pifProductName = "\(sourceModule.name).o"
executableName = pifProductName
#if os(Windows)
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need to vary this based on the platform being built for rather than the host platform so we don't break cross-compilation. There's not a great way to conditionalize productType based on platform in the PIF today, so this is where having a new "swiftPMTarget" product type to abstract away the platform specific differences might be useful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as discussed offline, this is only temporary (I can add a comment here indicating such) but I think if we can get some basic windows functionally working like building and running an executable which this change could get us there, with tests that now pass, we can then make the incremental changes like using a new product type and moving this kind of platform conditional into swift-build for that product type, and then have those tests ensure we don't regress with those change.

Copy link
Contributor

Choose a reason for hiding this comment

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

How long is temporary - something on the order of a few weeks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope so, will be working on the new product type next.

settings[.GENERATE_PRELINK_OBJECT_FILE] = "NO"
settings[.STRIP_INSTALLED_PRODUCT] = "NO"

// Macros build as executables, so they need slightly different
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this block need to be dropped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so correct me if I'm wrong but setting the MACH_O_TYPE should not be required to be set in the PIF as the product type definition in swift-build sets it for us, and with that said i feel CLANG_COVERAGE_MAPPING_LINKER_ARGS should be handled that same way

Copy link
Contributor

Choose a reason for hiding this comment

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

that's a good point, I wonder why this was put here originally...

and yeah, lets sink the CLANG_COVERAGE_MAPPING_LINKER_ARGS change into Swift Build

delegate: PackagePIFBuilder.BuildDelegate,
) {
self[.TARGET_NAME] = targetName
self[.PRODUCT_NAME] = createDylibForDynamicProducts ? productName : executableName
Copy link
Contributor

Choose a reason for hiding this comment

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

Will removing createDylibForDynamicProducts break the use case of xcodebuild building dylibs? We might be missing some tests there...

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 think @owenv was saying offline that there is some history here we just don't know about as to why this was like this. I think we should try and move forward with this as it cleans things up and I imagine we should be able to address any fallout quickly if need be...

@daveinglis
Copy link
Contributor Author

@swift-ci please test

@daveinglis
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@owenv owenv left a comment

Choose a reason for hiding this comment

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

LGTM, once the CLANG_COVERAGE_MAPPING_LINKER_ARGS override is applied at the Swift Build layer

@daveinglis
Copy link
Contributor Author

@swift-ci please test

@daveinglis
Copy link
Contributor Author

@swift-ci test

@daveinglis
Copy link
Contributor Author

@swift-ci test

- the also changes the source modules on Windows to be a static lib
 since pre-linked .o is not supported.
@daveinglis
Copy link
Contributor Author

@swift-ci test

@daveinglis
Copy link
Contributor Author

@swift-ci test windows

@daveinglis daveinglis merged commit a112ab8 into swiftlang:main Sep 17, 2025
6 checks passed
bnbarham added a commit that referenced this pull request Sep 18, 2025
@daveinglis daveinglis deleted the pif_updates branch October 2, 2025 18:15
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