Skip to content

[5.5] Windows Profiling Improvements #37610

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

Merged
merged 2 commits into from
May 27, 2021

Conversation

compnerd
Copy link
Member

This is a super low risk change for 5.5 to improve the clang (linker) driver invocation and linker options for enabling profiling support on Windows. This only impacts the Windows toolchain, and under -profile-generate only.

compnerd added 2 commits May 24, 2021 08:13
The Windows linker does not support `-u`.  Furthermore, the compiler
driver does not forward the `-u` option to the linker.  We correctly use
the `/include:` option from the linker.  This should ensure that the
symbol is preserved even with `/opt:ref`.  This spelling should be
compatible with both lld and link, which should provide sufficient
portability.

Take the opportunity to make it more obvious that the two parameters are
creating a pair that will be concatenated by using a braced initializer.

See
https://docs.microsoft.com/en-us/cpp/build/reference/include-force-symbol-references?view=msvc-160
for more details on the option.

(cherry picked from commit b3d5181)
Rather than computing an absolute path relative to Swift's resource
directory, use the compiler driver to locate the profiling runtime
relative to the C/C++ compiler's resource directory.  This ensures that
we correctly locate the runtime.  Additionally, because clang adds the
clang resource directory to the library search path, we do not need to
compute the path and can rely on the linker locating the runtime via the
library search path.  This simplifies the handling for the profile
runtime linking on Windows.

Out of abundant paranoia, place the library link request after the
forced symbol inclusion as a GC root to ensure that `/opt:ref` will not
accidentally dead strip the symbol and force a reload of the library.

(cherry picked from commit fc3ccdc)
@compnerd
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 99db287

@compnerd
Copy link
Member Author

@swift-ci please test macOS platform

@compnerd compnerd requested review from beccadax and artemcm May 24, 2021 22:24
@compnerd compnerd added the r5.5 label May 25, 2021
@compnerd compnerd changed the title Windows Profiling Improvements [5.5] Windows Profiling Improvements May 25, 2021
@compnerd compnerd requested review from artemcm and removed request for beccadax May 26, 2021 16:06
Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

LGTM

@artemcm artemcm requested a review from a team May 26, 2021 16:08
@tkremenek tkremenek merged commit 07c1374 into swiftlang:release/5.5 May 27, 2021
@compnerd compnerd deleted the 5.5-profiling branch May 27, 2021 15:26
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.5 labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants