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

aarch64-macos-gnu #44

Closed
andrewrk opened this issue Dec 13, 2020 · 7 comments · Fixed by #55
Closed

aarch64-macos-gnu #44

andrewrk opened this issue Dec 13, 2020 · 7 comments · Fixed by #55

Comments

@andrewrk
Copy link
Member

The first problem is a codesigning issue which I worked around by running codesign -s - but then I hit a second error:

-- Check for working CXX compiler: /Users/andy/dev/zig-bootstrap/out/host/bin/zig
-- Check for working CXX compiler: /Users/andy/dev/zig-bootstrap/out/host/bin/zig - broken
CMake Error at /Users/andy/local/share/cmake-3.19/Modules/CMakeTestCXXCompiler.cmake:59 (message):
  The C++ compiler

    "/Users/andy/dev/zig-bootstrap/out/host/bin/zig"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/andy/dev/zig-bootstrap/out/build-llvm-aarch64-macos-gnu-native/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/make cmTC_9f6ec/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_9f6ec.dir/build.make CMakeFiles/cmTC_9f6ec.dir/build
    Building CXX object CMakeFiles/cmTC_9f6ec.dir/testCXXCompiler.cxx.o
    /Users/andy/dev/zig-bootstrap/out/host/bin/zig  c++ -fno-sanitize=all -target aarch64-macos-gnu -mcpu=native   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk -o CMakeFiles/cmTC_9f6ec.dir/testCXXCompiler.cxx.o -c /Users/andy/dev/zig-bootstrap/out/build-llvm-aarch64-macos-gnu-native/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    Linking CXX executable cmTC_9f6ec
    /Users/andy/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9f6ec.dir/link.txt --verbose=1
    /Users/andy/dev/zig-bootstrap/out/host/bin/zig  c++ -fno-sanitize=all -target aarch64-macos-gnu -mcpu=native  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk -Wl,-headerpad_max_install_names CMakeFiles/cmTC_9f6ec.dir/testCXXCompiler.cxx.o -o cmTC_9f6ec
    warning: unsupported linker arg: -headerpad_max_install_names
    In file included from /Users/andy/dev/zig-bootstrap/out/host/lib/zig/libcxx/src/algorithm.cpp:9:
    In file included from /Users/andy/dev/zig-bootstrap/out/host/lib/zig/libcxx/include/algorithm:641:
    In file included from /Users/andy/dev/zig-bootstrap/out/host/lib/zig/libcxx/include/cstring:60:
    /Users/andy/dev/zig-bootstrap/out/host/lib/zig/libcxx/include/string.h:60:15: fatal error: 'string.h' file not found
    #include_next <string.h>
                  ^~~~~~~~~~
    1 error generated.
    make[1]: *** [cmTC_9f6ec] Error 1
    make: *** [cmTC_9f6ec/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:57 (project)


-- Configuring incomplete, errors occurred!
See also "/Users/andy/dev/zig-bootstrap/out/build-llvm-aarch64-macos-gnu-native/CMakeFiles/CMakeOutput.log".
See also "/Users/andy/dev/zig-bootstrap/out/build-llvm-aarch64-macos-gnu-native/CMakeFiles/CMakeError.log".
andy@Andrews-Air zig-bootstrap %

Not sure why cmake isn't respecting the cc arg like normal here.

@kubkon
Copy link
Member

kubkon commented Dec 22, 2020

Great news, this actually builds fine for me all the way to generating the final bootstrapped artefacts. However, the final zig binary still won't run since the output of LLD when cross-compiling C++ to macOS is malformed as was discussed in ziglang/zig#7318.

This is the output of dyld when running the generated zig binary:

dyld: lazy symbol binding failed: Symbol not found: _zig_stage1_os_init
  Referenced from: /Users/kubkon/dev/zig-bootstrap/out/zig-aarch64-macos-gnu-native/bin/./zig
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _zig_stage1_os_init
  Referenced from: /Users/kubkon/dev/zig-bootstrap/out/zig-aarch64-macos-gnu-native/bin/./zig
  Expected in: /usr/lib/libSystem.B.dylib

[1]    87741 abort      ./zig

The reason dyld is trying to find the symbol in libSystem is due to us patching up the LLD output post-mortem. Everything would be find if not for the fact that the missing symbol should have been statically linked.

@kubkon kubkon mentioned this issue Dec 23, 2020
@kivikakk
Copy link
Contributor

2303ab8 gets up to here:

[ 98%] Linking CXX static library ../../../lib/liblldELF.a
[ 98%] Built target lldELF
Scanning dependencies of target MachOOptionsTableGen
[ 98%] Building Options.inc...
[ 98%] Built target MachOOptionsTableGen
Scanning dependencies of target lldMachO2
[ 98%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/Arch/X86_64.cpp.o
[ 98%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/UnwindInfoSection.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/Driver.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/DriverUtils.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/Dwarf.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/ExportTrie.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/InputFiles.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/InputSection.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/LTO.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/MergedOutputSection.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/ObjC.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/OutputSection.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/OutputSegment.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/SymbolTable.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/Symbols.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/SyntheticSections.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/Target.cpp.o
[100%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/Writer.cpp.o
[100%] Linking CXX static library ../../../lib/liblldMachO2.a
[100%] Built target lldMachO2
Scanning dependencies of target MinGWOptionsTableGen
[100%] Building Options.inc...
[100%] Built target MinGWOptionsTableGen
Scanning dependencies of target lldMinGW
[100%] Building CXX object tools/lld/MinGW/CMakeFiles/lldMinGW.dir/Driver.cpp.o
[100%] Linking CXX static library ../../../lib/liblldMinGW.a
[100%] Built target lldMinGW
Scanning dependencies of target lld
[100%] Building CXX object tools/lld/tools/lld/CMakeFiles/lld.dir/lld.cpp.o
[100%] Linking CXX executable ../../../../bin/lld
warning: unsupported linker arg: -headerpad_max_install_names
error(zld): symbol '__ZN3lld12ErrorHandler5resetEv' defined multiple times
error: MultipleSymbolDefinitions
make[2]: *** [bin/lld] Error 1
make[1]: *** [tools/lld/tools/lld/CMakeFiles/lld.dir/all] Error 2
make: *** [all] Error 2

This is while building using out/host/bin/zig as CC/CXX. My build invocation was:

./build -j1 aarch64-macos-gnu native

@kubkon
Copy link
Member

kubkon commented Apr 19, 2021

@kivikakk Actually, if you use my branch https://github.com/ziglang/zig/tree/zld-cpp-take2 it successfully cross-links both lld and zig, however, there are still a few segfaults I need work out before we can say that zld is capable of properly linking Clang's C++ output. Getting there though!

@kubkon
Copy link
Member

kubkon commented May 6, 2021

Just a heads up for anyone tracking this issue, with #55 we can now successfully bootstrap aarch64-macos-gnu from anywhere!

@andrewrk
Copy link
Member Author

andrewrk commented May 6, 2021

$ ./build -j10 aarch64-macos-gnu cyclone
...
[100%] Linking CXX executable ../../../../bin/lld
warning: unsupported linker arg: -headerpad_max_install_names
error(zld): symbol '__ZN3lld12ErrorHandler5resetEv' defined multiple times
error: MultipleSymbolDefinitions

@andrewrk andrewrk reopened this May 6, 2021
@andrewrk
Copy link
Member Author

andrewrk commented May 6, 2021

oops, forgot to pull...?? sorry!

@andrewrk andrewrk closed this as completed May 6, 2021
@kubkon
Copy link
Member

kubkon commented May 6, 2021

oops, forgot to pull...?? sorry!

Jeez man, you’re gonna give me a heart attack! 😆

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.

3 participants