This is an archive of the discontinued LLVM Phabricator instance.

[BOLT][CMake] Redo the build and install targets
ClosedPublic

Authored by phosek on May 26 2023, 3:14 PM.

Details

Summary

The existing BOLT install targets are broken on Windows because they
don't properly handle the output extension. We cannot use the existing
LLVM macros since those make assumptions that don't hold for BOLT. This
change instead implements custom macros following the approach used by
Clang and LLD.

Diff Detail

Event Timeline

phosek created this revision.May 26 2023, 3:14 PM
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
phosek requested review of this revision.May 26 2023, 3:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2023, 3:14 PM
phosek edited the summary of this revision. (Show Details)May 26 2023, 3:14 PM

Ping, our toolchain build on Windows is currently broken because of BOLT and I verified that this change resolves the issue so I'd appreciate a review.

smeenai accepted this revision.May 30 2023, 12:15 PM

LGTM. Sorry for the delay, I was out for Memorial Day weekend.

This revision is now accepted and ready to land.May 30 2023, 12:15 PM
This revision was landed with ongoing or failed builds.May 30 2023, 12:23 PM
This revision was automatically updated to reflect the committed changes.
phosek updated this revision to Diff 526809.May 30 2023, 3:18 PM
phosek retitled this revision from [BOLT][CMake] Use LLVM macros for install targets to [BOLT][CMake] Avoid duplicating standard install targets.
phosek edited the summary of this revision. (Show Details)

I had to redo the patch after investigating the builder failure and better understanding the intention of the original code.

phosek reopened this revision.May 30 2023, 3:43 PM

There's still an issue where only bolt is included in LLVM_DISTRIBUTION_COMPONENTS and not individual tools such as llvm-bolt because then the install targets won't be created because of https://github.com/llvm/llvm-project/blob/c7eb1b07470b9babfcd258f014df3661e5f84b30/llvm/cmake/modules/AddLLVM.cmake#L1348. Unfortunately this scenario where the name of the component is different from the tool itself is currently supported in the LLVM build.

This revision is now accepted and ready to land.May 30 2023, 3:43 PM

@smeenai Do you have any thoughts on this? I don't actually know how to fix this. The intention seems to be allow the use of the bolt target/component as a grouping for other BOLT targets such as llvm-bolt or bolt_rt, so you can only include bolt in LLVM_DISTRIBUTION_COMPONENT. I understand why that may be desirable, but that breaks many of the assumptions that existing macros make and I don't know how to easily fix it.

Hmm, could we extend the existing umbrella target support for things like llvm-libraries and clang-libraries to cover the BOLT case as well?

bolt/tools/driver/CMakeLists.txt
38

I assume this should be add_dependencies?

41

This should depend on the stripped target?

phosek updated this revision to Diff 526931.May 31 2023, 12:14 AM
phosek marked 2 inline comments as done.
phosek retitled this revision from [BOLT][CMake] Avoid duplicating standard install targets to [BOLT][CMake] Redo the build and install targets.
phosek edited the summary of this revision. (Show Details)

Hmm, could we extend the existing umbrella target support for things like llvm-libraries and clang-libraries to cover the BOLT case as well?

I have opted for an approach that's similar to the one used by Clang and LLD, although the handling of components is different to preserve the existing behavior. This seems to be working in my local testing.

phosek updated this revision to Diff 526948.May 31 2023, 1:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 31 2023, 1:05 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Makes sense, though @Amir should also take a look.

bolt/CMakeLists.txt
122

Where is BOLT_DEPENDS being set now?

The CMake docs say DEPENDS should only be used for add_custom_command outputs in the same folder, and add_dependencies for everything else, so we want the latter here. I know this is just moving existing code, but we may as well fix that while we're here. I don't think it makes any difference for Ninja, but it might for other generators?

bolt/tools/heatmap/CMakeLists.txt
8

Why this change?

phosek updated this revision to Diff 527084.May 31 2023, 9:26 AM
phosek marked an inline comment as done.

@Amir does this change look good to you?

bolt/tools/heatmap/CMakeLists.txt
8

This tool wasn't previously included in the bolt umbrella target so I assume that it doesn't need an install target, but I'd be helpful for @Amir to confirm.

Amir added a comment.May 31 2023, 2:40 PM

@Amir does this change look good to you?

Looks good overall. Thanks for adding AddBolt cmake module. Testing the build internally, will reply shortly.

Amir added inline comments.May 31 2023, 4:19 PM
bolt/test/CMakeLists.txt
40

We have a number of dependencies on llvm-boltdiff and perf2bolt, e.g. in internal and upstream binary tests: https://github.com/rafaelauler/bolt-tests/blob/main/CMakeLists.txt#L22. Can we keep these targets somehow?

bolt/tools/heatmap/CMakeLists.txt
8

It wasn't included by omission. Let's include it into the umbrella target.

phosek updated this revision to Diff 527243.May 31 2023, 5:10 PM
phosek marked 2 inline comments as done.
phosek added inline comments.
bolt/test/CMakeLists.txt
40

These symlinks are now always generated, see the ALWAYS_GENERATED option in add_bolt_tool_symlink so there's no need to specify those as targets here separately.

Amir accepted this revision.May 31 2023, 6:53 PM

Thanks. Will update the dependencies, removing always-installed symlinks.

This revision was landed with ongoing or failed builds.May 31 2023, 11:02 PM
This revision was automatically updated to reflect the committed changes.
phosek reopened this revision.Jun 1 2023, 1:05 AM
This revision is now accepted and ready to land.Jun 1 2023, 1:05 AM
Amir added a comment.Jun 1 2023, 6:33 AM

Merged the PR. Please reland

This revision was automatically updated to reflect the committed changes.