From: Khem Raj Date: Mon, 23 Jan 2023 17:41:56 +0000 (-0800) Subject: stress-ng: Robustify test-float test X-Git-Tag: lucaceresoli/bug-15201-perf-libtraceevent-missing~1892 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9c4017982a5556580d24e72e74c4d5a879ff11c;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git stress-ng: Robustify test-float test Latest compilers are able to figure out that whole code can be optmized away when CFLAGS has -O2 or more agressive optimizations. In order to ensure the test is doing the right thing, make the variables global so compiler is not able to optimize it away. This fixes build on x86 especially when using clang compiler Signed-off-by: Khem Raj Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- diff --git a/meta/recipes-extended/stress-ng/stress-ng/0001-test-float-Make-variables-global.patch b/meta/recipes-extended/stress-ng/stress-ng/0001-test-float-Make-variables-global.patch new file mode 100644 index 00000000000..2e598ca4f4c --- /dev/null +++ b/meta/recipes-extended/stress-ng/stress-ng/0001-test-float-Make-variables-global.patch @@ -0,0 +1,34 @@ +From 958a86069c8d0149969b5c32212a28009c4a9ded Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 21 Jan 2023 23:18:18 -0800 +Subject: [PATCH] test-float: Make variables global + +Latest clang ( clang 16+ ) is able to optimize everything out when -O2 is used and as +a result build succeeds and test output comes out to be wrong. Therefore +make the variables global, so clang does not optimize away the functions + +Upstream-Status: Backport [https://github.com/ColinIanKing/stress-ng/commit/e299eb60a3a029e975304cc43045aea6ab1fad70] +Signed-off-by: Khem Raj +--- + test/test-float.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/test/test-float.c b/test/test-float.c +index d2800cd3..ad5503c3 100644 +--- a/test/test-float.c ++++ b/test/test-float.c +@@ -61,10 +61,9 @@ + /* Avoid implicit int in the definition of test even if FLOAT is not known. */ + typedef FLOAT float_type; + ++FLOAT a = 0.0, b = 0.0, c = 0.0, d = 0.0; + static float_type HOT OPTIMIZE3 test(void) + { +- FLOAT a = 0.0, b = 0.0, c = 0.0, d = 0.0; +- + float_ops(FLOAT, a, b, c, d, sin, cos); + float_ops(FLOAT, a, b, c, d, sinl, cosl); + +-- +2.39.1 + diff --git a/meta/recipes-extended/stress-ng/stress-ng_0.15.02.bb b/meta/recipes-extended/stress-ng/stress-ng_0.15.02.bb index c554bb403e6..75400f589e4 100644 --- a/meta/recipes-extended/stress-ng/stress-ng_0.15.02.bb +++ b/meta/recipes-extended/stress-ng/stress-ng_0.15.02.bb @@ -6,6 +6,7 @@ LICENSE = "GPL-2.0-only" LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" SRC_URI = "git://github.com/ColinIanKing/stress-ng.git;protocol=https;branch=master \ + file://0001-test-float-Make-variables-global.patch \ file://0001-Pass-LD_GOLD-1-via-makefile-to-enable-gold-linker.patch" SRCREV = "4164f6842c712c2d9a13619c3c70fd35d8d02cdb" S = "${WORKDIR}/git"