Skip to content
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

llvm: convert bitcode in static archives to object code #112154

Closed
wants to merge 1 commit into from

Conversation

carlocab
Copy link
Member

@carlocab carlocab commented Oct 2, 2022

In #106925, I enabled LTO for our LLVM build. This creates static
archives that contain LLVM bitcode instead of object code. This makes
the static archives more difficult to use, requiring workarounds such as

args << "-DCMAKE_EXE_LINKER_FLAGS=-Wl,-lto_library,#{llvm.opt_lib/shared_library("libLTO")}" if OS.mac?

and has caused problems for multiple downstream projects.

We can fix this by converting the bitcode into object code, which is
what Fedora does with their LLVM build. They also build their toolchain
with LTO.

Alternatively, we can disable LTO, but that foregoes significant
speedups we get from enabling it.

While we're here, let's add some test coverage for features that were
recently enabled that we don't test.

Fixes:

ziglang/zig#12923
halide/Halide#7055
mesonbuild/meson#10879
Homebrew/discussions#3666


  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

@carlocab carlocab added CI-linux-self-hosted Build on Linux self-hosted runner CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. CI-skip-dependents Pass --skip-dependents to brew test-bot. long build Set a long timeout for formula testing labels Oct 2, 2022
@BrewTestBot BrewTestBot added the python Python use is a significant feature of the PR or issue label Oct 2, 2022
@carlocab
Copy link
Member Author

carlocab commented Oct 2, 2022

This changes only the content of the static libraries. Any dependents would need to be rebuilt for those changes to affect them, so I'm skipping dependent testing here.

In Homebrew#106925, I enabled LTO for our LLVM build. This creates static
archives that contain LLVM bitcode instead of object code. This makes
the static archives more difficult to use, requiring workarounds such as

    https://github.com/Homebrew/homebrew-core/blob/c01f1794fc3decce04b71cae03966213fc7af34d/Formula/enzyme.rb#L30

and has caused problems for multiple downstream projects.

We can fix this by converting the bitcode into object code, which is
what Fedora does with their LLVM build. They also build their toolchain
with LTO.

Alternatively, we can disable LTO, but that foregoes significant
speedups we get from enabling it.

While we're here, let's add some test coverage for features that were
recently enabled that we don't test.

Fixes:

ziglang/zig#12923
halide/Halide#7055
mesonbuild/meson#10879
Homebrew/discussions#3666
@carlocab carlocab force-pushed the llvm-static-archives branch from d21daff to 6e8c5f7 Compare October 2, 2022 16:28
@@ -432,6 +432,24 @@ def install

# Install Emacs modes
elisp.install llvmpath.glob("utils/emacs/*.el") + share.glob("clang/*.el")

return if OS.linux? || !pgo_build
Copy link
Member

Choose a reason for hiding this comment

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

Probably nice to have a lto_enabled variable that could be used throughout in case this ever changes. Can be a separate style PR however.

@Bo98
Copy link
Member

Bo98 commented Oct 2, 2022

LGTM.

I was thinking maybe revision bump but 15.0.2 is probably out next week anyway.

@carlocab carlocab mentioned this pull request Oct 3, 2022
2 tasks
@carlocab carlocab linked an issue Oct 3, 2022 that may be closed by this pull request
2 tasks
@carlocab carlocab removed the CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. label Oct 3, 2022
@BrewTestBot
Copy link
Member

🤖 A scheduled task has triggered a merge.

carlocab added a commit to carlocab/meson that referenced this pull request Oct 3, 2022
carlocab added a commit to carlocab/homebrew-core that referenced this pull request Oct 3, 2022
This was fixed in Homebrew#112154.
@carlocab carlocab mentioned this pull request Oct 3, 2022
carlocab added a commit that referenced this pull request Oct 3, 2022
This was fixed in #112154.
carlocab added a commit to carlocab/Enzyme that referenced this pull request Oct 5, 2022
wsmoses pushed a commit to EnzymeAD/Enzyme that referenced this pull request Oct 6, 2022
BrewTestBot pushed a commit that referenced this pull request Oct 6, 2022
* llvm 15.0.2
* llvm: improve `install` method
  - define an `lto_build` variable per feedback from #112154
  - move the runtimes build from `stage2-profdata` to `stage2`. Building
  the runtimes is not useful with the `stage2-profdata` compiler, but
  doing it in `stage2` means that the runtimes will be built with our
  instrumented compiler.
carlocab added a commit to carlocab/homebrew-core that referenced this pull request Oct 6, 2022
BrewTestBot pushed a commit that referenced this pull request Oct 6, 2022
This was fixed in #112154.

Closes #112461.

Signed-off-by: Daniel Nachun <9205048+danielnachun@users.noreply.github.com>
Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>
banach-space added a commit to banach-space/llvm-tutor that referenced this pull request Oct 8, 2022
This patch remove a Homebrew specific workaround that's not needed
after: Homebrew/homebrew-core#112154
banach-space added a commit to banach-space/llvm-tutor that referenced this pull request Oct 8, 2022
This patch remove a Homebrew specific workaround that's not needed
after: Homebrew/homebrew-core#112154
banach-space added a commit to banach-space/clang-tutor that referenced this pull request Oct 8, 2022
This patch remove a Homebrew specific workaround that's not needed
after: Homebrew/homebrew-core#112154
@carlocab carlocab mentioned this pull request Oct 13, 2022
6 tasks
carlocab added a commit to carlocab/homebrew-core that referenced this pull request Oct 13, 2022
Fixes Homebrew/discussions#3734.

This is essentially the same issue as Homebrew#112154, except that I'm not aware
of a way to convert the bitcode for GCC. It's possible that there is no
way to do this, given that GCC seems to consider its IR as an internal
implementation detail.
BrewTestBot pushed a commit that referenced this pull request Oct 13, 2022
Fixes Homebrew/discussions#3734.

This is essentially the same issue as #112154, except that I'm not aware
of a way to convert the bitcode for GCC. It's possible that there is no
way to do this, given that GCC seems to consider its IR as an internal
implementation detail.

Closes #113036.

Signed-off-by: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com>
Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>
@carlocab carlocab deleted the llvm-static-archives branch October 15, 2022 04:07
carlocab added a commit to carlocab/meson that referenced this pull request Oct 24, 2022
eli-schwartz pushed a commit to mesonbuild/meson that referenced this pull request Oct 25, 2022
@github-actions github-actions bot added the outdated PR was locked due to age label Nov 15, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI-linux-self-hosted Build on Linux self-hosted runner CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. CI-skip-dependents Pass --skip-dependents to brew test-bot. long build Set a long timeout for formula testing outdated PR was locked due to age python Python use is a significant feature of the PR or issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LLVM 15 library is broken
4 participants