Skip to content

Commit 5ff682d

Browse files
committed
try patching musl
1 parent 7c1367e commit 5ff682d

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

ci/install-musl.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ musl="musl-${musl_version}"
3030
# first. See https://github.com/rust-lang/ci-mirrors/blob/main/files/libc.toml.
3131
curl --retry 5 "https://ci-mirrors.rust-lang.org/libc/${musl}.tar.gz" | tar xzf -
3232

33+
if [ "$musl_version" = "$old_musl" ]; then
34+
patch_dir="$(realpath ci/musl-patches-1.1.x)"
35+
cd "$musl"
36+
for patchfile in "$patch_dir"/*; do
37+
pwd
38+
cat "$patchfile" | patch -p1
39+
done
40+
cd ..
41+
fi
42+
3343
# Configure, build, and install musl:
3444
cd "$musl"
3545
case ${1} in
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From 725e17ed6dff4d0cd22487bb64470881e86a92e7 Mon Sep 17 00:00:00 2001
2+
From: Rich Felker <dalias@aerifal.cx>
3+
Date: Mon, 6 Nov 2023 08:26:19 -0500
4+
Subject: [PATCH] remove non-prototype declaration of basename from string.h
5+
6+
commit 37bb3cce4598c19288628e675eaf1cda6e96958f suppressed the
7+
declaration for C++, where it is wrongly interpreted as declaring the
8+
function as taking no arguments. with C23 removing non-prototype
9+
declarations, that problem is now also relevant to C.
10+
11+
the non-prototype declaration for basename originates with commit
12+
06aec8d7152dfb8360cb7ed9b3d7215ca0b0b500, where it was designed to
13+
avoid conflicts with programs which declare basename with the GNU
14+
signature taking const char *. that change was probably misguided, as
15+
it represents not only misaligned expectations with the caller, but
16+
also undefined behavior (calling a function that's been declared with
17+
the wrong type).
18+
19+
we could opt to fix the declaration, but since glibc, with the
20+
gratuitously incompatible GNU-basename function, seems to be the only
21+
implementation that declares it in string.h, it seems better to just
22+
remove the declaration. this provides some warning if applications are
23+
being built expecting the GNU behavior but not getting it. if we
24+
declared it here, it would only produce a warning if the caller also
25+
declares it themselves (rare) or if the caller attempts to pass a
26+
const-qualified pointer.
27+
---
28+
include/string.h | 3 ---
29+
1 file changed, 3 deletions(-)
30+
31+
diff --git a/include/string.h b/include/string.h
32+
index db73d2a92..83e2b9464 100644
33+
--- a/include/string.h
34+
+++ b/include/string.h
35+
@@ -95,9 +95,6 @@ char *strchrnul(const char *, int);
36+
char *strcasestr(const char *, const char *);
37+
void *memrchr(const void *, int, size_t);
38+
void *mempcpy(void *, const void *, size_t);
39+
-#ifndef __cplusplus
40+
-char *basename();
41+
-#endif
42+
#endif
43+
44+
#ifdef __cplusplus

0 commit comments

Comments
 (0)