Skip to content

Conversation

@nkcsgexi
Copy link
Contributor

@nkcsgexi nkcsgexi commented Nov 17, 2025

When compiling a Swift module in incremental mode, each Swift source file is compiled into an object file and we use linker to link them together. Because the predicate function for checking dynamic feature availability is eagerly synthesized per compilation unit, the linker will complain about duplicated symbols for them. Setting their visibility as private ensures that linker doesn't see them, thus addressing the linker errors.

One workaround for this problem is to enable WMO.

rdar://164971313

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi force-pushed the private-predicate-check branch from dcd7c04 to 3609030 Compare November 17, 2025 21:25
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi force-pushed the private-predicate-check branch from 3609030 to 1d915ca Compare November 17, 2025 23:04
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi force-pushed the private-predicate-check branch 2 times, most recently from 604d160 to 496f1d1 Compare November 17, 2025 23:42
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi force-pushed the private-predicate-check branch from 496f1d1 to 0eeaa96 Compare November 18, 2025 01:53
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi force-pushed the private-predicate-check branch from 0eeaa96 to 59c08d3 Compare November 18, 2025 05:02
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

…n should be private

When compiling a Swift module in incremental mode, each Swift source file is compiled into an object file
and we use linker to link them together. Because the predicate function for checking dynamic feature
availability is eagerly synthesized per compilation unit, the linker will complain about duplicated
symbols for them. Setting their visibility as private ensures that linker doesn't see them, thus addressing
the linker errors.

One workaround for this problem is to enable WMO.

rdar://164971313
@nkcsgexi nkcsgexi force-pushed the private-predicate-check branch from 59c08d3 to d144524 Compare November 18, 2025 17:19
@nkcsgexi nkcsgexi changed the title CustomAvailable: set predicate function to be private CustomAvailability: synthesized dynamic availability checking function should be private Nov 18, 2025
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

funcDecl->setBodySynthesizer(synthesizeAvailabilityDomainPredicateBody,
(void *)var);
funcDecl->setAccess(AccessLevel::Internal);
funcDecl->setAccess(AccessLevel::Private);
Copy link
Member

Choose a reason for hiding this comment

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

Why private rather than marking them as @export(implementation), which allows the linker to merge the different copies in different translation units?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we worry about deserialization issues trigged by the function body of this synthesized function when marked as @export(implementation)? Previously, we have been hitting a module deserialization error (e.g.rdar://164410957).

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test Windows

@nkcsgexi nkcsgexi merged commit 4432378 into swiftlang:main Nov 19, 2025
3 checks passed
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