Hi,
After the arm32-on-arm64 issue was resolved in Cross-compiling 'hello' to raspberryPi I’m trying to cross-compile more advanced packages. However, I keep running into a problem where the compiler-rt-libc
fails to build because of invalid assembler instructions. A snippet:
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S: Assembler messages:
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S:19: Error: selected processor does not support `dmb' in Thumb mode
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S:19: Error: selected processor does not support `ldrex r0,[r12]' in Thumb mode
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S:19: Error: cannot honor width suffix -- `add r2,r0,r1'
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S:19: Error: selected processor does not support `strex r3,r2,[r12]' in Thumb mode
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S:19: Error: selected processor does not support `dmb' in Thumb mode
Taken from the command
$ nix build -L github:NixOS/nixpkgs/7eeb326217be38cf0c86e38edf1ec57aa2a974be#pkgs.pkgsCross.raspberryPi.libcamera
running on a NixOS 22.11 aarch64-linux VM.
full log at gist:4f4be6ac9c0c5703637eb9855b5448da · GitHub
Elias
Strange, I think I’ve fixed this issue back in 348d19ad, which should be in NixOS 22.11.
Something is explicitly depending on clang 11, rather than the default version. This requires a real fix to compiler-rt, which I’m working on here: compiler-rt: fix build on ARMv6 by lopsided98 · Pull Request #205176 · NixOS/nixpkgs · GitHub
Thanks everyone!
@rnhmjoj Note that I’m building on NixOS 22.11, but referencing a very recent nixpkgs-unstable commit. Not sure if that makes any difference.
@lopsided98 thanks, that’s very helpful. To workaround the build issue, can I somehow define my own raspberryPi platform specifying armv6k?
I’m not sure how to do it from the command line with flakes (you need to pass the crossSystem
argument when evaluating nixpkgs), but when building a NixOS system this should work:
nixpkgs.crossSystem = {
system = "armv6l-linux";
gcc.arch = "armv6k";
};
Thank you, @lopsided98. I’m hitting a hard-float error now:
cc1: error: '-mfloat-abi=hard': selected architecture lacks an FPU
full log: gist:5786516187b0194ce9f8e73c0930ed45 · GitHub
It’s my understanding that the rpi0 has a FPU. Do I need to tweak the crossSystem further?
Elias
Yeah, I guess you need:
gcc = {
arch = "armv6k";
fpu = "vfp";
};
Thank you. I’m now getting the same error as initially,
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S: Assembler messages:
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S:19: Error: selected processor does not support `dmb' in Thumb mode
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S:19: Error: selected processor does not support `ldrex r0,[r12]' in Thumb mode
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S:19: Error: cannot honor width suffix -- `add r2,r0,r1'
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S:19: Error: selected processor does not support `strex r3,r2,[r12]' in Thumb mode
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> /build/compiler-rt-11.1.0.src/lib/builtins/arm/sync_fetch_and_add_4.S:19: Error: selected processor does not support `dmb' in Thumb mode
compiler-rt-libc-armv6l-unknown-linux-gnueabihf> make[2]: *** [lib/builtins/CMakeFiles/clang_rt.builtins-armhf.dir/build.make:193: lib/builtins/CMakeFiles/clang_rt.builtins-armhf.dir/arm/sync_fetch_and_add_
my nixpkgs
is this:
crosspkgs = import nixpkgs {
system = "${arch}-linux";
crossSystem = {
system = "armv6l-linux";
gcc = {
arch = "armv6k";
fpu = "vfp";
};
};
};
and I’m running
nix build .#crosspkgs.libcamera
What did I miss? The configuration seems to have ignored the armv6k
part.
Elias
Perhaps I misunderstood your arch="armv6k"
to mean that I didn’t need your PR 205176 for my particular case. I’m retrying the build, this time with your PR applied on a local nixpkgs
clone.
Success! libcamera
built without error with the PR applied. I still don’t understand why arch="armv6k"
doesn’t alleviate the problem with assembly instructions.