kassane / docker-zig

Minimal Container to use Zig toolchain
MIT License
2 stars 0 forks source link

busybox - issues #1

Open kassane opened 12 months ago

kassane commented 12 months ago

Busybox

build-system with C ABI

 docker run --rm -v $(pwd):/app -w /app kassany/ziglang:0.11.0 build
warning: Encountered error: FileNotFound, falling back to default ABI and dynamic linker.

warning: Encountered error: FileNotFound, falling back to default ABI and dynamic linker.

warning: Encountered error: FileNotFound, falling back to default ABI and dynamic linker.

zig build-exe hello-world Debug native: error: warning: Encountered error: FileNotFound, falling back to default ABI and dynamic linker.

Build works without Libc, but with warning!!

kassane commented 12 months ago
docker run --rm -v $(pwd):/app -w /app kassany/ziglang:0.11.0 libc
Zig attempted to find the path to native system libc headers by executing this command:
cc -E -Wp,-v -xc /dev/null
error: unable to detect native libc: UnableToSpawnCCompiler
kassane commented 12 months ago

New update from busybox:

Works on C ABI, except C++ ABI (linux - musl only):

$> docker run --rm -v $(pwd):/app -w /app kassany/ziglang:latest run -lc hello.c -target native-native-musl 
Hello C!!
$> docker run --rm -v $(pwd):/app -w /app kassany/ziglang:latest run hello.zig
Hello Zig!!
$> docker run --rm -it -v $(pwd):/app -w /app kassany/ziglang:latest run -lc++ hello.cpp -target native-native-musl     
Compile C Objects [1344/1344] aio.c... error(compilation): clang failed with stderr: zig: error: unable to make temporary file: No such file or directory

Compile C Objects [1/10] UnwindLevel1.c... error(compilation): clang failed with stderr: zig: error: unable to make temporary file: No such file or directory

error: unable to build libunwind: SubCompilationFailed

## busybox
docker run --rm -it -v $(pwd):/app -w /app kassany/ziglang:latest c++ -v ###
clang version 16.0.6 (https://github.com/ziglang/zig-bootstrap 34644ad5032c58e39327d33d7f96d63d7c330003)
Target: x86_64-unknown-linux-musl
Thread model: posix
InstalledDir: /app

## debian
docker run --rm -it -v $(pwd):/app -w /app kassany/bookworm-ziglang:latest bash
ziguana@ade7867cd389:/app$ zig c++ -v ###
clang version 16.0.6 (https://github.com/ziglang/zig-bootstrap 34644ad5032c58e39327d33d7f96d63d7c330003)
Target: x86_64-unknown-linux-musl
Thread model: posix
InstalledDir: /app

## my host
zig c++ -v ###
clang version 16.0.6 (https://github.com/ziglang/zig-bootstrap 34644ad5032c58e39327d33d7f96d63d7c330003)
Target: x86_64-unknown-linux-musl
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/13.2.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
kassane commented 12 months ago

Recently there has been an attempt to preload the abi cache. However, it's not done on busybox, but works on debian and alpine.

# force Global-Cache preload
RUN zig c++ -target native-native-musl /dev/null 2>/dev/null; \
    zig c++ -target native-windows /dev/null 2>/dev/null; \
    zig c++ -target native-macos /dev/null 2>/dev/null

## $HOME/.cache/zig (builded: llvm-libcxx/abi + llvm-libunwind + libcompiler-rt + OS-libc [musl/mingw/macos-libc])
kassane commented 10 months ago

In https://github.com/kassane/docker-zig/actions/runs/6597936631

Reference:

kassane commented 2 months ago
0.602 error: download 'https://ziglang.org/download/0.12.0/zig-linux-x86_64-0.12.0.tar.xz' failed: failed to connect to the HTTP server with TlsInitializationFailed

https://github.com/kassane/docker-zig/actions/runs/9303280676/job/25605238505#step:9:153