Skip to content

Linking fails when building Zig: LLD dependencies are missing #12069

Description

@kamidev

Zig Version

b88151 (build fails)

Steps to Reproduce

Apple M1 Max, macOS Version 12.4 (Build 21F79).
llvm 14.0.6 and zlib installed with homebrew.

Using build instructions for M1 Mac from wiki:

➜  rm -rf build; mkdir build; rm -rf ~/.cache/zig; rm -rf zig-cache; git pull
Already up to date.
➜  cd build; cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix llvm) -DZIG_PREFER_CLANG_CPP_DYLIB=true; make install

Expected Behavior

Successful build of stage1 binary

Actual Behavior

Build fails

[ 99%] Linking CXX executable zig0
Undefined symbols for architecture arm64:
  "_adler32", referenced from:
      void lld::elf::OutputSection::maybeCompress<llvm::object::ELFType<(llvm::support::endianness)1, false> >()::'lambda'(unsigned long)::operator()(unsigned long) const in liblldELF.a(OutputSections.cpp.o)
      void lld::elf::OutputSection::maybeCompress<llvm::object::ELFType<(llvm::support::endianness)0, false> >()::'lambda'(unsigned long)::operator()(unsigned long) const in liblldELF.a(OutputSections.cpp.o)
      void lld::elf::OutputSection::maybeCompress<llvm::object::ELFType<(llvm::support::endianness)1, true> >()::'lambda'(unsigned long)::operator()(unsigned long) const in liblldELF.a(OutputSections.cpp.o)
      void lld::elf::OutputSection::maybeCompress<llvm::object::ELFType<(llvm::support::endianness)0, true> >()::'lambda'(unsigned long)::operator()(unsigned long) const in liblldELF.a(OutputSections.cpp.o)
  "_adler32_combine", referenced from:
      void lld::elf::OutputSection::maybeCompress<llvm::object::ELFType<(llvm::support::endianness)1, false> >() in liblldELF.a(OutputSections.cpp.o)
      void lld::elf::OutputSection::maybeCompress<llvm::object::ELFType<(llvm::support::endianness)0, false> >() in liblldELF.a(OutputSections.cpp.o)
      void lld::elf::OutputSection::maybeCompress<llvm::object::ELFType<(llvm::support::endianness)1, true> >() in liblldELF.a(OutputSections.cpp.o)
      void lld::elf::OutputSection::maybeCompress<llvm::object::ELFType<(llvm::support::endianness)0, true> >() in liblldELF.a(OutputSections.cpp.o)
  "_deflate", referenced from:
      deflateShard(llvm::ArrayRef<unsigned char>, int, int) in liblldELF.a(OutputSections.cpp.o)
  "_deflateEnd", referenced from:
      deflateShard(llvm::ArrayRef<unsigned char>, int, int) in liblldELF.a(OutputSections.cpp.o)
  "_deflateInit2_", referenced from:
      deflateShard(llvm::ArrayRef<unsigned char>, int, int) in liblldELF.a(OutputSections.cpp.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [zig0] Error 1
make[1]: *** [CMakeFiles/zig0.dir/all] Error 2
make: *** [all] Error 2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.os-macosmacOS

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions