]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
busybox: Do not define global 'const' with clang
authorKhem Raj <raj.khem@gmail.com>
Sat, 24 May 2025 14:57:43 +0000 (07:57 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 29 May 2025 09:51:50 +0000 (10:51 +0100)
This helps fix segfaults when compiling with clang, the option to
define global const is configurable now in busybox [1] [2]

Turn ptr_to_globals and bb_errno to be non const

writing to a const variable is undefined behavior

This is undefined as per (C99 6.7.3 paragraph 5) see [1]
errno and ptr_to_globals is written to in code, this fails with
segfaults when compiled with clang

[1] https://git.busybox.net/busybox/commit/?id=1f925038a
[2] https://lists.busybox.net/pipermail/busybox/2022-January/089413.html

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/busybox/busybox.inc

index 638b40c758fcdf6d67bc1f4e830230487b5e0611..4ebaeb92c97c8b210df9c03ee5e53e49b375a99a 100644 (file)
@@ -16,6 +16,7 @@ SECTION = "base"
 # Whether to split the suid apps into a seperate binary
 BUSYBOX_SPLIT_SUID ?= "1"
 
+CFLAGS:append:toolchain-clang = " -DBB_GLOBAL_CONST=''"
 export EXTRA_CFLAGS = "${CFLAGS}"
 export EXTRA_LDFLAGS = "${LDFLAGS}"