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
alsa-firmware: enable cross compilation #63866
alsa-firmware: enable cross compilation #63866
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my host system it builds fine but cross compiling fails:
builder for '/nix/store/gb1blacz8nlm8srjznpl7njspq74g51z-alsa-firmware-1.0.29-aarch64-unknown-linux-gnu.drv' failed with exit code 2; last 10 log lines:
make[1]: Leaving directory '/build/alsa-firmware-1.0.29/korg1212'
Making all in maestro3
make[1]: Entering directory '/build/alsa-firmware-1.0.29/maestro3'
aarch64-unknown-linux-gnu-gcc -DPACKAGE_NAME=\"alsa-firmware\" -DPACKAGE_TARNAME=\"alsa-firmware\" -DPACKAGE_VERSION=\"1.0.29\" -DPACKAGE_STRING=\"alsa-firmware\ 1.0.29\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DPAC
KAGE=\"alsa-firmware\" -DVERSION=\"1.0.29\" -I. -g -O2 -c -o fw_writer.o fw_writer.c
aarch64-unknown-linux-gnu-gcc -g -O2 -o fw_writer fw_writer.o
./fw_writer
/nix/store/x6b81sfmbmkmcyqp2rmk6jgsmzvyrjj0-bash-4.4-p23/bin/bash: ./fw_writer: cannot execute binary file: Exec format error
make[1]: *** [Makefile:612: maestro3_assp_kernel.fw] Error 126
make[1]: Leaving directory '/build/alsa-firmware-1.0.29/maestro3'
make: *** [Makefile:361: all-recursive] Error 1
[0 built (1 failed)]
error: build of '/nix/store/gb1blacz8nlm8srjznpl7njspq74g51z-alsa-firmware-1.0.29-aarch64-unknown-linux-gnu.drv' failed
Looks like you need to do the same for fw_writer
as for tobin
.
@@ -0,0 +1,347 @@ | |||
--- a/hdsploader/Makefile.am 2015-02-26 20:36:03.000000000 +0800 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did you get this patch from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I composed this patch myself. 😅
@@ -8,6 +8,19 @@ stdenv.mkDerivation rec { | |||
sha256 = "0gfcyj5anckjn030wcxx5v2xk2s219nyf99s9m833275b5wz2piw"; | |||
}; | |||
|
|||
patches = [ ./cross.patch ]; | |||
|
|||
nativeBuildInputs = [ automake autoconf buildPackages.stdenv.cc ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nativeBuildInputs = [ automake autoconf buildPackages.stdenv.cc ]; | |
nativeBuildInputs = [ autoreconfHook buildPackages.stdenv.cc ]; |
This hook does all the autotools steps, so you don't need the preConfigure
either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is neat!
@@ -1,4 +1,4 @@ | |||
{stdenv, fetchurl}: | |||
{stdenv, buildPackages, autoconf, automake, fetchurl}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{stdenv, buildPackages, autoconf, automake, fetchurl}: | |
{ stdenv, buildPackages, autoreconfHook, fetchurl }: |
Spaces + autoreconfHook
You need to do the same to -$(firmware_files): fw_writer
- ./fw_writer
+LINK_FOR_BUILD.c = $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(TARGET_ARCH_FOR_BUILD)
+
+$(fw_writer_OBJECTS) : CC=$(CC_FOR_BUILD)
+$(fw_writer_OBJECTS) : CFLAGS=$(CFLAGS_FOR_BUILD)
+$(fw_writer_OBJECTS) : CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+
+fw_writer$(BUILD_EXEEXT): $(tobin_OBJECTS)
+ $(LINK_FOR_BUILD.c) $^ $(LOADLIBES_FOR_BUILD) $(LDLIBS_FOR_BUILD) -o $@
+
+$(firmware_files): fw_writer$(BUILD_EXEEXT)
+ ./fw_writer$(BUILD_EXEEXT)```
Then it builds fine for me :) |
@JohnAZoidberg I don't know. I built |
81a977a
to
b57c2b5
Compare
Thanks, now your command for building for raspi and |
Have you tried getting the patch merged upstream? :) |
@JohnAZoidberg Oh, good point. I should try upstreaming it, too. |
I see that you tried to upstream this patch, but it looks like it was ignored. Maybe you should replace the patch with a In any case, I tested cross builds for armv6l, armv7l and aarch64 and they all succeeded. I would love to get this merged, as it is one of the few blockers for basic cross-compiled NixOS. |
@lopsided98 sad to hear. Okay, I will use a |
This is also working fine for me on |
@JohnAZoidberg @matthewbauer Okay, I think I need to update this PR to the latest master (?) to keep it fresh, but should I rebase or merge? |
@lopsided98 Maybe it was my fault. I guess the email client I used to submit this patch did something funny with the patch file, and it looks corrupted. I will try to rectify this upstream patch. Now by the look of the patch content it is definitely wrong: there is a reference to my Nix store path. 😂 |
What's the status of this @dingxiangfei2009? Please rebase it on top of the lastest master. |
Any interest in this still? |
I just ran into this issue while trying to cross-compile a very basic sd-card image for armv7l-hf-multiplatform and this patch solved it |
It looks like this no longer applies as of alsa-1.2.1. |
Rebased version of original patch by Ding Xiang Fei found in NixOS/nixpkgs#63866. This version applies in alsa-firmware-1.2.1. Co-authored-by: Ding Xiang Fei <dingxiangfei2009@users.noreply.github.com>
Updated version at matthewbauer/alsa-firmware@a8a4784. @dingxiangfei2009 would it be okay to send this upstream? |
Rebased version of original patch by Ding Xiang Fei found in NixOS/nixpkgs#63866. This version applies in alsa-firmware-1.2.1. Co-authored-by: Ding Xiang Fei <dingxiangfei2009@users.noreply.github.com>
Rebased version of original patch by Ding Xiang Fei found in NixOS/nixpkgs#63866. This version applies in alsa-firmware-1.2.1. Co-authored-by: Ding Xiang Fei <dingxiangfei2009@users.noreply.github.com>
Rebased version of original patch by Ding Xiang Fei found in NixOS/nixpkgs#63866. This version applies in alsa-firmware-1.2.1. Co-authored-by: Ding Xiang Fei <dingxiangfei2009@users.noreply.github.com>
Rebased version of original patch by Ding Xiang Fei found in NixOS/nixpkgs#63866. This version applies in alsa-firmware-1.2.1. Co-authored-by: Ding Xiang Fei <dingxiangfei2009@users.noreply.github.com>
Co-authored-by: Matthew Bauer <mjbauer95@gmail.com>
b57c2b5
to
1525a51
Compare
Thanks for merging, @matthewbauer. Any chance this could get backported to |
Rebased version of original patch by Ding Xiang Fei found in NixOS/nixpkgs#63866. This version applies in alsa-firmware-1.2.1. Co-authored-by: Ding Xiang Fei <dingxiangfei2009@users.noreply.github.com> From: Matthew Bauer <mjbauer95@gmail.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Motivation for this change
The Autoconf and Automake scripts in
alsa-firmware
incorrectly build the firmware writers to the host platform, which leads to incorrect Exec format if they are invoked by these scripts later to transform the firmware blobs. This PR will properly build the writers to the build platform instead.Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)