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
Conversation
Formula/llvm@11.rb
Outdated
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 |
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.
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.
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 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?
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.
Sounds good. We can also compare the existing bottle to the newly built one to see if something looks off.
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 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.
1d44fad
to
60e8bc4
Compare
Formula/llvm@11.rb
Outdated
@@ -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.# |
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.
-DCLANG_VENDOR_UTI=org.# | |
-DCLANG_VENDOR_UTI=org.#{tap.user.downcase}.clang |
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.
Whoops, had a copy/paste issue with my editor for that one.
Formula/llvm@11.rb
Outdated
@@ -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}" |
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.
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.
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? |
No, this is a test failure. LLVM 11 builds pretty reliably in my experience. Might be due to the newer SDK. |
The test appears to be failing here: homebrew-core/Formula/llvm@11.rb Line 289 in 58d4fbf
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 |
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.
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.
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 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.
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'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.
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.
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?
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.
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.
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.
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.
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 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.
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.
It might be that those were Debug
builds (cf. Homebrew/brew#11455), which is why stripping made a big difference.
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.
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.
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 see @carlocab already took of LLVM 12, so that I've crossed that out.
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.
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.
brew install --build-from-source <formula>
, where<formula>
is the name of the formula you're submitting?brew test <formula>
, where<formula>
is the name of the formula you're submitting?brew audit --strict <formula>
(after doingbrew install --build-from-source <formula>
)? If this is a new formula, does it passbrew audit --new <formula>
?