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

apache-arrow: switch to llvm@17 #169354

Merged
merged 22 commits into from Apr 18, 2024
Merged

apache-arrow: switch to llvm@17 #169354

merged 22 commits into from Apr 18, 2024

Conversation

ZhongRuoyu
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 HOMEBREW_NO_INSTALL_FROM_API=1 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 HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

Cherry-picked from #165206.

@github-actions github-actions bot added the boost Boost use is a significant feature of the PR or issue label Apr 18, 2024
@ZhongRuoyu
Copy link
Member Author

libunwind linkage is everywhere 😢

@chenrui333 chenrui333 added the long build Needs CI-long-timeout label Apr 18, 2024
@ZhongRuoyu ZhongRuoyu added CI-long-timeout Use longer GitHub Actions CI timeout. CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. labels Apr 18, 2024
@github-actions github-actions bot removed the CI-long-timeout Use longer GitHub Actions CI timeout. label Apr 18, 2024
@ZhongRuoyu ZhongRuoyu added the CI-long-timeout Use longer GitHub Actions CI timeout. label Apr 18, 2024
Comment on lines +37 to +42
if DevelopmentTools.clang_build_version >= 1500
recursive_dependencies
.select { |d| d.name.match?(/^llvm(@\d+)?$/) }
.map { |llvm_dep| llvm_dep.to_formula.opt_lib }
.each { |llvm_lib| ENV.remove "HOMEBREW_LIBRARY_PATHS", llvm_lib }
end
Copy link
Member

Choose a reason for hiding this comment

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

Should probably just handle this in brew at this point.

Though, dare I ask -- why don't we want linkage with our libunwind? As long as they're all using the same one it should be ok... (Though admittedly guaranteeing that may be a tall order)

Copy link
Member Author

Choose a reason for hiding this comment

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

Should probably just handle this in brew at this point.

Yea, I agree. Was looking into this too.

Though, dare I ask -- why don't we want linkage with our libunwind? As long as they're all using the same one it should be ok... (Though admittedly guaranteeing that may be a tall order)

Because we cannot be sure the LLVM used to build the formula (or simply present at build time) will continue to stay around until the next rebuild/update -- unless it's a direct runtime dependency.

Some formulae have a build-only dependency on llvm. The linkage test would have failed should there be libunwind linkage. This was the case when this workaround was added to apache-arrow in #146072 though LLVM became a runtime dependency later.

Some others, like the dependents here, depend on llvm indirectly via another runtime dependency (apache-arrow in this case). This makes it unnecessarily challenging for us to switch the dependency formula to a different llvm. Even a "hello world" can link to libunwind unexpectedly.

$ cat test.cc
#include <iostream>

int main() {
  std::cout << "hello, world\n";
}
$ LIBRARY_PATH="$(brew --prefix llvm)/lib" "$(brew --prefix llvm)/bin/clang++" test.cc
ld: warning: reexported library with install name '/usr/local/opt/llvm/lib/libunwind.1.dylib' found at '/usr/local/Cellar/llvm/17.0.6_1/lib/libunwind.1.0.dylib' couldn't be matched with any parent library and will be linked directly
$ otool -L ./a.out
./a.out:
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1700.255.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2)
	/usr/local/opt/llvm/lib/libunwind.1.dylib (compatibility version 1.0.0, current version 1.0.0)

Copy link
Member

@cho-m cho-m Apr 18, 2024

Choose a reason for hiding this comment

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

Should probably just handle this in brew at this point.

Makes sense.

Though, dare I ask -- why don't we want linkage with our libunwind? As long as they're all using the same one it should be ok... (Though admittedly guaranteeing that may be a tall order)

In current state, dependents are mixing libs and can end up crashing, e.g. #161342 (as I recall, there should be a couple other crashes fixed by unlinking llvm's libunwind)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Even a "hello world" can link to libunwind unexpectedly.

$ cat test.cc
#include <iostream>

int main() {
  std::cout << "hello, world\n";
}
$ LIBRARY_PATH="$(brew --prefix llvm)/lib" "$(brew --prefix llvm)/bin/clang++" test.cc
ld: warning: reexported library with install name '/usr/local/opt/llvm/lib/libunwind.1.dylib' found at '/usr/local/Cellar/llvm/17.0.6_1/lib/libunwind.1.0.dylib' couldn't be matched with any parent library and will be linked directly
$ otool -L ./a.out
./a.out:
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1700.255.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2)
	/usr/local/opt/llvm/lib/libunwind.1.dylib (compatibility version 1.0.0, current version 1.0.0)

This is really weird. Smells like a bug in ld to me. Thoughts, @Bo98?

@ZhongRuoyu
Copy link
Member Author

🥲 rtabmap on Linux failed with:

cp: cannot create directory '/home/linuxbrew/.linuxbrew/Cellar/llvm@17/17.0.6/lib': No space left on device

If this is the only failure I think I'd build rtabmap after merging this.

carlocab added a commit to Homebrew/brew that referenced this pull request Apr 18, 2024
This leads to undesired linkage with LLVM's `libunwind` (because it
shadows the system's `libunwind`).

See, for example, Homebrew/homebrew-core#169354.
@github-actions github-actions bot removed the CI-long-timeout Use longer GitHub Actions CI timeout. label Apr 18, 2024
Copy link
Contributor

@github-actions github-actions bot added the CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. label Apr 18, 2024
@BrewTestBot BrewTestBot added this pull request to the merge queue Apr 18, 2024
Merged via the queue into master with commit 780b49e Apr 18, 2024
14 checks passed
@BrewTestBot BrewTestBot deleted the apache-arrow-llvm@17 branch April 18, 2024 16:31
Copy link
Contributor

github-actions bot commented Apr 18, 2024

@ZhongRuoyu bottle request for rtabmap failed.

Same failure. Gonna use the self-hosted runner instead.

ZhongRuoyu added a commit that referenced this pull request Apr 18, 2024
`pdal` opportunistically linked to LLVM's libunwind on Linux, causing a
runtime dependency on it. Instead let's properly link it to `libunwind`.

Discovered in #169354.
@ZhongRuoyu ZhongRuoyu mentioned this pull request Apr 18, 2024
6 tasks
ZhongRuoyu added a commit that referenced this pull request Apr 18, 2024
`pdal` opportunistically linked to LLVM's libunwind on Linux, causing a
runtime dependency on it. Instead let's properly link it to `libunwind`.

Discovered in #169354.
Copy link
Contributor

github-actions bot commented Apr 19, 2024

@ZhongRuoyu bottle request for rtabmap failed.

This request was automatically failed because there were no enabled runners online to process the request for more than 1 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
boost Boost use is a significant feature of the PR or issue CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. long build Needs CI-long-timeout
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants