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

Building with LLVM 10.0.1 installed via Homebrew fails #6087

Closed
kubkon opened this issue Aug 18, 2020 · 11 comments
Closed

Building with LLVM 10.0.1 installed via Homebrew fails #6087

kubkon opened this issue Aug 18, 2020 · 11 comments
Labels
os-macos upstream An issue with a third party project that Zig uses.
Milestone

Comments

@kubkon
Copy link
Member

kubkon commented Aug 18, 2020

As reported by @jbsolomon-fw in #4799, when building on macOS with LLVM 10.0.1 installed via Homebrew, linker trips with the following error:

ld: library not found for -llibxml2.tbd

This seems like an upstream problem with llvm-config which reports the following required system libraries to link properly with LLVM:

$ llvm-config --system-libs
-lz -lcurses -lm -llibxml2.tbd
@kubkon kubkon added os-macos upstream An issue with a third party project that Zig uses. labels Aug 18, 2020
@kubkon
Copy link
Member Author

kubkon commented Aug 18, 2020

A temporary (and super hacky hack hack that makes me cringe) solution to the problem is to:

  1. Create a symbolic link /usr/local/lib/liblibxml2.tbd.dylib -> /usr/lib/libxml2.2.dylib
  2. Add /usr/local/lib to your dyld search path if it's not already there. The easiest way is to simply add LINK_FLAGS "-L/usr/local/lib" to zig0 and zig target properties in CMakeLists.txt:
set_target_properties(zig0 PROPERTIES
    COMPILE_FLAGS ${EXE_CFLAGS}
    LINK_FLAGS ${EXE_LDFLAGS}
    LINK_FLAGS "-L/usr/local/lib"
)

This should get everyone with LLVM 10.0.1 installed via Homebrew on macOS going for now.

@kubkon
Copy link
Member Author

kubkon commented Aug 18, 2020

Out of curiosity, I built upstream LLVM from source, and the future looks even bleaker, with the following output from llvm-config:

$ ./llvm-config --version
12.0.0git
$ ./llvm-config --system-libs
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libcurses.tbd -lm -llibz.tbd -llibxml2.tbd

@kubkon
Copy link
Member Author

kubkon commented Aug 18, 2020

I have now filed an upstream bug report: https://bugs.llvm.org/show_bug.cgi?id=47226

@kubkon
Copy link
Member Author

kubkon commented Aug 19, 2020

UPDATE: Good news, this patch https://reviews.llvm.org/D86134#2224990 fixes this in upstream. Now we need to figure out if there is any plan to backport it to 10.0.1 -> 10.0.1.1, otherwise we'll need to wait an entire release cycle again, and who knows what breaks next...

@johnaoss
Copy link

johnaoss commented Sep 8, 2020

Looks like the patch got reverted: https://reviews.llvm.org/rGcdcb9ab10e53ff08293915af3cd897c42112bcc5

@glepnir
Copy link

glepnir commented Sep 18, 2020

Try the solution..Still got failed.

notCalle added a commit to notCalle/zig that referenced this issue Sep 18, 2020
@notCalle
Copy link
Contributor

Ohai! New to zig, and ran into the same build problem.

Got around it by replacing the broken lib reference in LLVM_LIBRARIES in the CMake config.

@yangruihan
Copy link

yangruihan commented Sep 26, 2020

try

brew install --build-from-source llvm

or remove --system-libs and add -lm -lz -lcurses -lxml2 directly.

@andrewrk andrewrk added this to the 0.7.0 milestone Oct 4, 2020
@andrewrk
Copy link
Member

andrewrk commented Oct 4, 2020

I just built successfully on my macos with llvm 10.0.1_1. No hacks or workarounds were needed. Closing since it appears to be fixed by homebrew.

@andrewrk andrewrk closed this as completed Oct 4, 2020
@ncihnegn
Copy link

ncihnegn commented Oct 9, 2020

Still failing on my mac w/ brew llvm 10.0.1_1.

@andrewrk
Copy link
Member

The LLVM 11 release is imminent. Let's see what happens. Until it gets packaged up you'll have to make do with building from source or using the binary distribution available on ziglang.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os-macos upstream An issue with a third party project that Zig uses.
Projects
None yet
Development

No branches or pull requests

7 participants