Message ID | 20250523083021.7368-1-kelefa.sane@smile.fr |
---|---|
State | Under Review |
Headers | show |
Series | [meta-oe] crash: fix reproducibility | expand |
Le ven. 23 mai 2025 à 10:30, kelefa.sane via lists.openembedded.org <kelefa.sane=smile.fr@lists.openembedded.org> a écrit : > From: Kéléfa Sané <kelefa.sane@smile.fr> > > Fix reproducibility issue by retrieving the compiler version from the CC > env variable, which define the compiler used in the build and not from > the native gcc compiler install in the host machine. > > Signed-off-by: Kéléfa Sané <kelefa.sane@smile.fr> > Reviewed-by: Yoann Congal <yoann.congal@smile.fr> --- > meta-oe/conf/include/non-repro-meta-oe.inc | 3 -- > meta-oe/recipes-kernel/crash/crash.inc | 1 + > ...e-CC-env-var-to-get-compiler-version.patch | 48 +++++++++++++++++++ > 3 files changed, 49 insertions(+), 3 deletions(-) > create mode 100644 > meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch > > diff --git a/meta-oe/conf/include/non-repro-meta-oe.inc > b/meta-oe/conf/include/non-repro-meta-oe.inc > index 894d7f330a..ae4fb1d194 100755 > --- a/meta-oe/conf/include/non-repro-meta-oe.inc > +++ b/meta-oe/conf/include/non-repro-meta-oe.inc > @@ -7,9 +7,6 @@ KNOWN_NON_REPRO_META_OE = " \ > asio-ptest \ > asio-src \ > cpuid-doc \ > - crash \ > - crash-dbg \ > - crash-src \ > dhrystone \ > dhrystone-dbg \ > dhrystone-dev \ > diff --git a/meta-oe/recipes-kernel/crash/crash.inc > b/meta-oe/recipes-kernel/crash/crash.inc > index aef77be1a0..45fc9cd1fd 100644 > --- a/meta-oe/recipes-kernel/crash/crash.inc > +++ b/meta-oe/recipes-kernel/crash/crash.inc > @@ -27,6 +27,7 @@ SRC_URI = "git:// > github.com/crash-utility/${BPN}.git;branch=master;protocol=http > <http://github.com/crash-utility/$%7BBPN%7D.git;branch=master;protocol=http> > file://0003-Fix-build-failure-in-readline-lib.patch \ > > file://0004-tools.c-do-not-use-keywords-nullptr-as-a-variable-in.patch \ > file://0005-Fix-build-failure-on-32bit-machine-i686.patch \ > + file://0001-Use-CC-env-var-to-get-compiler-version.patch \ > " > SRCREV = "f13853cef53f5c5463a51021edbc81977e2b1405" > > diff --git > a/meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch > b/meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch > new file mode 100644 > index 0000000000..d51008886e > --- /dev/null > +++ > b/meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch > @@ -0,0 +1,48 @@ > +From 31b789d1b21ed26315d08798d6044450e3545ddf Mon Sep 17 00:00:00 2001 > +From: =?UTF-8?q?K=C3=A9l=C3=A9fa=20San=C3=A9?= <kelefa.sane@smile.fr> > +Date: Fri, 16 May 2025 16:18:28 +0200 > +Subject: [PATCH] Use CC env var to get compiler version > +MIME-Version: 1.0 > +Content-Type: text/plain; charset=UTF-8 > +Content-Transfer-Encoding: 8bit > + > +The source file build_data.c generated at compilation time define a > +variable compiler_version which is obtained by calling "gcc --version" > +cmd. This call retrieve the native gcc compiler install on host build > +machine but not necessarily the compiler use to build the project (ex: > +cross compilation). > + > +The CC env variable commonly used in Makefile project define the > +compiler to use at build, so this is the appropriate way to retrieve the > +compiler version, when the CC env var is define. > + > +Upstream-Status: Submitted [ > https://lists.crash-utility.osci.io/archives/list/devel@lists.crash-utility.osci.io/thread/MIPWYZGF3EIC47FVNNYK77FI4ZJ3FHON/ > ] > + > +Signed-off-by: Kéléfa Sané <kelefa.sane@smile.fr> > +--- > + configure.c | 12 +++++++++++- > + 1 file changed, 11 insertions(+), 1 deletion(-) > + > +diff --git a/configure.c b/configure.c > +index 4668c9a..a20e174 100644 > +--- a/configure.c > ++++ b/configure.c > +@@ -1362,7 +1362,17 @@ make_build_data(char *target) > + > + fp1 = popen("date", "r"); > + fp2 = popen("id", "r"); > +- fp3 = popen("gcc --version", "r"); > ++ > ++ const char *cc_env = getenv("CC"); > ++ if(NULL == cc_env) { > ++ fp3 = popen("gcc --version", "r"); > ++ } > ++ else { > ++ char compiler_version_cmd[512]; > ++ > ++ snprintf(compiler_version_cmd, > sizeof(compiler_version_cmd)-1, "%s --version", cc_env); > ++ fp3 = popen(compiler_version_cmd, "r"); > ++ } > + > + if ((fp4 = fopen("build_data.c", "w")) == NULL) { > + perror("build_data.c"); > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#117605): > https://lists.openembedded.org/g/openembedded-devel/message/117605 > Mute This Topic: https://lists.openembedded.org/mt/113261963/4316185 > Group Owner: openembedded-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ > yoann.congal@smile.fr] > -=-=-=-=-=-=-=-=-=-=-=- > >
On 5/23/25 10:30, kelefa.sane via lists.openembedded.org wrote: > From: Kéléfa Sané <kelefa.sane@smile.fr> > > Fix reproducibility issue by retrieving the compiler version from the CC > env variable, which define the compiler used in the build and not from > the native gcc compiler install in the host machine. > > Signed-off-by: Kéléfa Sané <kelefa.sane@smile.fr> > --- > meta-oe/conf/include/non-repro-meta-oe.inc | 3 -- > meta-oe/recipes-kernel/crash/crash.inc | 1 + > ...e-CC-env-var-to-get-compiler-version.patch | 48 +++++++++++++++++++ > 3 files changed, 49 insertions(+), 3 deletions(-) > create mode 100644 meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch > > diff --git a/meta-oe/conf/include/non-repro-meta-oe.inc b/meta-oe/conf/include/non-repro-meta-oe.inc > index 894d7f330a..ae4fb1d194 100755 > --- a/meta-oe/conf/include/non-repro-meta-oe.inc > +++ b/meta-oe/conf/include/non-repro-meta-oe.inc > @@ -7,9 +7,6 @@ KNOWN_NON_REPRO_META_OE = " \ > asio-ptest \ > asio-src \ > cpuid-doc \ > - crash \ > - crash-dbg \ > - crash-src \ > dhrystone \ > dhrystone-dbg \ > dhrystone-dev \ > diff --git a/meta-oe/recipes-kernel/crash/crash.inc b/meta-oe/recipes-kernel/crash/crash.inc > index aef77be1a0..45fc9cd1fd 100644 > --- a/meta-oe/recipes-kernel/crash/crash.inc > +++ b/meta-oe/recipes-kernel/crash/crash.inc > @@ -27,6 +27,7 @@ SRC_URI = "git://github.com/crash-utility/${BPN}.git;branch=master;protocol=http > file://0003-Fix-build-failure-in-readline-lib.patch \ > file://0004-tools.c-do-not-use-keywords-nullptr-as-a-variable-in.patch \ > file://0005-Fix-build-failure-on-32bit-machine-i686.patch \ > + file://0001-Use-CC-env-var-to-get-compiler-version.patch \ > " > SRCREV = "f13853cef53f5c5463a51021edbc81977e2b1405" > > diff --git a/meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch b/meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch > new file mode 100644 > index 0000000000..d51008886e > --- /dev/null > +++ b/meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch > @@ -0,0 +1,48 @@ > +From 31b789d1b21ed26315d08798d6044450e3545ddf Mon Sep 17 00:00:00 2001 > +From: =?UTF-8?q?K=C3=A9l=C3=A9fa=20San=C3=A9?= <kelefa.sane@smile.fr> > +Date: Fri, 16 May 2025 16:18:28 +0200 > +Subject: [PATCH] Use CC env var to get compiler version > +MIME-Version: 1.0 > +Content-Type: text/plain; charset=UTF-8 > +Content-Transfer-Encoding: 8bit > + > +The source file build_data.c generated at compilation time define a > +variable compiler_version which is obtained by calling "gcc --version" > +cmd. This call retrieve the native gcc compiler install on host build > +machine but not necessarily the compiler use to build the project (ex: > +cross compilation). > + > +The CC env variable commonly used in Makefile project define the > +compiler to use at build, so this is the appropriate way to retrieve the > +compiler version, when the CC env var is define. > + > +Upstream-Status: Submitted [https://lists.crash-utility.osci.io/archives/list/devel@lists.crash-utility.osci.io/thread/MIPWYZGF3EIC47FVNNYK77FI4ZJ3FHON/] > + > +Signed-off-by: Kéléfa Sané <kelefa.sane@smile.fr> > +--- > + configure.c | 12 +++++++++++- > + 1 file changed, 11 insertions(+), 1 deletion(-) > + > +diff --git a/configure.c b/configure.c > +index 4668c9a..a20e174 100644 > +--- a/configure.c > ++++ b/configure.c > +@@ -1362,7 +1362,17 @@ make_build_data(char *target) > + > + fp1 = popen("date", "r"); > + fp2 = popen("id", "r"); > +- fp3 = popen("gcc --version", "r"); > ++ > ++ const char *cc_env = getenv("CC"); > ++ if(NULL == cc_env) { > ++ fp3 = popen("gcc --version", "r"); > ++ } > ++ else { > ++ char compiler_version_cmd[512]; > ++ > ++ snprintf(compiler_version_cmd, sizeof(compiler_version_cmd)-1, "%s --version", cc_env); Minor note: no need for "-1". snprintf should take care of that - the maximum number of bytes written includes the terminating \0. > ++ fp3 = popen(compiler_version_cmd, "r"); > ++ } > + > + if ((fp4 = fopen("build_data.c", "w")) == NULL) { > + perror("build_data.c"); > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#117605): https://lists.openembedded.org/g/openembedded-devel/message/117605 > Mute This Topic: https://lists.openembedded.org/mt/113261963/6084445 > Group Owner: openembedded-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
diff --git a/meta-oe/conf/include/non-repro-meta-oe.inc b/meta-oe/conf/include/non-repro-meta-oe.inc index 894d7f330a..ae4fb1d194 100755 --- a/meta-oe/conf/include/non-repro-meta-oe.inc +++ b/meta-oe/conf/include/non-repro-meta-oe.inc @@ -7,9 +7,6 @@ KNOWN_NON_REPRO_META_OE = " \ asio-ptest \ asio-src \ cpuid-doc \ - crash \ - crash-dbg \ - crash-src \ dhrystone \ dhrystone-dbg \ dhrystone-dev \ diff --git a/meta-oe/recipes-kernel/crash/crash.inc b/meta-oe/recipes-kernel/crash/crash.inc index aef77be1a0..45fc9cd1fd 100644 --- a/meta-oe/recipes-kernel/crash/crash.inc +++ b/meta-oe/recipes-kernel/crash/crash.inc @@ -27,6 +27,7 @@ SRC_URI = "git://github.com/crash-utility/${BPN}.git;branch=master;protocol=http file://0003-Fix-build-failure-in-readline-lib.patch \ file://0004-tools.c-do-not-use-keywords-nullptr-as-a-variable-in.patch \ file://0005-Fix-build-failure-on-32bit-machine-i686.patch \ + file://0001-Use-CC-env-var-to-get-compiler-version.patch \ " SRCREV = "f13853cef53f5c5463a51021edbc81977e2b1405" diff --git a/meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch b/meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch new file mode 100644 index 0000000000..d51008886e --- /dev/null +++ b/meta-oe/recipes-kernel/crash/crash/0001-Use-CC-env-var-to-get-compiler-version.patch @@ -0,0 +1,48 @@ +From 31b789d1b21ed26315d08798d6044450e3545ddf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?K=C3=A9l=C3=A9fa=20San=C3=A9?= <kelefa.sane@smile.fr> +Date: Fri, 16 May 2025 16:18:28 +0200 +Subject: [PATCH] Use CC env var to get compiler version +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The source file build_data.c generated at compilation time define a +variable compiler_version which is obtained by calling "gcc --version" +cmd. This call retrieve the native gcc compiler install on host build +machine but not necessarily the compiler use to build the project (ex: +cross compilation). + +The CC env variable commonly used in Makefile project define the +compiler to use at build, so this is the appropriate way to retrieve the +compiler version, when the CC env var is define. + +Upstream-Status: Submitted [https://lists.crash-utility.osci.io/archives/list/devel@lists.crash-utility.osci.io/thread/MIPWYZGF3EIC47FVNNYK77FI4ZJ3FHON/] + +Signed-off-by: Kéléfa Sané <kelefa.sane@smile.fr> +--- + configure.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/configure.c b/configure.c +index 4668c9a..a20e174 100644 +--- a/configure.c ++++ b/configure.c +@@ -1362,7 +1362,17 @@ make_build_data(char *target) + + fp1 = popen("date", "r"); + fp2 = popen("id", "r"); +- fp3 = popen("gcc --version", "r"); ++ ++ const char *cc_env = getenv("CC"); ++ if(NULL == cc_env) { ++ fp3 = popen("gcc --version", "r"); ++ } ++ else { ++ char compiler_version_cmd[512]; ++ ++ snprintf(compiler_version_cmd, sizeof(compiler_version_cmd)-1, "%s --version", cc_env); ++ fp3 = popen(compiler_version_cmd, "r"); ++ } + + if ((fp4 = fopen("build_data.c", "w")) == NULL) { + perror("build_data.c");