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

Undefined symbols for architecture arm64 after nix upgrade #6303

Closed
Anton-4 opened this issue Dec 23, 2023 · 2 comments · Fixed by #6314
Closed

Undefined symbols for architecture arm64 after nix upgrade #6303

Anton-4 opened this issue Dec 23, 2023 · 2 comments · Fixed by #6314

Comments

@Anton-4
Copy link
Collaborator

Anton-4 commented Dec 23, 2023

This issue is not encountered on main but does happen when upgrading to a newer nix revision.

This error only happens when building the tests $ cargo test --release --no-run, not when doing cargo build --release, building/running roc files, nor when using the repl.
Partial error:

[...]
error: could not compile `roc_repl_expect` (lib test) due to previous error
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/nix/store/k8ipha35ighvhbigcxh906fylq1w2c5a-rust-default-1.71.1/lib/rustlib/aarch64-apple-darwin/bin:[...]-dead_strip" "-nodefaultlibs"
  = note: Undefined symbols for architecture arm64:
            "std::terminate()", referenced from:
                llvm::itanium_demangle::Node::printAsOperand(llvm::itanium_demangle::OutputBuffer&, llvm::itanium_demangle::Node::Prec, bool) const in libllvm_sys-a632a77be37a2bc1.rlib(ItaniumDemangle.cpp.o)
                llvm::itanium_demangle::PODSmallVector<llvm::itanium_demangle::Node*, 32ul>::push_back(llvm::itanium_demangle::Node* const&) in libllvm_sys-a632a77be37a2bc1.rlib(ItaniumDemangle.cpp.o)
                llvm::itanium_demangle::SpecialName::printLeft(llvm::itanium_demangle::OutputBuffer&) const in libllvm_sys-a632a77be37a2bc1.rlib(ItaniumDemangle.cpp.o)
                llvm::itanium_demangle::CtorVtableSpecialName::printLeft(llvm::itanium_demangle::OutputBuffer&) const in libllvm_sys-a632a77be37a2bc1.rlib(ItaniumDemangle.cpp.o)
                llvm::itanium_demangle::NameType::printLeft(llvm::itanium_demangle::OutputBuffer&) const in libllvm_sys-a632a77be37a2bc1.rlib(ItaniumDemangle.cpp.o)
                llvm::itanium_demangle::ModuleName::printLeft(llvm::itanium_demangle::OutputBuffer&) const in libllvm_sys-a632a77be37a2bc1.rlib(ItaniumDemangle.cpp.o)
                llvm::itanium_demangle::PODSmallVector<llvm::itanium_demangle::PODSmallVector<llvm::itanium_demangle::Node*, 8ul>*, 4ul>::push_back(llvm::itanium_demangle::PODSmallVector<llvm::itanium_demangle::Node*, 8ul>* const&) in libllvm_sys-a632a77be37a2bc1.rlib(ItaniumDemangle.cpp.o)
                ...
[...]
            "operator new(unsigned long)", referenced from:
                _LLVMContextCreate in libllvm_sys-a632a77be37a2bc1.rlib(Core.cpp.o)
                llvm::Module::setModuleInlineAsm(llvm::StringRef) in libllvm_sys-a632a77be37a2bc1.rlib(Core.cpp.o)
                _LLVMAppendBasicBlockInContext in libllvm_sys-a632a77be37a2bc1.rlib(Core.cpp.o)
                _LLVMCreateBuilderInContext in libllvm_sys-a632a77be37a2bc1.rlib(Core.cpp.o)
                _LLVMCreatePassManager in libllvm_sys-a632a77be37a2bc1.rlib(Core.cpp.o)
                _LLVMCreateFunctionPassManagerForModule in libllvm_sys-a632a77be37a2bc1.rlib(Core.cpp.o)
                std::__1::vector<llvm::GenericValue, std::__1::allocator<llvm::GenericValue>>::reserve(unsigned long) in libllvm_sys-a632a77be37a2bc1.rlib(ExecutionEngineBindings.cpp.o)
                ...
          ld: symbol(s) not found for architecture arm64
          clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: could not compile `test_gen` (test "test_gen") due to previous error
Undefined symbols

I was able to bisect this to nixpkgs commit bcbdb800cf7659d6ff36ac114121a056fe8c9656
.

This commit updates llvmPackages on Darwin from 11 to 16. I'm not yet sure why this change is resulting in the Undefined symbols for architecture arm64. The fact that this is only happening when building tests is probably a valuable clue.

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Dec 26, 2023

Looks like this was caused by NixOS/nixpkgs#166205.

Workarounds are available, going to try them out now.

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Dec 26, 2023

Running with RUSTFLAGS="-C link-arg=-lc++abi" fixes the issue. I'm going to update the shellHook in the flake to:

shellHook = ''
            export LLVM_SYS_${llvmMajorMinorStr}_PREFIX="${llvmPkgs.llvm.dev}"
            ${aliases}
            '' + lib.optionalString (system == "aarch64-darwin") ''
              export RUSTFLAGS="-C link-arg=-lc++abi"
            ''; # lc++abi as workaround for github.com/NixOS/nixpkgs/issues/166205, see also github.com/roc-lang/roc/issues/6303

Anton-4 added a commit that referenced this issue Dec 26, 2023
Signed-off-by: Anton-4 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant