diff mbox series

[v2,4/4] lttng-tools: Remove the scope resolution operator with musl

Message ID 20250720090010.3122861-4-mingli.yu@eng.windriver.com
State New
Headers show
Series [v2,1/4] lttng-ust: Upgrade 2.13.9 -> 2.14.0 | expand

Commit Message

mingli.yu@eng.windriver.com July 20, 2025, 9 a.m. UTC
From: Mingli Yu <mingli.yu@windriver.com>

Remove the scope resolution operator :: in musl build to fix the below
build failure.
 | ../../../sources/lttng-tools-2.14.0/src/common/eventfd.cpp:18:31: error: expected id-expression before numeric constant
 |    18 |                 int flags = ::EFD_CLOEXEC;
 |       |                               ^~~~~~~~~~~
 | ../../../sources/lttng-tools-2.14.0/src/common/eventfd.cpp:21:36: error: expected id-expression before numeric constant
 |    21 |                         flags |= ::EFD_SEMAPHORE;
 |       |

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
 ...Remove-the-scope-resolution-operator.patch | 41 +++++++++++++++++++
 .../lttng/lttng-tools_2.14.0.bb               |  2 +
 2 files changed, 43 insertions(+)
 create mode 100644 meta/recipes-kernel/lttng/lttng-tools/0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch

Comments

Alexander Kanavin July 21, 2025, 9:39 a.m. UTC | #1
On Sun, 20 Jul 2025 at 11:00, Yu, Mingli via lists.openembedded.org
<mingli.yu=eng.windriver.com@lists.openembedded.org> wrote:
>
> +Upstream-Status: Pending

Please no Pending patches without a clear reason. Submit upstream
first, or at least report the issue.

> +SRC_URI:append:libc-musl = " file://0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch"

Why is it conditional to musl? This will cause complications on future
version updates.

Alex
Khem Raj July 22, 2025, 1:23 a.m. UTC | #2
On 7/20/25 2:00 AM, Yu, Mingli via lists.openembedded.org wrote:
> From: Mingli Yu <mingli.yu@windriver.com>
> 
> Remove the scope resolution operator :: in musl build to fix the below
> build failure.
>   | ../../../sources/lttng-tools-2.14.0/src/common/eventfd.cpp:18:31: error: expected id-expression before numeric constant
>   |    18 |                 int flags = ::EFD_CLOEXEC;
>   |       |                               ^~~~~~~~~~~
>   | ../../../sources/lttng-tools-2.14.0/src/common/eventfd.cpp:21:36: error: expected id-expression before numeric constant
>   |    21 |                         flags |= ::EFD_SEMAPHORE;
>   |       |
> 
> Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> ---
>   ...Remove-the-scope-resolution-operator.patch | 41 +++++++++++++++++++
>   .../lttng/lttng-tools_2.14.0.bb               |  2 +
>   2 files changed, 43 insertions(+)
>   create mode 100644 meta/recipes-kernel/lttng/lttng-tools/0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch
> 
> diff --git a/meta/recipes-kernel/lttng/lttng-tools/0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch b/meta/recipes-kernel/lttng/lttng-tools/0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch
> new file mode 100644
> index 00000000000..dac5002f097
> --- /dev/null
> +++ b/meta/recipes-kernel/lttng/lttng-tools/0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch
> @@ -0,0 +1,41 @@
> +From da83d31a8dd555c28eb27bd7a7d3c53b51d5f276 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <mingli.yu@windriver.com>
> +Date: Sun, 20 Jul 2025 16:37:57 +0800
> +Subject: [PATCH] eventfd.cpp: Remove the scope resolution operator
> +
> +Remove the scope resolution operator :: to fix the below build failure
> +with musl.
> + | ../../../sources/lttng-tools-2.14.0/src/common/eventfd.cpp:18:31: error: expected id-expression before numeric constant
> + |    18 |                 int flags = ::EFD_CLOEXEC;
> + |       |                               ^~~~~~~~~~~
> + | ../../../sources/lttng-tools-2.14.0/src/common/eventfd.cpp:21:36: error: expected id-expression before numeric constant
> + |    21 |                         flags |= ::EFD_SEMAPHORE;
> + |       |                                    ^~~~~~~~~~~~~
> +
> +Upstream-Status: Pending

The difference is that musl defines these labels as preprocessor macros

https://git.musl-libc.org/cgit/musl/tree/include/sys/eventfd.h#n14

where as glibc defines then as enums as well.

https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/eventfd.h;h=97a000a4948d02aa9f3d15f488b63545adcf02b4;hb=HEAD#l27

so they can be referenced as flags from the global namespace as well.

Removing the global scope resolution operator (::) and just using the 
flags directly is a portable fix that will work across glibc and musl
so need to make it musl specific, moreover, please send it upstream as
well since its a portable fix.

> +
> +Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> +---
> + src/common/eventfd.cpp | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/src/common/eventfd.cpp b/src/common/eventfd.cpp
> +index fe5b549..3379b0b 100644
> +--- a/src/common/eventfd.cpp
> ++++ b/src/common/eventfd.cpp
> +@@ -15,10 +15,10 @@
> +
> + lttng::eventfd::eventfd(bool use_semaphore_semantics, std::uint64_t initial_value) :
> + 	file_descriptor([use_semaphore_semantics, initial_value]() {
> +-		int flags = ::EFD_CLOEXEC;
> ++		int flags = EFD_CLOEXEC;
> +
> + 		if (use_semaphore_semantics) {
> +-			flags |= ::EFD_SEMAPHORE;
> ++			flags |= EFD_SEMAPHORE;
> + 		}
> +
> + 		const auto raw_fd = ::eventfd(initial_value, flags);
> +--
> +2.34.1
> +
> diff --git a/meta/recipes-kernel/lttng/lttng-tools_2.14.0.bb b/meta/recipes-kernel/lttng/lttng-tools_2.14.0.bb
> index da3bdd4052f..989c963c1f8 100644
> --- a/meta/recipes-kernel/lttng/lttng-tools_2.14.0.bb
> +++ b/meta/recipes-kernel/lttng/lttng-tools_2.14.0.bb
> @@ -48,6 +48,8 @@ SRC_URI = "https://lttng.org/files/lttng-tools/lttng-tools-${PV}.tar.bz2 \
>              file://0001-gen-ust-events-constructor-change-rpath-to-libdir-li.patch \
>              "
>   
> +SRC_URI:append:libc-musl = " file://0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch"
> +
>   SRC_URI[sha256sum] = "d8c39c26cec13b7bd82551cd52a22efc358b888e36ebcf9c1b60ef1c3a3c2fd3"
>   
>   inherit autotools ptest pkgconfig useradd python3-dir manpages systemd
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#220617): https://lists.openembedded.org/g/openembedded-core/message/220617
> Mute This Topic: https://lists.openembedded.org/mt/114249011/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-kernel/lttng/lttng-tools/0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch b/meta/recipes-kernel/lttng/lttng-tools/0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch
new file mode 100644
index 00000000000..dac5002f097
--- /dev/null
+++ b/meta/recipes-kernel/lttng/lttng-tools/0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch
@@ -0,0 +1,41 @@ 
+From da83d31a8dd555c28eb27bd7a7d3c53b51d5f276 Mon Sep 17 00:00:00 2001
+From: Mingli Yu <mingli.yu@windriver.com>
+Date: Sun, 20 Jul 2025 16:37:57 +0800
+Subject: [PATCH] eventfd.cpp: Remove the scope resolution operator
+
+Remove the scope resolution operator :: to fix the below build failure
+with musl.
+ | ../../../sources/lttng-tools-2.14.0/src/common/eventfd.cpp:18:31: error: expected id-expression before numeric constant
+ |    18 |                 int flags = ::EFD_CLOEXEC;
+ |       |                               ^~~~~~~~~~~
+ | ../../../sources/lttng-tools-2.14.0/src/common/eventfd.cpp:21:36: error: expected id-expression before numeric constant
+ |    21 |                         flags |= ::EFD_SEMAPHORE;
+ |       |                                    ^~~~~~~~~~~~~
+
+Upstream-Status: Pending
+
+Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
+---
+ src/common/eventfd.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/common/eventfd.cpp b/src/common/eventfd.cpp
+index fe5b549..3379b0b 100644
+--- a/src/common/eventfd.cpp
++++ b/src/common/eventfd.cpp
+@@ -15,10 +15,10 @@
+ 
+ lttng::eventfd::eventfd(bool use_semaphore_semantics, std::uint64_t initial_value) :
+ 	file_descriptor([use_semaphore_semantics, initial_value]() {
+-		int flags = ::EFD_CLOEXEC;
++		int flags = EFD_CLOEXEC;
+ 
+ 		if (use_semaphore_semantics) {
+-			flags |= ::EFD_SEMAPHORE;
++			flags |= EFD_SEMAPHORE;
+ 		}
+ 
+ 		const auto raw_fd = ::eventfd(initial_value, flags);
+-- 
+2.34.1
+
diff --git a/meta/recipes-kernel/lttng/lttng-tools_2.14.0.bb b/meta/recipes-kernel/lttng/lttng-tools_2.14.0.bb
index da3bdd4052f..989c963c1f8 100644
--- a/meta/recipes-kernel/lttng/lttng-tools_2.14.0.bb
+++ b/meta/recipes-kernel/lttng/lttng-tools_2.14.0.bb
@@ -48,6 +48,8 @@  SRC_URI = "https://lttng.org/files/lttng-tools/lttng-tools-${PV}.tar.bz2 \
            file://0001-gen-ust-events-constructor-change-rpath-to-libdir-li.patch \
            "
 
+SRC_URI:append:libc-musl = " file://0001-eventfd.cpp-Remove-the-scope-resolution-operator.patch"
+
 SRC_URI[sha256sum] = "d8c39c26cec13b7bd82551cd52a22efc358b888e36ebcf9c1b60ef1c3a3c2fd3"
 
 inherit autotools ptest pkgconfig useradd python3-dir manpages systemd