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

unable to build glibc for target armv8-linux-gnueabihf #3287

Open
andrewrk opened this issue Sep 22, 2019 · 8 comments
Open

unable to build glibc for target armv8-linux-gnueabihf #3287

andrewrk opened this issue Sep 22, 2019 · 8 comments
Labels
arch-arm 32-bit ARM bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals.
Milestone

Comments

@andrewrk
Copy link
Member

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 andrewrk added bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. arch-arm 32-bit ARM labels Sep 22, 2019
@andrewrk andrewrk added this to the 0.6.0 milestone Sep 22, 2019
andrewrk added a commit that referenced this issue Sep 22, 2019
 * add zig build option `-Dskip-libc` to skip tests that build libc
   (e.g. if you don't want to wait for musl to build)
 * add `-Denable-wine` option which uses wine to run cross compiled
   windows tests on non-windows hosts
 * add `-Denable-qemu` option which uses qemu to run cross compiled
   foreign architecture tests
 * add `-Denable-foreign-glibc=path` option which combined with
   `-Denable-qemu` enables running cross compiled tests that link
   against glibc. See
   https://github.com/ziglang/zig/wiki/Updating-libc#glibc for how to
   produce this directory.
 * the test matrix is done manually. release test builds are only
   enabled by default for the native target. this should save us some CI
   time, while still providing decent coverage of release builds.
   - add test coverage for `x86_64-linux-musl -lc` (building musl libc)
   - add test coverage for `x86_64-linux-gnu -lc` (building glibc)
   - add test coverage for `aarch64v8_5a-linux-none`
   - add test coverage for `aarch64v8_5a-linux-musl -lc` (building musl libc)
   - add test coverage for `aarch64v8_5a-linux-gnu -lc` (building glibc)
   - add test coverage for `arm-linux-none`
   - test coverage for `arm-linux-musleabihf -lc` (building musl libc) is
     disabled due to #3286
   - test coverage for `arm-linux-gnueabihf -lc` (building glibc) is disabled
     due to #3287
   - test coverage for `x86_64-windows-gnu -lc` (building mingw-w64) is
     disabled due to #3285
 * enable qemu testing on the Linux CI job. There's not really a good
   reason to enable wine, since we have a Windows CI job as well.
 * remove the no longer needed `--build-file ../build.zig` from CI
   scripts
 * fix bug in glibc compilation where it wasn't properly reading the abi
   list txt files, resulting in "key not found" error.
 * std.build.Target gains:
   - isNetBSD
   - isLinux
   - osRequiresLibC
   - getArchPtrBitWidth
   - getExternalExecutor
 * zig build system gains support for enabling wine and enabling qemu.
   `artifact.enable_wine = true;`, `artifact.enable_qemu = true;`. This
   communicates that the system has these tools installed and the build
   system will use them to run tests.
 * zig build system gains support for overriding the dynamic linker of
   an executable artifact.
 * fix std.c.lseek prototype. makes behavior tests for
   arm-linux-musleabihf pass.
 * disable std lib tests that are failing on ARM. See #3288, #3289
 * provide `std.os.off_t`.
 * disable some of the compiler_rt symbols for arm 32 bit. Fixes
   compiler_rt tests for arm 32 bit
 * add __stack_chk_guard when linking against glibc. Fixes std lib tests
   for aarch64-linux-gnu
 * workaround for "unable to inline function" using `@inlineCall`. Fixes
   compiler_rt tests for arm 32 bit.
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Mar 31, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 30, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@leventov
Copy link

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

@FireFox317
Copy link
Contributor

FireFox317 commented Jan 28, 2021

@leventov The solution to this (and many more related issues) has been mentioned by @LemonBoy in #4926 (comment), but it still has to be done.

@fwg
Copy link

fwg commented Feb 14, 2022

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).

@flyx
Copy link

flyx commented Feb 15, 2022

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.

@tmm1
Copy link
Sponsor

tmm1 commented Sep 11, 2022

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

@andrewrk
Copy link
Member Author

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.

@alexrp
Copy link
Sponsor Contributor

alexrp commented Jan 22, 2023

With #12346 merged, should this be closed?

@andrewrk
Copy link
Member Author

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

zig/test/tests.zig

Lines 235 to 242 in c0284e2

// https://github.com/ziglang/zig/issues/3287
//.{
// .target = CrossTarget.parse(.{
// .arch_os_abi = "arm-linux-gnueabihf",
// .cpu_features = "generic+v8a",
// }) catch unreachable,
// .link_libc = true,
//},

@andrewrk andrewrk modified the milestones: 0.11.0, 0.11.1 Jul 20, 2023
@andrewrk andrewrk modified the milestones: 0.11.1, 0.12.0, 0.13.0 Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-arm 32-bit ARM bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals.
Projects
None yet
Development

No branches or pull requests

7 participants