diff mbox series

[12/21] mtd-utils: Fix GCC version detection

Message ID 20250324-b4-musl-gcc15-v1-12-ca68c03c5b01@gmail.com
State Accepted, archived
Commit ed24490dccf348ba55816d45a2444d4bf0f574c8
Headers show
Series musl/gcc-15: Fix packages to build with gcc15 on musl platforms | expand

Commit Message

Khem Raj March 24, 2025, 4:33 p.m. UTC
Helps building with GCC with 0 in minor version e.g. 15.0.1

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...01-Improve-check-for-GCC-compiler-version.patch | 34 ++++++++++++++++++++++
 meta/recipes-devtools/mtd/mtd-utils_2.3.0.bb       |  3 +-
 2 files changed, 36 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/mtd/files/0001-Improve-check-for-GCC-compiler-version.patch b/meta/recipes-devtools/mtd/files/0001-Improve-check-for-GCC-compiler-version.patch
new file mode 100644
index 0000000000000000000000000000000000000000..3cd58e053db5352007bc979bb140378607c30663
--- /dev/null
+++ b/meta/recipes-devtools/mtd/files/0001-Improve-check-for-GCC-compiler-version.patch
@@ -0,0 +1,34 @@ 
+From e7adb21350ff3b96dbd2de56a127e9d916c08d62 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 22 Mar 2025 19:05:32 -0700
+Subject: [PATCH] Improve check for GCC compiler version
+
+When using unreleased compiler has version like
+15.0.1 and that test fails because __GNUC_MINOR__ < 1
+becomes true, therefore check for full version string
+which is more rubust.
+
+Upstream-Status: Submitted [https://lists.infradead.org/pipermail/linux-mtd/2025-March/108860.html]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ ubifs-utils/common/atomic.h | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/ubifs-utils/common/atomic.h b/ubifs-utils/common/atomic.h
+index f287d43..95754b2 100644
+--- a/ubifs-utils/common/atomic.h
++++ b/ubifs-utils/common/atomic.h
+@@ -2,8 +2,12 @@
+ #ifndef __ATOMIC_H__
+ #define __ATOMIC_H__
+ 
++#define GCC_VERSION (__GNUC__ * 10000 \
++                     + __GNUC_MINOR__ * 100 \
++                     + __GNUC_PATCHLEVEL__)
++
+ /* Check GCC version, just to be safe */
+-#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC_MINOR__ < 1)
++#if GCC_VERSION < 40100
+ # error atomic.h works only with GCC newer than version 4.1
+ #endif /* GNUC >= 4.1 */
+ 
diff --git a/meta/recipes-devtools/mtd/mtd-utils_2.3.0.bb b/meta/recipes-devtools/mtd/mtd-utils_2.3.0.bb
index aa593ac14f537efdf70ab9a0198245897c903984..2f7043b9773de5912bcd60d8021f8f1c1fec642d 100644
--- a/meta/recipes-devtools/mtd/mtd-utils_2.3.0.bb
+++ b/meta/recipes-devtools/mtd/mtd-utils_2.3.0.bb
@@ -16,7 +16,8 @@  SRC_URI = "git://git.infradead.org/mtd-utils.git;branch=master \
            file://0001-ubifs-utils-ubifs.h-Include-fcntl.h.patch \
            file://0002-ubifs-utils-journal-Include-sys-stat.h.patch \
            file://0003-ubifs-utils-link-libmissing.a-in-case-execinfo.h-isn.patch \
-           file://0004-ubifs-utils-extract_files-Include-linux-limits.h.patch"
+           file://0004-ubifs-utils-extract_files-Include-linux-limits.h.patch \
+           file://0001-Improve-check-for-GCC-compiler-version.patch"
 
 S = "${WORKDIR}/git"