Skip to content

Conversation

@edymtt
Copy link
Contributor

@edymtt edymtt commented Oct 21, 2022

Also adapt to new signature for llvm_install_symlink and match the usage pattern employed by other LLVM projects.

Addresses rdar://101396797

@edymtt
Copy link
Contributor Author

edymtt commented Oct 21, 2022

@swift-ci please smoke test

@compnerd
Copy link
Member

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).

@edymtt
Copy link
Contributor Author

edymtt commented Oct 21, 2022

@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
@edymtt edymtt force-pushed the next-adapt-to-new-llvm_install_symlink-signature branch from c268511 to 79b5a1d Compare October 24, 2022 16:30
@edymtt edymtt changed the title [next] adapt to new signature for llvm_install_symlink Adapt to new signature for llvm_install_symlink Oct 24, 2022
@edymtt edymtt changed the title Adapt to new signature for llvm_install_symlink Adapt to new signature for llvm_install_symlink... Oct 24, 2022
@edymtt
Copy link
Contributor Author

edymtt commented Oct 24, 2022

@swift-ci please smoke test

@edymtt
Copy link
Contributor Author

edymtt commented Oct 24, 2022

@swift-ci please build toolchain

@edymtt edymtt requested a review from compnerd October 24, 2022 16:35
Copy link
Member

@compnerd compnerd left a 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
Copy link
Member

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?

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 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.

Copy link
Contributor Author

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

https://github.com/apple/swift/blob/dc8d37d6b5adeb2371755844445ef5b3021c789a/tools/driver/CMakeLists.txt#L114

https://github.com/apple/swift/blob/dc8d37d6b5adeb2371755844445ef5b3021c789a/tools/driver/CMakeLists.txt#L123-L125

#6053 seems to suggest that may have been the original intent for adding add_swift_tool_symlink in the first place

Copy link
Contributor Author

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

Copy link
Member

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}.

Copy link
Contributor Author

@edymtt edymtt Oct 26, 2022

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
@edymtt
Copy link
Contributor Author

edymtt commented Oct 25, 2022

@swift-ci please build toolchain

@edymtt
Copy link
Contributor Author

edymtt commented Oct 25, 2022

@swift-ci please smoke-test

@edymtt edymtt changed the title Adapt to new signature for llvm_install_symlink... Prefer add_swift_tool_symlink to install symlink for swift-frontend Oct 25, 2022
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)
Copy link
Contributor

@gottesmm gottesmm Oct 25, 2022

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()

Copy link
Contributor Author

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)

@edymtt
Copy link
Contributor Author

edymtt commented Oct 26, 2022

@swift-ci please build toolchain

@edymtt
Copy link
Contributor Author

edymtt commented Oct 27, 2022

I've noticed that this PR is now addressing two different concerns:

  • adapting to the new signature of add_swift_tool_symlink
  • avoid creating symlinks for swift-frontend twice, and possibly take the chance to lean a bit more into the LLVM component model

Those have different implications and urgency, so I thought to split this PR in two:

@edymtt edymtt closed this Oct 31, 2022
@edymtt edymtt deleted the next-adapt-to-new-llvm_install_symlink-signature branch October 31, 2022 14:16
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.

4 participants