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

Presence of gcc-cross tools breaks cross-compilation with zig c++ #10777

Open
PiotrSikora opened this issue Feb 3, 2022 · 0 comments
Open

Presence of gcc-cross tools breaks cross-compilation with zig c++ #10777

PiotrSikora opened this issue Feb 3, 2022 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior os-linux zig cc Zig as a drop-in C compiler feature
Milestone

Comments

@PiotrSikora
Copy link
Contributor

Zig Version

0.10.0-dev.528+f95fcb2b1

Steps to Reproduce

$ cat hello.cpp 
#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

Install gcc-cross tools for aarch64 (this breaks the build)

$ sudo apt install -y g++-aarch64-linux-gnu

Expected Behavior

$ rm -rf ~/.cache/zig && zig c++ -v -target aarch64-linux-musl hello.cpp && file ./a.out
clang version 13.0.0 (https://github.com/ziglang/zig-bootstrap.git 4ed79aefb7a58a6d642f47a81e1ef04fd164042b)                                                                                                                                              
Target: aarch64-unknown-linux-musl                                                                                                                                                                                                                        
Thread model: posix                                                                                                                                                                                                                                       
InstalledDir: /usr/lib/llvm-13/bin                                                                                                                                                                                                                        
[...]
a.out: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, stripped

Actual Behavior

$ rm -rf ~/.cache/zig && zig c++ -v -target aarch64-linux-musl hello.cpp && file ./a.out
clang version 13.0.0 (https://github.com/ziglang/zig-bootstrap.git 4ed79aefb7a58a6d642f47a81e1ef04fd164042b)
Target: aarch64-unknown-linux-musl
Thread model: posix
InstalledDir: /usr/lib/llvm-13/bin
Found candidate GCC installation: /usr/lib/gcc-cross/aarch64-linux-gnu/11
Selected GCC installation: /usr/lib/gcc-cross/aarch64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
[...]
ld.lld: error: undefined symbol: __aarch64_ldadd8_acq_rel
>>> referenced by cxa_exception.cpp
>>>               /root/.cache/zig/o/6eee571a85eafaabee575c7127a903b0/cxa_exception.o:(__cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)) in archive /root/.cache/zig/o/530ffec9b20ea4d9d93d1f9e2815f09f/libc++abi.a
>>> referenced by cxa_exception.cpp
>>>               /root/.cache/zig/o/6eee571a85eafaabee575c7127a903b0/cxa_exception.o:(__cxa_end_catch) in archive /root/.cache/zig/o/530ffec9b20ea4d9d93d1f9e2815f09f/libc++abi.a
>>> referenced by cxa_exception.cpp
>>>               /root/.cache/zig/o/6eee571a85eafaabee575c7127a903b0/cxa_exception.o:(__cxa_decrement_exception_refcount) in archive /root/.cache/zig/o/530ffec9b20ea4d9d93d1f9e2815f09f/libc++abi.a
>>> referenced 8 more times

ld.lld: error: undefined symbol: __aarch64_swp8_acq_rel
>>> referenced by cxa_handlers.cpp
>>>               /root/.cache/zig/o/a71f0a776c9aeea06560b2500ffa1828/cxa_handlers.o:(std::set_new_handler(void (*)())) in archive /root/.cache/zig/o/530ffec9b20ea4d9d93d1f9e2815f09f/libc++abi.a
>>> referenced by cxa_default_handlers.cpp
>>>               /root/.cache/zig/o/66c5fcf0a2b0aad28259afe5c3cb936c/cxa_default_handlers.o:(std::set_unexpected(void (*)())) in archive /root/.cache/zig/o/530ffec9b20ea4d9d93d1f9e2815f09f/libc++abi.a
>>> referenced by cxa_default_handlers.cpp
>>>               /root/.cache/zig/o/66c5fcf0a2b0aad28259afe5c3cb936c/cxa_default_handlers.o:(std::set_terminate(void (*)())) in archive /root/.cache/zig/o/530ffec9b20ea4d9d93d1f9e2815f09f/libc++abi.a

ld.lld: error: undefined symbol: __aarch64_ldadd4_acq_rel
>>> referenced by ios.cpp
>>>               /root/.cache/zig/o/ddb6aef311b844fc43c6171812f69b6a/ios.o:(std::__1::ios_base::xalloc()) in archive /root/.cache/zig/o/8db9de3dbc883d88b6b664ef2d07e036/libc++.a
>>> referenced by stdlib_stdexcept.cpp
>>>               /root/.cache/zig/o/a738e730253ecc25f615ac90cf6b3870/stdlib_stdexcept.o:(std::logic_error::~logic_error()) in archive /root/.cache/zig/o/530ffec9b20ea4d9d93d1f9e2815f09f/libc++abi.a
>>> referenced by stdlib_stdexcept.cpp
>>>               /root/.cache/zig/o/a738e730253ecc25f615ac90cf6b3870/stdlib_stdexcept.o:(std::logic_error::~logic_error()) in archive /root/.cache/zig/o/530ffec9b20ea4d9d93d1f9e2815f09f/libc++abi.a
>>> referenced 16 more times

ld.lld: error: undefined symbol: __aarch64_ldadd8_relax
>>> referenced by memory.cpp
>>>               /root/.cache/zig/o/0e516735b66b21afefaf4dc1a71d91bf/memory.o:(std::__1::__shared_count::__add_shared()) in archive /root/.cache/zig/o/8db9de3dbc883d88b6b664ef2d07e036/libc++.a
>>> referenced by memory.cpp
>>>               /root/.cache/zig/o/0e516735b66b21afefaf4dc1a71d91bf/memory.o:(std::__1::__shared_weak_count::__add_shared()) in archive /root/.cache/zig/o/8db9de3dbc883d88b6b664ef2d07e036/libc++.a
>>> referenced by memory.cpp
>>>               /root/.cache/zig/o/0e516735b66b21afefaf4dc1a71d91bf/memory.o:(std::__1::__shared_weak_count::__add_weak()) in archive /root/.cache/zig/o/8db9de3dbc883d88b6b664ef2d07e036/libc++.a

ld.lld: error: undefined symbol: __aarch64_cas8_acq_rel
>>> referenced by memory.cpp
>>>               /root/.cache/zig/o/0e516735b66b21afefaf4dc1a71d91bf/memory.o:(std::__1::__shared_weak_count::lock()) in archive /root/.cache/zig/o/8db9de3dbc883d88b6b664ef2d07e036/libc++.a
@PiotrSikora PiotrSikora added the bug Observed behavior contradicts documented or intended behavior label Feb 3, 2022
@andrewrk andrewrk added this to the 0.11.0 milestone Aug 19, 2022
@andrewrk andrewrk modified the milestones: 0.11.0, 0.12.0 Jun 19, 2023
@andrewrk andrewrk added the zig cc Zig as a drop-in C compiler feature label Aug 13, 2024
@andrewrk andrewrk modified the milestones: 0.14.0, unplanned Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-linux zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

No branches or pull requests

2 participants