Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.19: GLOB_BRACE is not portable #2844

Open
kanavin opened this issue Jan 15, 2024 · 3 comments
Open

4.19: GLOB_BRACE is not portable #2844

kanavin opened this issue Jan 15, 2024 · 3 comments
Labels

Comments

@kanavin
Copy link
Contributor

kanavin commented Jan 15, 2024

When building 4.19.1 with musl C library, the following error happens:

/home/pokybuild/yocto-worker/musl-qemux86-64/build/build/tmp/work/core2-64-poky-linux-musl/rpm/4.19.1/git/rpmio/rpmglob.c: In function 'rpmGlobPath':
| /home/pokybuild/yocto-worker/musl-qemux86-64/build/build/tmp/work/core2-64-poky-linux-musl/rpm/4.19.1/git/rpmio/rpmglob.c:84:15: error: 'GLOB_BRACE' undeclared (first use in this function); did you mean 'GLOB_NOSPACE'?
|    84 |     gflags |= GLOB_BRACE;
|       |               ^~~~~~~~~~
|       |               GLOB_NOSPACE

I appreciate that fixing this isn't easy (unless one wants to break all usages of braces in calls to the function).

Full log (it's large, and doesn't contain anything else that would be relevant):
https://autobuilder.yoctoproject.org/typhoon/#/builders/45/builds/8466/steps/11/logs/stdio

@kanavin kanavin added the bug label Jan 15, 2024
@kanavin
Copy link
Contributor Author

kanavin commented Jan 16, 2024

For completeness, we're going to patch rpm to ignore the braces if GLOB_BRACE is absent, and if failures occur on musl systems, then they would be separately fixed - so far none have been found:

From f78e05544fb5ae9ef688963f19666f1af34c3d5c Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex@linutronix.de>
Date: Tue, 16 Jan 2024 09:59:26 +0100
Subject: [PATCH] rpmio/rpmglob.c: avoid using GLOB_BRACE if undefined by C
 library

This addresses musl failures; if there is code out there relying on
those braces, it needs to be fixed when used on musl.

This is unlikely to be trivially fixable upstream.

Upstream-Status: Inappropriate [reported at https://github.com/rpm-software-management/rpm/issues/2844]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 rpmio/rpmglob.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/rpmio/rpmglob.c b/rpmio/rpmglob.c
index 243568766..43c27074a 100644
--- a/rpmio/rpmglob.c
+++ b/rpmio/rpmglob.c
@@ -33,6 +33,12 @@
 
 #include "debug.h"
 
+/* Don't fail if the standard C library
++ * doesn't provide brace expansion */
+#ifndef GLOB_BRACE
+#define GLOB_BRACE 0
+#endif
+
 /* Return 1 if pattern contains a magic char, see glob(7) for a list */
 static int ismagic(const char *pattern)
 {

@dmnks
Copy link
Contributor

dmnks commented Jan 16, 2024

Yup, we recently refactored quite a bit of code related to glob handling, and mostly went with the GNU glob(3) implementation, meaning that at least GLOB_BRACE is indeed used now. Previously, we had our own implementation of brace expansion, IIRC.

I'll have a closer look but it's possible this could actually be fixed upstream. Thanks for the report!

@dmnks dmnks self-assigned this Jan 16, 2024
@kanavin
Copy link
Contributor Author

kanavin commented Jan 16, 2024

FWIW, I think it's most easily fixable by relying on gnulib implementation?
https://github.com/coreutils/gnulib/blob/master/lib/glob.c

@dmnks dmnks removed their assignment Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

2 participants