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@11: upstream Linux fixes #79466

Merged
merged 1 commit into from Jun 23, 2021
Merged

Conversation

danielnachun
Copy link
Member

  • 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>?

@danielnachun danielnachun added the linux to homebrew-core Migration of linuxbrew-core to homebrew-core label Jun 17, 2021
@BrewTestBot BrewTestBot added legacy Relates to a versioned @ formula python Python use is a significant feature of the PR or issue labels Jun 17, 2021
Comment on lines 193 to 196
on_linux do
# Strip executables/libraries/object files to reduce their size
system("strip", "--strip-unneeded", "--preserve-dates", *(Dir[bin/"**/*", lib/"**/*"]).select do |f|
f = Pathname.new(f)
f.file? && (f.elf? || f.extname == ".a")
end)
end
Copy link
Member

Choose a reason for hiding this comment

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

Their build scripts generate an install/strip target. Wouldn't it be better to call that target instead on Linux? Or maybe calling it on both, though I'd want to know what this changes on macOS.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this might be carried over from the older versions where we weren't using the monorepo to build. I'll try to test this locally and see if it attains the same result on Linux. On macOS I can call it as well, and if it passes all the tests fine then maybe it's okay to use on both?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. We can also compare the existing bottle to the newly built one to see if something looks off.

Copy link
Member Author

Choose a reason for hiding this comment

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

I built LLVM 12 locally with install/strip as the target and the bottle size only differs by 7 MB between the version built with install/strip and the original one we manually stripped. I also check some of the binaries produced by install/strip and file reports them all to be stripped.

Is there anything else we should be checking for comparison? I'm happy to build LLVM 11 and 12 bottles in the linuxbrew/core CI so that the artifacts can be downloaded to be compared if that would be useful.

@danielnachun danielnachun force-pushed the llvm@11 branch 2 times, most recently from 1d44fad to 60e8bc4 Compare June 21, 2021 01:10
@@ -132,6 +133,9 @@ def install
-DLLDB_PYTHON_RELATIVE_PATH=libexec/#{site_packages}
-DLIBOMP_INSTALL_ALIASES=OFF
-DCLANG_PYTHON_BINDINGS_VERSIONS=#{py_ver}
-DPACKAGE_VENDOR=#{tap.user}
-DPACKAGE_BUGREPORT=#{tap.issues_url}
-DCLANG_VENDOR_UTI=org.#
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
-DCLANG_VENDOR_UTI=org.#
-DCLANG_VENDOR_UTI=org.#{tap.user.downcase}.clang

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, had a copy/paste issue with my editor for that one.

@@ -146,6 +150,7 @@ def install
args << "-DLLVM_BUILD_LLVM_C_DYLIB=ON"
args << "-DLLVM_ENABLE_LIBCXX=ON"
args << "-DLLVM_CREATE_XCODE_TOOLCHAIN=#{MacOS::Xcode.installed? ? "ON" : "OFF"}"
args << "-DRUNTIMES_CMAKE_ARGS=-DCMAKE_INSTALL_RPATH=#{rpath}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
args << "-DRUNTIMES_CMAKE_ARGS=-DCMAKE_INSTALL_RPATH=#{rpath}"

This isn't needed. The change in LC_RPATH entries for runtimes changed (i.e. regressed) in LLVM 12.

@danielnachun
Copy link
Member Author

I don't understand this test failure. The most recent changes I pushed should not have affected it at all. Is this just another "temperamental" build issue?

@carlocab
Copy link
Member

carlocab commented Jun 21, 2021

No, this is a test failure. LLVM 11 builds pretty reliably in my experience. Might be due to the newer SDK.

@carlocab
Copy link
Member

The test appears to be failing here:

assert_equal "Hello World!", shell_output("./testlibc++").chomp

which is weird, because the SDK shouldn't have any effect on this.

refute_match(/libstdc\+\+/, lib)
refute_match(/libgcc/, lib)
refute_match(/libatomic/, lib)
end
assert_equal "Hello World!", shell_output("./testlibc++").chomp
Copy link
Member

Choose a reason for hiding this comment

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

This is where the test is failing. I think the new flags you added to the compilation of testlibc++ aren't as innocuous as we thought.

Copy link
Member

Choose a reason for hiding this comment

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

I have had trouble with Compiler-RT on ARM in a separate PR, so it's possible it just doesn't work properly, and adding -rtlib=compiler-rt has exposed that problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a little confused though, because I had a previous that was successful with that flag: https://github.com/Homebrew/homebrew-core/actions/runs/948629092. The one thing I did change was that I used the install/strip target. If that ends up creating a problem on ARM for compiler-rt, then that could indicate that install/strip breaks compiler-rt on ARM.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, going back to install from install/strip has fixed the test on ARM. I am thinking we should not use install/strip on ARM for LLVM 11, as compiler-rt may not be the only thing it breaks. I think LLVM 11 was the first version to support Apple Silicon, so perhaps the symbol stripping for that architecture had some problems which were resolved in LLVM 12?

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm. Very weird. I suspect we'll want to avoid install/strip on LLVM 12 too. We can just go back to the on_linux block you wanted to do originally.

Copy link
Member

Choose a reason for hiding this comment

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

Probs not worth it, given that we don't have a clear idea of what it does and doesn't break. Especially given how we use LLVM_ENABLE_RUNTIMES, which means we have a bunch of things that aren't built with our shims and hence may contain things like debug symbols, etc.

Copy link
Member

Choose a reason for hiding this comment

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

I think that back then the difference between stripped and unstripped was bigger. And that I was manually building llvm and manually uploading it with a slow connection, like 10 to 20 times a year. One upload took between 1 and 2 hours, so every megabyte I could squeeze out of that build was worth it.

I am fine to remove the stripping.

Copy link
Member

Choose a reason for hiding this comment

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

It might be that those were Debug builds (cf. Homebrew/brew#11455), which is why stripping made a big difference.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah if were unintentionally making them debug builds, removing the debugging symbols would make a much bigger difference than removing unused symbols. If we're not doing that anymore, that could probably explain why the effect is so small.

@carlocab with this resolved, I think we are ready to merge and nothing should need to be rebottled on macOS. I'll have to open a new PR to disable stripping in LLVM 12, and I won't add it for the older LLVM versions either.

@iMichka I think LLVM 11 and 12 should be revision bumped to disable stripping. Can that be handled in the merge? Or do we need to open new PRs for that? I'll change the PRs I opened for LLVM 7, 8, and 9 to disable stripping on those versions as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see @carlocab already took of LLVM 12, so that I've crossed that out.

carlocab added a commit to carlocab/homebrew-core that referenced this pull request Jun 22, 2021
Using the `install/strip` target seems to have broken LLVM 11 on Apple
Silicon (cf. Homebrew#79466). Stripping results in just a modest decrease in
bottle size, so it seems better to play it safe here and stick with the
`install` target.
carlocab added a commit that referenced this pull request Jun 22, 2021
Using the `install/strip` target seems to have broken LLVM 11 on Apple
Silicon (cf. #79466). Stripping results in just a modest decrease in
bottle size, so it seems better to play it safe here and stick with the
`install` target.
@danielnachun danielnachun merged commit 72aac74 into Homebrew:master Jun 23, 2021
@github-actions github-actions bot added the outdated PR was locked due to age label Jul 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2021
@danielnachun danielnachun deleted the llvm@11 branch August 6, 2021 02:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
legacy Relates to a versioned @ formula linux to homebrew-core Migration of linuxbrew-core to homebrew-core 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.

None yet

4 participants