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 lld flang 19.1.1 #192505

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

llvm lld flang 19.1.1 #192505

wants to merge 3 commits into from

Conversation

carlocab
Copy link
Member

@carlocab carlocab commented Oct 1, 2024

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

  • llvm 19.1.1
  • lld 19.1.1
  • flang 19.1.1

@carlocab carlocab added long build Set a long timeout for formula testing CI-no-fail-fast-deps Continue dependent tests despite failing GitHub Actions matrix tests. labels Oct 1, 2024
@cho-m
Copy link
Member

cho-m commented Oct 1, 2024

Based on https://github.com/orgs/Homebrew/discussions/5631, we probably should disable EH since we now ship Flang.

-DLLVM_ENABLE_EH=ON

This is how other repositories that ship flang build llvm. We are doing a bit of a hack by setting -D LLVM_ENABLE_EH=OFF which gets overridden when running find_package(LLVM ...) which allows us to bypass the error while still linking with exception symbols.

Other References:

  1. https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/flang/CMakeLists.txt#L17-L23
  2. flang build not enforcing style guidelines llvm/llvm-project#59353
  3. https://discourse.llvm.org/t/compiling-with-flang-new/66808
  4. https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/llvm/package.py#L846-L854

EDIT: If we want to keep it on, may need to add at minimum some caveats or perhaps some workarounds as our build is non-standard.

@carlocab
Copy link
Member Author

carlocab commented Oct 2, 2024

I'd just follow what Fedora are doing. LLVM's lead maintainer and one (out of two) of the LLVM release managers maintain the Fedora packages.

But if we want to turn off EH and/or RTTI (though IIRC RTTI requires EH -- but maybe it was the other way around), I would suggest saving it for LLVM 20 because changing those settings will require recompiling everything that links to libLLVM.

@cho-m
Copy link
Member

cho-m commented Oct 2, 2024

Actually my comment was wrong and Fedora does disable. I confirmed by downloading RPM12 and checking LLVMConfig.cmake

set(LLVM_ENABLE_ASSERTIONS OFF)

set(LLVM_ENABLE_EH OFF)

set(LLVM_ENABLE_FFI TRUE)
if(LLVM_ENABLE_FFI)
  find_package(FFI)
endif()

set(LLVM_ENABLE_RTTI ON)

Footnotes

  1. https://koji.fedoraproject.org/koji/buildinfo?buildID=2549315

  2. https://kojipkgs.fedoraproject.org//packages/llvm/19.1.0/1.fc42/aarch64/llvm-devel-19.1.0-1.fc42.aarch64.rpm

@carlocab
Copy link
Member Author

carlocab commented Oct 2, 2024

@cho-m
Copy link
Member

cho-m commented Oct 2, 2024

That's weird, since their spec files show LLVM_ENABLE_EH=ON:

Looks like it may be arch-specific. x86_64 rpm does have it enabled:

set(LLVM_ENABLE_ASSERTIONS OFF)

set(LLVM_ENABLE_EH ON)

set(LLVM_ENABLE_FFI TRUE)
if(LLVM_ENABLE_FFI)
  find_package(FFI)
endif()

set(LLVM_ENABLE_RTTI ON)

Anyway, I think the upstream CMake check (llvm/llvm-project@f7e58c9) wasn't tested on Standalone mode which is why it currently works.

There should probably be a caveat as CMake LLVMFlang can't handle our flang which is usually a bad sign.

@carlocab
Copy link
Member Author

carlocab commented Oct 2, 2024

We could just create a wrapper script that always adds -l[std]c++ 🤷 Or perhaps a config file next to it (when installed in libexec) that isn't linked to bin.

Setting LLVM_ENABLE_EH could be a big change. Probably worth opening an issue/discussion for feedback, plus a note in caveats linking to the issue/discussion. Then if no one complains we can set it to OFF for LLVM 20.

CC @Bo98 for thoughts.

@Bo98
Copy link
Member

Bo98 commented Oct 2, 2024

Setting LLVM_ENABLE_EH could be a big change.

It can affect ABI at least. Though I also agree we should try disable it & RTTI.

LLVM 20 is definitely a good time to make changes. Somewhat relatedly: perhaps worth considering if libcxx probably should be split to a separate formula. We've had regular bug reports about it since the LLVM C++ headers got prioritised again.

@carlocab
Copy link
Member Author

carlocab commented Oct 2, 2024

Or perhaps a config file next to it (when installed in libexec) that isn't linked to bin.

Testing creating a libexec/"bin/flang.cfg" that contains only -lc++. Seems to work. Will add it in a follow-up, plus some caveats. #192611

carlocab added a commit that referenced this pull request Oct 2, 2024
This addresses issues users have had at Homebrew/discussions#5631.

See also discussion at #192505.

We could probably rebuild LLVM with `LLVM_ENABLE_EH=OFF`, but that
breaks the ABI so we should save it for LLVM 20 at the earliest.
@carlocab carlocab added the CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. label Oct 2, 2024
Also:
- remove the `zstd` and `zlib` dependencies since there's no actual
  linkage
- reduce the scope of the `llvm` method to a variable in `install`
carlocab added a commit that referenced this pull request Oct 2, 2024
This addresses issues users have had at Homebrew/discussions#5631.

See also discussion at #192505.

We could probably rebuild LLVM with `LLVM_ENABLE_EH=OFF`, but that
breaks the ABI so we should save it for LLVM 20 at the earliest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. CI-no-fail-fast-deps Continue dependent tests despite failing GitHub Actions matrix tests. long build Set a long timeout for formula testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants