Skip to contentSkip to conversation

package/util-linux: fix build with -O0

PATCH Applied Fabrice Fontaine 3 participants 3 messages Nov 7, 2023 – Mar 16, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/util-linux: fix build with -O0

Fix the following build failure with -O0 raised since bump to version 2.39 in commit ad276d94a392fb13244e042851a44269e6254d61 and
https://github.com/util-linux/util-linux/commit/2fa4168c8bc9d5438bc1dfadda293c7c21b6fa59:

libuuid/src/gen_uuid.c: In function 'uuid_generate_time_generic':
libuuid/src/gen_uuid.c:536:33: error: initializer element is not constant

  THREAD_LOCAL int  cache_size = cs_min;
                                 ^~~~~~

Fixes:
- http://autobuild.buildroot.org/results/7c9b8508345ffaba167c08521fb865d76555be1d
- http://autobuild.buildroot.org/results/2f80a5cdb523cc3c8c0f3693607a1be036b2ae98

---
 ...rc-gen_uuid.c-fix-cs_min-declaration.patch | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 package/util-linux/0001-libuuid-src-gen_uuid.c-fix-cs_min-declaration.patch
package/util-linux/0001-libuuid-src-gen_uuid.c-fix-cs_min-declaration.patch new file +70 -0
new file mode 100644
index 0000000000..ebd7d2961f
@@ -0,0 +1,70 @@
+From 8f501bc54424b0b3fe2f8acf5079418fd73703c5 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <[email protected]>
+Date: Tue, 7 Nov 2023 18:43:57 +0100
+Subject: [PATCH] libuuid/src/gen_uuid.c: fix cs_min declaration
+
+Define cs_min through a define and not a const int to avoid the
+following build failure with -O0 raised since version 2.39 and
+https://github.com/util-linux/util-linux/commit/2fa4168c8bc9d5438bc1dfadda293c7c21b6fa59:
+
+libuuid/src/gen_uuid.c: In function 'uuid_generate_time_generic':
+libuuid/src/gen_uuid.c:536:33: error: initializer element is not constant
+  THREAD_LOCAL int  cache_size = cs_min;
+                                 ^~~~~~
+
+Fixes:
+ - http://autobuild.buildroot.org/results/2f80a5cdb523cc3c8c0f3693607a1be036b2ae98
+
+Signed-off-by: Fabrice Fontaine <[email protected]>
+Upstream: https://github.com/util-linux/util-linux/pull/2573
+---
+ libuuid/src/gen_uuid.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
+index 619ef0131..a70f5cf12 100644
+--- a/libuuid/src/gen_uuid.c
++++ b/libuuid/src/gen_uuid.c
+@@ -518,6 +518,8 @@ int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont_offset)
+ 	return __uuid_generate_time_internal(out, num, cont_offset);
+ }
+ 
++#define CS_MIN (1<<6)
++
+ /*
+  * Generate time-based UUID and store it to @out
+  *
+@@ -529,11 +531,10 @@ int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont_offset)
+ static int uuid_generate_time_generic(uuid_t out) {
+ #ifdef HAVE_TLS
+ 	/* thread local cache for uuidd based requests */
+-	const int			cs_min = (1<<6);
+ 	const int			cs_max = (1<<18);
+ 	const int			cs_factor = 2;
+ 	THREAD_LOCAL int		num = 0;
+-	THREAD_LOCAL int		cache_size = cs_min;
++	THREAD_LOCAL int		cache_size = CS_MIN;
+ 	THREAD_LOCAL int		last_used = 0;
+ 	THREAD_LOCAL struct uuid	uu;
+ 	THREAD_LOCAL time_t		last_time = 0;
+@@ -554,7 +555,7 @@ static int uuid_generate_time_generic(uuid_t out) {
+ 		 */
+ 		if ((last_used == cache_size) && (cache_size < cs_max))
+ 			cache_size *= cs_factor;
+-		else if ((last_used < (cache_size / cs_factor)) && (cache_size > cs_min))
++		else if ((last_used < (cache_size / cs_factor)) && (cache_size > CS_MIN))
+ 			cache_size /= cs_factor;
+ 
+ 		num = cache_size;
+@@ -568,7 +569,7 @@ static int uuid_generate_time_generic(uuid_t out) {
+ 		}
+ 		/* request to daemon failed, reset cache */
+ 		num = 0;
+-		cache_size = cs_min;
++		cache_size = CS_MIN;
+ 	}
+ 	if (num > 0) { /* serve uuid from cache */
+ 		uu.time_low++;
+-- 
+2.42.0
+
Signature · 6 lines
2.42.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 13 lines · On Tue, 7 Nov 2023 18:46:51 +0100 Fabrice Fontaine…

Fix the following build failure with -O0 raised since bump to version 2.39 in commit ad276d94a392fb13244e042851a44269e6254d61 and
https://github.com/util-linux/util-linux/commit/2fa4168c8bc9d5438bc1dfadda293c7c21b6fa59:

libuuid/src/gen_uuid.c: In function 'uuid_generate_time_generic':
libuuid/src/gen_uuid.c:536:33: error: initializer element is not constant

  THREAD_LOCAL int  cache_size = cs_min;
                                 ^~~~~~

Fixes:
- http://autobuild.buildroot.org/results/7c9b8508345ffaba167c08521fb865d76555be1d
- http://autobuild.buildroot.org/results/2f80a5cdb523cc3c8c0f3693607a1be036b2ae98

Quoted 5 lines
---
 ...rc-gen_uuid.c-fix-cs_min-declaration.patch | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 package/util-linux/0001-libuuid-src-gen_uuid.c-fix-cs_min-declaration.patch

Applied to master, thanks.

Thomas

Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
Quoted 18 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:

Quoted 13 lines · On Tue, 7 Nov 2023 18:46:51 +0100 Fabrice Fontaine…

Fix the following build failure with -O0 raised since bump to version 2.39 in commit ad276d94a392fb13244e042851a44269e6254d61 and
https://github.com/util-linux/util-linux/commit/2fa4168c8bc9d5438bc1dfadda293c7c21b6fa59:

libuuid/src/gen_uuid.c: In function 'uuid_generate_time_generic':
libuuid/src/gen_uuid.c:536:33: error: initializer element is not constant THREAD_LOCAL int cache_size = cs_min;
^~~~~~

Fixes:
- http://autobuild.buildroot.org/results/7c9b8508345ffaba167c08521fb865d76555be1d
- http://autobuild.buildroot.org/results/2f80a5cdb523cc3c8c0f3693607a1be036b2ae98

Quoted 7 lines
Quoted 5 lines

---
...rc-gen_uuid.c-fix-cs_min-declaration.patch | 70 +++++++++++++++++++

1 file changed, 70 insertions(+)

create mode 100644 package/util-linux/0001-libuuid-src-gen_uuid.c-fix-cs_min-declaration.patch

Applied to master, thanks.

Committed to 2023.11.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot