Skip to content

[clang] Unconditionally add autolink hints for frameworks. #6502

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

Closed
wants to merge 1 commit into from

Conversation

ributzka
Copy link

Clang infers framework autolink hints when parsing a modulemap. In order to do so, it checks if the module is a framework and if there is a framework binary or TBD file in the SDK. Only when Clang finds the filei, then the autolink hint is added to the module metadata.

During a project build many clang processes perform this check, which causes many stat calls - even for modules/frameworks that are not even used.

The linker is already resilient to non-existing framework links that come from the autolink metadata, so there is no need for Clang to do this check.

Instead the autolink hints are now added unconditionally and the linker only needs to do the check once. This reduces the overall number of stat calls.

This fixes rdar://106578342.

Differential Revision: https://reviews.llvm.org/D146255

(cherry picked from commit 29e2a4e)

Clang infers framework autolink hints when parsing a modulemap. In order to do
so, it checks if the module is a framework and if there is a framework binary
or TBD file in the SDK. Only when Clang finds the filei, then the autolink hint
is added to the module metadata.

During a project build many clang processes perform this check, which causes
many stat calls - even for modules/frameworks that are not even used.

The linker is already resilient to non-existing framework links that come from
the autolink metadata, so there is no need for Clang to do this check.

Instead the autolink hints are now added unconditionally and the linker only
needs to do the check once. This reduces the overall number of stat calls.

This fixes rdar://106578342.

Differential Revision: https://reviews.llvm.org/D146255

(cherry picked from commit 29e2a4e)
@ributzka
Copy link
Author

@swift-ci please test

1 similar comment
@artemcm
Copy link

artemcm commented Mar 21, 2023

@swift-ci please test

@ributzka ributzka changed the base branch from stable/20221013 to swift/release/5.9 April 10, 2023 18:48
@ributzka
Copy link
Author

@swift-ci please test

@ributzka
Copy link
Author

Please test with following pull request:
swiftlang/swift#65051

@swift-ci please test

@ributzka
Copy link
Author

Please test with following pull request:
swiftlang/swift#65051

@swift-ci please test

@ributzka
Copy link
Author

The Swift change has been merged. Trying another test build with that Swift fix.

@ributzka
Copy link
Author

@swift-ci please test

@ributzka
Copy link
Author

Hi @compnerd, could you please help me with the Windows test issue?

@compnerd
Copy link
Member

From the build log:

AffineTransform.swift.obj : fatal error LNK1276: invalid directive 'CoreFoundation' found; does not start with '/'

This seems like you are forming the autolink directives incorrectly.

@compnerd
Copy link
Member

Oh, you are likely embedding a -framework Foundation link directive on Linux and Windows which won't work as the linkers do not support that flag.

@ributzka
Copy link
Author

ributzka commented Apr 17, 2023

Yup, that is what clang has done since day one with respect to autolink hints. I updated swift-autolink-extract to not pass on unsupported directives (-framework) and that fixed Linux. Windows for some reason is a different story and I don't have a setup to investigate it.

@compnerd
Copy link
Member

compnerd commented Apr 17, 2023

There is no special way around that unfortunately. Windows directly passes the arguments to the linker through the linker, you cannot change that behaviour as we cannot modify the linker from Microsoft. Perhaps we should instead of have a predicate to check if the linker supports -framework?

@ributzka
Copy link
Author

@swift-ci please test windows

@ributzka ributzka closed this Sep 1, 2023
@shahmishal shahmishal deleted the eng/PR-106578342 branch September 1, 2023 21:52
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