On 11/22/21 09:00, Jacob Kroon via lists.openembedded.org wrote: > Hi, > > Some days ago there was a patch in OE-Core that updated the > Upstream-Status tags in a couple of the gcc patches. I figured this > wouldn't cause too much of rebuilding thanks to hashequiv, but it did, > and all my target packages got rebuilt. > > It turns out that gcc embeds a checksum of its build artifacts, which > includes .a archives, and those will most likely differ between > gcc-cross builds since the timestamps of the .o files are included as > meta information by default. There is a way to configure binutils in > such a way that ar and ranlib defaults to being deterministic > (--enable-deterministic-archives), but I don't think distros like Fedora > do that. > > The target gcc reproduces because it is built with binutils-cross, and > binutils-cross *is* configured with --enable-deterministic-archives. > gcc-cross however is built with the host's binutils. > > I proposed a gcc patch > (https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585060.html) > for building gcc with the 'D' flags passed to ar/ranlib, but it turns > out it is not portable to all platforms. But it did mean that gcc-cross > reproduced. > > Next thing I tried was to let gcc-cross depend on binutils-native, so I > made sure the tools were not removed during do_install(), added the > deterministic configure switch and added the dependency to gcc-cross, > and again gcc-cross reproduced. However, RP raised some concerns about > circular dependencies and increased build times. > > Also, it might be better if *all* cross/native recipes would use > deterministic ar/ranlib, so next thing was to try and pass "-D" in > BUILD_AR and BUILD_RANLIB. This causes problems with recipes that do > "$(AR) cru ...". This becomes "ar D cru ..." which is a fatal error in > ar, see > https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/ar.c;h=8885585ef7537450f0f0990a5eeea7eb16bcad8f;hb=HEAD#l814. > > So next idea was to add wrappers around ar/ranlib (similar to what is > done today for chown/chgrp for native recipes) that filters the options > and makes them behave as if they were built with > --enable-deterministic-archives. This also reproduces gcc-cross, but > introducing more wrapper scripts is perhaps not so great. > > Here are the fragile wrappers I used: > > openembedded-core/scripts/cross-intercept/ar > #!/bin/bash > args=$(echo $1 | sed -e "s/u//g") > shift > PATH=$(echo $PATH | sed -e "s,$(dirname $(realpath -s $0)),,g") > exec ar D $args $* > > openembedded-core/scripts/cross-intercept/ranlib > #!/bin/bash > PATH=$(echo $PATH | sed -e "s,$(dirname $(realpath -s $0)),,g") > exec ranlib -D $* > > Thoughts anyone ? >
I've attached an oe-core patch that adds the wrappers above to native and cross builds. Jacob
From 03deadd32ac8fd6e968183dd9f9aaad08a24d1fb Mon Sep 17 00:00:00 2001 From: Jacob Kroon <[email protected]> Date: Sun, 21 Nov 2021 22:48:49 +0100 Subject: [PATCH] Add ar/ranlib wrappers Signed-off-by: Jacob Kroon <[email protected]> --- meta/classes/cross.bbclass | 2 ++ scripts/cross-intercept/ar | 1 + scripts/cross-intercept/ranlib | 1 + scripts/native-intercept/ar | 5 +++++ scripts/native-intercept/ranlib | 3 +++ 5 files changed, 12 insertions(+) create mode 120000 scripts/cross-intercept/ar create mode 120000 scripts/cross-intercept/ranlib create mode 100755 scripts/native-intercept/ar create mode 100755 scripts/native-intercept/ranlib diff --git a/meta/classes/cross.bbclass b/meta/classes/cross.bbclass index 3e6a2f60b9..9d951076a7 100644 --- a/meta/classes/cross.bbclass +++ b/meta/classes/cross.bbclass @@ -93,3 +93,5 @@ python do_addto_recipe_sysroot () { } addtask addto_recipe_sysroot after do_populate_sysroot do_addto_recipe_sysroot[deptask] = "do_populate_sysroot" + +PATH:prepend = "${COREBASE}/scripts/cross-intercept:" diff --git a/scripts/cross-intercept/ar b/scripts/cross-intercept/ar new file mode 120000 index 0000000000..bc68ffd7a2 --- /dev/null +++ b/scripts/cross-intercept/ar @@ -0,0 +1 @@ +../native-intercept/ar \ No newline at end of file diff --git a/scripts/cross-intercept/ranlib b/scripts/cross-intercept/ranlib new file mode 120000 index 0000000000..87670e7a42 --- /dev/null +++ b/scripts/cross-intercept/ranlib @@ -0,0 +1 @@ +../native-intercept/ranlib \ No newline at end of file diff --git a/scripts/native-intercept/ar b/scripts/native-intercept/ar new file mode 100755 index 0000000000..bcec5cc331 --- /dev/null +++ b/scripts/native-intercept/ar @@ -0,0 +1,5 @@ +#!/bin/bash +args=$(echo $1 | sed -e "s/u//g") +shift +PATH=$(echo $PATH | sed -e "s,$(dirname $(realpath -s $0)),,g") +exec ar D $args $* diff --git a/scripts/native-intercept/ranlib b/scripts/native-intercept/ranlib new file mode 100755 index 0000000000..1f870a3a29 --- /dev/null +++ b/scripts/native-intercept/ranlib @@ -0,0 +1,3 @@ +#!/bin/bash +PATH=$(echo $PATH | sed -e "s,$(dirname $(realpath -s $0)),,g") +exec ranlib -D $*
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1354): https://lists.openembedded.org/g/openembedded-architecture/message/1354 Mute This Topic: https://lists.openembedded.org/mt/87230716/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-architecture/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
