ziglang / zig

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

`zig cc` unable to build hello-world for target s390x-linux-gnu #21076

Closed bjia56 closed 5 days ago

bjia56 commented 4 weeks ago

Zig Version

0.14.0-dev.1052+d6f997259

Steps to Reproduce and Observed Behavior

$ cat test.c
#include <stdio.h>

int main() {
    printf("Hello world!");
}
$ ./zig-linux-x86_64-0.14.0-dev.1052+d6f997259/zig cc -target s390x-linux-gnu.2.19 test.c -o test
error: sub-compilation of glibc crti.o failed
    note: unable to check cache: stat file 'zig-linux-x86_64-0.14.0-dev.1052+d6f997259/lib/libc/glibc/sysdeps/crti.S' failed: FileNotFound
error: unable to build glibc CRT file: SubCompilationFailed
error: sub-compilation of glibc crtn.o failed
    note: unable to check cache: stat file 'zig-linux-x86_64-0.14.0-dev.1052+d6f997259/lib/libc/glibc/sysdeps/crtn.S' failed: FileNotFound
error: sub-compilation of glibc Scrt1.o failed
    note: unable to check cache: stat file 'zig-linux-x86_64-0.14.0-dev.1052+d6f997259/lib/libc/glibc/sysdeps/start-2.33.S' failed: FileNotFound
$ ./zig-linux-x86_64-0.14.0-dev.1052+d6f997259/zig cc -target s390x-linux-gnu test.c -o test
/home/brettjia/.cache/zig/o/b6158625386ad44943fac58bc9e70c2f/m.s:4025:1: error: symbol 'lgammal' is already defined
lgammal:
^

Expected Behavior

Compilation succeeds.

rootbeer commented 4 weeks ago

Reproduced.

Changing the target glibc version changes the error a bit. A more recent glibc just has the lgammal error:

$ zig cc -target s390x-linux-gnu.2.29 hello.c -o hello
/home/pat/projects/ziglang/zig-global-cache/o/562e59d6889be0dcc813888297ac739a/m.s:4041:1: error: symbol 'lgammal' is already defined
lgammal:
^
$

Depending on your goals, as a work-around the Musl targets seem to work fine:

$ zig  cc -target s390x-linux-musl hello.c -o hello
$
alexrp commented 4 weeks ago

See also #20376.