ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.82k stars 2.47k forks source link

ensure that building zig from source succeeds on android 5.1 #5782

Open justjosias opened 4 years ago

justjosias commented 4 years ago

During compilation of Zig, using the standard posix instructions, the zig0 executable segfaulted when it was run.

Running the zig0 executable by itself also segfaults.

Compilation log:

[ 98%] Building CXX object CMakeFiles/zig0.dir/src/stage2.cpp.o
[ 98%] Linking CXX executable zig0
make[2]: Leaving directory '/home/josias/git/zig/build'
[ 98%] Built target zig0
make[2]: Entering directory '/home/josias/git/zig/build'
Scanning dependencies of target zig_build_libstage2
make[2]: Leaving directory '/home/josias/git/zig/build'
make[2]: Entering directory '/home/josias/git/zig/build'
Segmentation fault
make[2]: *** [CMakeFiles/zig_build_libstage2.dir/build.make:57: CMakeFiles/zig_build_libstage2] Error 139
make[2]: Leaving directory '/home/josias/git/zig/build'
make[1]: *** [CMakeFiles/Makefile2:178: CMakeFiles/zig_build_libstage2.dir/all] Error 2
make[1]: Leaving directory '/home/josias/git/zig/build'
make: *** [Makefile:130: all] Error 2

The output of strace ./zig0:

execve("./zig0", ["./zig0"], 0xffc77fe0 /* 12 vars */ <unfinished ...>
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x219d02c} ---
<... execve resumed>)                   = ?
+++ killed by SIGSEGV +++
Segmentation fault

Background information: Debian 10 in proot in Termux in Android 5.1 on an ARM tablet. The patch for LLVM PolyPlugin was applied.

Kernel version: 3.18.19

LinuxUserGD commented 1 year ago

I get a different error on Android x86_64 (Waydroid):

~/git/zig/build $ ninja -j4
[15/20] Running zig1.wasm to produce /data/data/com.termux/files/home/git/zig/build/zig2.c
FAILED: zig2.c /data/data/com.termux/files/home/git/zig/build/zig2.c
cd /data/data/com.termux/files/home/git/zig && /data/data/com.termux/files/home/git/zig/build/zig1 /data/data/com.termux/files/home/git/zig/lib build-exe src/main.zig -ofmt=c -lc -OReleaseSmall --name zig2 -femit-bin="/data/data/com.termux/files/home/git/zig/build/zig2.c" --pkg-begin build_options /data/data/com.termux/files/home/git/zig/build/config.zig --pkg-end -target x86_64-android
error: UnknownOperatingSystem
[16/20] Running zig1.wasm to produce /data/data/com.termux/files/home/git/zig/build/compiler_rt.c
FAILED: compiler_rt.c /data/data/com.termux/files/home/git/zig/build/compiler_rt.c
cd /data/data/com.termux/files/home/git/zig && /data/data/com.termux/files/home/git/zig/build/zig1 /data/data/com.termux/files/home/git/zig/lib build-obj lib/compiler_rt.zig -ofmt=c -OReleaseSmall --name compiler_rt -femit-bin="/data/data/com.termux/files/home/git/zig/build/compiler_rt.c" --pkg-begin build_options /data/data/com.termux/files/home/git/zig/build/config.zig --pkg-end -target x86_64-android
error: UnknownOperatingSystem
ninja: build stopped: subcommand failed.
~/git/zig/build $

Edit: Seems to be a different issue (see https://github.com/ziglang/zig/issues/16565), as "Debian 10 in proot" should be still Linux I think