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

Failure using homebrew-provided llvm #207161

Closed
4 tasks done
WardF opened this issue Feb 10, 2025 · 5 comments
Closed
4 tasks done

Failure using homebrew-provided llvm #207161

WardF opened this issue Feb 10, 2025 · 5 comments
Labels
bug Reproducible Homebrew/homebrew-core bug upstream issue An upstream issue report is needed

Comments

@WardF
Copy link

WardF commented Feb 10, 2025

brew gist-logs <formula> link OR brew config AND brew doctor output

wfisher@icelandic:~$ brew config
HOMEBREW_VERSION: 4.4.20
ORIGIN: https://github.com/Homebrew/brew
HEAD: 47ef1a3b0b742a78be35c016df6a0279d6035ebb
Last commit: 7 days ago
Branch: stable
Core tap JSON: 10 Feb 17:22 UTC
Core cask tap JSON: 10 Feb 17:22 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.rwKysaPwGx/org.xquartz:0
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 3.3.7 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.7/bin/ruby
CPU: deca-core 64-bit arm_donan
Clang: 16.0.0 build 1600
Git: 2.39.5 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.3-arm64
CLT: 16.2.0.0.1.1733547573
Xcode: 16.2
Rosetta 2: false

wfisher@icelandic:~$ brew doctor
Your system is ready to brew.
wfisher@icelandic:~$

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

(This issue originally reported by @czender at Unidata/netcdf-c#3083)

Original goal is to use the homebrew-installed llvm suite of tools (clang, etc) to compile netCDF-C (https://github.com/Unidata/netcdf-c).

What happened (include all command output)?

(from @czender)

A few months ago my default build environment on MacOS stopped working due to a Clang compiler error on the file ocdump.c. I usually do not report compiler errors because they have nothing to do with netCDF per se, and the compiler authors usually resolved these things eventually. So consider this a heads-up and feel free to resolve without taking action. However, note that this particular compiler error on this particular file has been there for ~3-4 months, and survived many patch releases of Clang. So it may be something that prevents other users from building/testing netCDF 4.9.3. Everything here (Clang, MacOS, and the netCDF-main branch are the latest available as of today.

zender@spectral:~/netcdf-c$ clang --version
Homebrew clang version 19.1.7
Target: arm64-apple-darwin24.3.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/19.1.7/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin24.cfg
zender@spectral:~/netcdf-c$ 
zender@spectral:~/netcdf-c$ make
...
Normal output ...
...
/bin/sh ../libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I..  -I.. -I.. -I../include -I/opt/homebrew/include  -fno-strict-aliasing -MT liboc_la-ocdump.lo -MD -MP -MF .deps/liboc_la-ocdump.Tpo -c -o liboc_la-ocdump.lo `test -f 'ocdump.c' || echo './'`ocdump.c
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I.. -I.. -I.. -I../include -I/opt/homebrew/include -fno-strict-aliasing -MT liboc_la-ocdump.lo -MD -MP -MF .deps/liboc_la-ocdump.Tpo -c ocdump.c  -fno-common -DPIC -o .libs/liboc_la-ocdump.o
PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang -DHAVE_CONFIG_H -I. -I.. -I.. -I.. -I../include -I/opt/homebrew/include -fno-strict-aliasing -MT liboc_la-ocdump.lo -MD -MP -MF .deps/liboc_la-ocdump.Tpo -c ocdump.c -fno-common -DPIC -o .libs/liboc_la-ocdump.o
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'ocdump.c'.
4.      Running pass 'InstructionSelect' on function '@dumpfield'
 #0 0x00000001186da9dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libLLVM.dylib+0x4a129dc)
 #1 0x0000000113e27808 llvm::sys::CleanupOnSignal(unsigned long) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libLLVM.dylib+0x15f808)
 #2 0x00000001186caa00 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libLLVM.dylib+0x4a02a00)
 #3 0x00000001186caadc CrashRecoverySignalHandler(int) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libLLVM.dylib+0x4a02adc)
 #4 0x000000019aa3ede4 (/usr/lib/system/libsystem_platform.dylib+0x180482de4)
 #5 0x0000000114b644fc llvm::InstructionSelect::runOnMachineFunction(llvm::MachineFunction&) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libLLVM.dylib+0xe9c4fc)
 #6 0x0000000114b644fc llvm::InstructionSelect::runOnMachineFunction(llvm::MachineFunction&) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libLLVM.dylib+0xe9c4fc)
 #7 0x0000000114344c18 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libLLVM.dylib+0x67cc18)
 #8 0x000000011400aa9c llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libLLVM.dylib+0x342a9c)
 #9 0x0000000113ffe70c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libLLVM.dylib+0x33670c)
#10 0x00000001071d2f68 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang-cpp.dylib+0x17def68)
#11 0x000000010759f700 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang-cpp.dylib+0x1bab700)
#12 0x0000000105c2af60 clang::ParseAST(clang::Sema&, bool, bool) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang-cpp.dylib+0x236f60)
#13 0x0000000107d692f0 clang::FrontendAction::Execute() (/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang-cpp.dylib+0x23752f0)
#14 0x0000000107cdfda8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang-cpp.dylib+0x22ebda8)
#15 0x0000000107dc2e04 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang-cpp.dylib+0x23cee04)
#16 0x00000001006e6b3c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/homebrew/Cellar/llvm/19.1.7/bin/clang-19+0x100006b3c)
#17 0x00000001006e478c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/opt/homebrew/Cellar/llvm/19.1.7/bin/clang-19+0x10000478c)
#18 0x000000010791a9b4 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang-cpp.dylib+0x1f269b4)
#19 0x0000000113d5822c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libLLVM.dylib+0x9022c)
#20 0x000000010791a1e4 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang-cpp.dylib+0x1f261e4)
#21 0x00000001078d06bc clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang-cpp.dylib+0x1edc6bc)
#22 0x00000001078f8140 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang-cpp.dylib+0x1f04140)
#23 0x00000001006e3500 clang_main(int, char**, llvm::ToolContext const&) (/opt/homebrew/Cellar/llvm/19.1.7/bin/clang-19+0x100003500)
#24 0x00000001006f104c main (/opt/homebrew/Cellar/llvm/19.1.7/bin/clang-19+0x10001104c)
#25 0x000000019a688274 
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Homebrew clang version 19.1.7
Target: arm64-apple-darwin24.3.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/19.1.7/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin24.cfg
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/ct/rzzvxlqn4_3f9cr8wgn2pm480000gn/T/ocdump-2069b1.c
clang: note: diagnostic msg: /var/folders/ct/rzzvxlqn4_3f9cr8wgn2pm480000gn/T/ocdump-2069b1.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/zender/Library/Logs/DiagnosticReports/clang-19_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg: 

********************
gmake[2]: *** [Makefile:643: liboc_la-ocdump.lo] Error 1
gmake[2]: Leaving directory '/Users/zender/netcdf-c/oc2'
gmake[1]: *** [Makefile:816: all-recursive] Error 1
gmake[1]: Leaving directory '/Users/zender/netcdf-c'
gmake: *** [Makefile:658: all] Error 2
zender@spectral:~/netcdf-c$ 

What did you expect to happen?

Expectation was that netcdf-c would compile properly instead of throwing the compiler-specific error above.

Step-by-step reproduction instructions (by running brew commands)

$ brew install llvm hdf5 cmake
    $ git clone https://github.com/Unidata/netcdf-c
    $ cd netcdf-c && mkdir build && cd build
    $ cmake .. -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang
    $ make
@WardF WardF added the bug Reproducible Homebrew/homebrew-core bug label Feb 10, 2025
@cho-m
Copy link
Member

cho-m commented Feb 12, 2025

Could be an upstream LLVM issue but would need to try narrowing down to a minimal reproducer.

Seems to be happening in GlobalIsel which is only used in -O0. So a workaround could be a higher optimization or just disabling GlobalIsel (-mllvm --aarch64-enable-global-isel-at-O=-1).

Doesn't seem to happen if using older LLVM (brew install llvm@18) though hard to compare as main llvm is built with higher optimization (PGO + LTO) and more features enabled.

@carlocab
Copy link
Member

I think this is an upstream issue -- I get a similar failure with upstream's build too. See https://github.com/carlocab/netcdf-llvm/actions/runs/13278624843/job/37072645813

@cho-m cho-m added the upstream issue An upstream issue report is needed label Feb 12, 2025
@WardF
Copy link
Author

WardF commented Feb 12, 2025

Thank you! @czender, since this appears to be upstream, do you want to open an LLVM issue or shall I? Also, does the workaround in #207161 (comment) work on your end? I'll give it a test here when I get the chance, but I can only test whether it works functionally, not whether it works for your workflow. Thank you @cho-m and @carlocab!

@czender
Copy link

czender commented Feb 12, 2025

Thanks everyone for verifying the issue and supplying a potential workaround. I just tested to suggested compiler flag and ... it works for me! Yippee! @WardF I would appreciate it if you opened the LLVM issue since it will affect a lot of netCDF users unless/until it's fixed upstream.

@carlocab
Copy link
Member

Closing as this is not a Homebrew-specific issue. Please report this at https://github.com/llvm/llvm-project/issues/new?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen&template=Blank+issue to ensure this is fixed.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible Homebrew/homebrew-core bug upstream issue An upstream issue report is needed
Projects
None yet
Development

No branches or pull requests

4 participants