-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Prefer add_swift_tool_symlink to install symlink for swift-frontend
#61668
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
Prefer add_swift_tool_symlink to install symlink for swift-frontend
#61668
Conversation
|
@swift-ci please smoke test |
|
I think that more than just the smoke test, we should be building full toolchains for this. I'm concerned that this might impact the file system layout and thus packaging (at least for Windows). |
|
@swift-ci please build toolchain |
and match the usage pattern employed by other LLVM projects. For context about the underlying change see https://reviews.llvm.org/D117977 Addresses rdar://101396797
c268511 to
79b5a1d
Compare
llvm_install_symlinkllvm_install_symlink
llvm_install_symlinkllvm_install_symlink...
|
@swift-ci please smoke test |
|
@swift-ci please build toolchain |
compnerd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This seems pretty close. I am curious about a possible drift between the actual binaries being installed and the symlinks though.
CMakeLists.txt
Outdated
| add_definitions("-fprofile-instr-use=${SWIFT_PROFDATA_FILE}") | ||
| endif() | ||
|
|
||
| set(SWIFT_TOOLS_INSTALL_DIR "bin" CACHE PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we ensure that this matches the install bin dir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to search for such a parameter I could reuse, but I was not able to find it -- it seems we hardcode bin and/or we rely on preexisting defaults (like it was the case for llvm_install_symlink pre LLVM 15)
Updating all the places to use a proper parameter would require more work and qualification outside of the scope of unblocking next -- so in this context I leaned toward adding the variable to the main CMakeLists.txt to "highlight" this concern in future reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a bit more investigation, wondering if I should instead solve this issue inside of tools/driver/CMakeLists.txt -- in particular noticing that in there add_swift_tool_symlink and swift_install_in_component are laying down the same symlinks during installation (albeit with different means), so there could be a chance to simplify this part instead of adding to it
#6053 seems to suggest that may have been the original intent for adding add_swift_tool_symlink in the first place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposing one such approach in f94b96e -- preferring add_swift_tool_symlink to create the symlink during installation, and augmenting it with a destination argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on how we want to do it, we can base this on ${LLVM_TOOLS_INSTALL_DIR} or ${CMAKE_INSTALL_BINDIR}.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I see -- I thought the question was about the risk of installing the symlinks in a different directory than the target program, but instead it seems we were more concerned on using a sane default value for the setting.
I reverted to the previous approach and used ${CMAKE_INSTALL_BINDIR} as the default value in e7c4b19
Also ensure we don't symlink to swift-frontend twice
|
@swift-ci please build toolchain |
|
@swift-ci please smoke-test |
llvm_install_symlink...add_swift_tool_symlink to install symlink for swift-frontend
cmake/modules/AddSwift.cmake
Outdated
| set(SWIFT_TOOLS_INSTALL_DIR destination) | ||
| llvm_add_tool_symlink(SWIFT ${name} ${dest} ALWAYS_GENERATE) | ||
| llvm_install_symlink(SWIFT ${name} ${dest} ALWAYS_GENERATE COMPONENT ${component}) | ||
| unset(SWIFT_TOOLS_INSTALL_DIR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating an LLVM component called "compiler", can you instead use the default behavior of LLVM (which should create install-${name} as an install command) and instead use something like the following to register that llvm component (swift-frontend) with the swift component (compiler).
function (add_dependency_from_llvm_component_to_swift_component swift-target-name swift-component)
add_dependencies(install-${swift-target-name} install-${swift-component})
endfunction()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my experiments, it seems I cannot drop the COMPONENT argument -- if I do, the cmake_install.cmake script will not install the symlink when specifying our Swift components (e.g. -DCMAKE_INSTALL_COMPONENT=compiler), but when specifying the name of the target program (if ALWAYS_GENERATE is provided) or the source one (otherwise), which is not something that we currently allow in the Swift build system.
As discussed offline, I've attempted to lean a bit more on the LLVM functions around components by (a) dropping ALWAYS_GENERATE and (b) configuring an LLVM component for swift-frontend to avoid failures -- you can find this in 87f8906 (although I have mixed feelings about it)
Use CMAKE_INSTALL_BINDIR as initial value for SWIFT_TOOLS_INSTALL_DIR
|
@swift-ci please build toolchain |
|
I've noticed that this PR is now addressing two different concerns:
Those have different implications and urgency, so I thought to split this PR in two:
|
Also adapt to new signature for
llvm_install_symlinkand match the usage pattern employed by other LLVM projects.Addresses rdar://101396797