zig icon indicating copy to clipboard operation
zig copied to clipboard

unable to build glibc for target armv8-linux-gnueabihf

Open andrewrk opened this issue 6 years ago • 6 comments
trafficstars

In file included from /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/arm/crti.S:44:
In file included from /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/unix/sysv/linux/arm/sysdep.h:28:
In file included from /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/unix/arm/sysdep.h:19:
/home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/arm/sysdep.h:25:11: fatal error: 'arm-features.h' file not found
# include <arm-features.h>
          ^~~~~~~~~~~~~~~~
1 error generated.

The following command failed:
/home/andy/dev/zig/build/zig cc -MD -MV -MF /home/andy/.local/share/zig/stage1/tmp/sOHDkvFFXRTa-crti.o.d -nostdinc -fno-spell-checking -isystem /home/andy/dev/zig/build/lib/zig/include -target armv8.5a-unknown-linux-gnueabihf -g -fno-omit-frame-pointer -D_DEBUG -fno-stack-protector -fPIC -o /home/andy/.local/share/zig/stage1/tmp/sOHDkvFFXRTa-crti.o -c /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/arm/crti.S -I /home/andy/dev/zig/build/lib/zig/libc/glibc/include -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/unix/sysv/linux/arm -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/arm/nptl -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/unix/sysv/linux/include -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/unix/sysv/linux -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/nptl -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/pthread -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/unix/sysv -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/unix/arm -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/unix -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/arm -I /home/andy/dev/zig/build/lib/zig/libc/glibc/sysdeps/generic -I /home/andy/dev/zig/build/lib/zig/libc/glibc -I /home/andy/dev/zig/build/lib/zig/libc/include/arm-linux-gnueabihf -I /home/andy/dev/zig/build/lib/zig/libc/include/generic-glibc -I /home/andy/dev/zig/build/lib/zig/libc/include/arm-linux-any -I /home/andy/dev/zig/build/lib/zig/libc/include/any-linux-any -D_LIBC_REENTRANT -include /home/andy/dev/zig/build/lib/zig/libc/glibc/include/libc-modules.h -DMODULE_NAME=libc -include /home/andy/dev/zig/build/lib/zig/libc/glibc/include/libc-symbols.h -DTOP_NAMESPACE=glibc -DASSEMBLER -g -Wa,--noexecstack
The following command exited with error code 1:
/home/andy/dev/zig/build/zig test /home/andy/dev/zig/test/stage1/behavior.zig --library c --test-name-prefix behavior-arm-linux-gnueabihf-Debug-c-multi  --cache-dir /home/andy/dev/zig/zig-cache --name test -target armv8_5a-linux-gnueabihf --test-cmd qemu-arm --test-cmd -L --test-cmd /home/andy/Downloads/glibc/multi/install/glibcs/arm-linux-gnueabihf --test-cmd-bin --override-std-dir /home/andy/dev/zig/std 

After this works, test coverage can be added.

andrewrk avatar Sep 22 '19 03:09 andrewrk

@andrewrk is there any update on this or a workaround?

leventov avatar Jan 28 '21 13:01 leventov

@leventov The solution to this (and many more related issues) has been mentioned by @LemonBoy in https://github.com/ziglang/zig/issues/4926#issuecomment-744326413, but it still has to be done.

FireFox317 avatar Jan 28 '21 14:01 FireFox317

If anybody finds this because of the missing arm-features.h, it's not fixed yet with #4926.

I got my code to build by adding the missing header with a wget --content-disposition "https://sourceware.org/git?p=glibc.git;a=blob_plain;f=sysdeps/arm/arm-features.h;hb=HEAD" in my zig lib folder (for me that's either $HOME/lib/zig/libc/glibc/sysdeps/arm or /usr/local/Cellar/zig/0.9.0/lib/zig/libc/glibc/sysdeps/arm).

fwg avatar Feb 14 '22 10:02 fwg

Can confirm @fwg's solution works. Here's how to get a Nix zig package containing the additional file:

zig = zig-overlay.packages.${system}."0.9.0".overrideAttrs (old: {
        installPhase = let
          armFeatures = builtins.fetchurl {
            url = "https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=sysdeps/arm/arm-features.h;h=80a1e2272b5b4ee0976a410317341b5ee601b794;hb=0281c7a7ec8f3f46d8e6f5f3d7fca548946dbfce";
            name = "glibc-2.35_arm-features.h";
            sha256 = "1g4yb51srrfbd4289yj0vrpzzp2rlxllxgz8q4a5zw1n654wzs5a";
          };
        in old.installPhase + "\ncp ${armFeatures} $out/lib/libc/glibc/sysdeps/arm/arm-features.h";
      });

zig-overlay being a Flake input with url = github:arqv/zig-overlay. I pinned the URL to the glibc-2.35 tag.

flyx avatar Feb 15 '22 21:02 flyx

@andrewrk Is there more to this than just merging #12346?

tmm1 avatar Sep 11 '22 20:09 tmm1

Perhaps not, but it is my duty to test & verify patches from first-time contributors. I also need to run the test suite for armv8-linux-gnueabihf and find out if the tests then pass and if so, enable more CI test coverage.

andrewrk avatar Sep 11 '22 20:09 andrewrk

With #12346 merged, should this be closed?

alexrp avatar Jan 22 '23 19:01 alexrp

This issue can be closed when the corresponding tests are enabled:

https://github.com/ziglang/zig/blob/c0284e242f7d78955204dc8a627fecd45aa5e521/test/tests.zig#L235-L242

andrewrk avatar Jan 22 '23 19:01 andrewrk