Skip to content

Commit 5907cde

Browse files
committed
dash: recover 0.5.2
Three stacked breaks under the modern musl toolchain, all fixed in variants/dash.sh: 1. autoreconf failed because the 0.5.2 tree omits the GNU-required AUTHORS/NEWS/README -- now built with `automake --foreign --add-missing`. 2. It would otherwise pull in libedit (only --with-libedit >=0.5.4) -- now skipped for 0.5.2 like 0.5.3. 3. The sources #include <sys/cdefs.h> (a header musl omits) and use the LFS64 API (struct stat64/open64/lseek64) that musl 1.2.5 dropped -- a compat shim at <srcdir>/sys/cdefs.h supplies __P and macro-maps the *64 names to their base symbols, force-included via CPPFLAGS. Regression-checked 0.5.3/0.5.4/0.5.12 unaffected. Build checksums (amd64+arm64) generated locally against the committed source checksum.
1 parent e12a7ab commit 5907cde

8 files changed

Lines changed: 80 additions & 8 deletions

File tree

.github/actions/downloads/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ runs:
332332
shvr_shell: dash
333333
shvr_version: "0.5.3"
334334
cache_path: "dash/0.5.3"
335+
- uses: ./.github/actions/single-download
336+
with:
337+
shvr_shell: dash
338+
shvr_version: "0.5.2"
339+
cache_path: "dash/0.5.2"
335340
- uses: ./.github/actions/single-download
336341
with:
337342
shvr_shell: hush

.github/workflows/docker.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ jobs:
512512
dash_0.5.5.1
513513
dash_0.5.4
514514
dash_0.5.3
515+
dash_0.5.2
515516
hush_1.38.0
516517
hush_1.37.0
517518
hush_1.36.1
@@ -817,6 +818,7 @@ jobs:
817818
dash_0.5.5.1
818819
dash_0.5.4
819820
dash_0.5.3
821+
dash_0.5.2
820822
hush_1.38.0
821823
hush_1.37.0
822824
hush_1.36.1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8978aabdf20f43f83430da69151de5038e547608fbb1c1efb07cf0b17f826eda dash
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6fd0a314cbf2f0e3c26062143689f41b6aa5491b8c5e0157ae9c04d9a6ed55d8 dash
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0c3f4772e7bb365398d1730430424a064bb3a00d57270ee1d31c51f9f7138348 0.5.2.tar.gz

variants/dash.sh

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ shvr_download_dash ()
5757
fi
5858

5959
# >=0.5.4 builds with the in-tree libedit for line editing/history.
60+
# 0.5.2/0.5.3 predate --with-libedit (0.5.3 hardcodes -DSMALL) and must not
61+
# pull it in.
6062
case "$version" in
61-
0.5.3) ;;
62-
*) shvr_download_libedit ;;
63+
0.5.2|0.5.3) ;;
64+
*) shvr_download_libedit ;;
6365
esac
6466
}
6567

@@ -77,9 +79,12 @@ shvr_build_dash ()
7779
then
7880
./autogen.sh
7981
else
82+
# --foreign: pre-0.5.3 trees (e.g. 0.5.2) ship no AUTHORS/NEWS/README,
83+
# which GNU-strictness automake demands; foreign mode skips that check.
84+
# Harmless on versions that do carry the files.
8085
aclocal
8186
autoheader
82-
automake --add-missing
87+
automake --foreign --add-missing
8388
autoconf
8489
fi
8590

@@ -101,7 +106,7 @@ shvr_build_dash ()
101106
# which is the wrong static link order, so reorder it in the generated Makefile.
102107
libedit_flag=
103108
case "$version" in
104-
0.5.3) ;;
109+
0.5.2|0.5.3) ;;
105110
*)
106111
shvr_build_libedit
107112
cd "${build_srcdir}"
@@ -112,6 +117,55 @@ shvr_build_dash ()
112117
;;
113118
esac
114119

120+
# 0.5.2 predates musl compatibility on two fronts. (1) Its sources include
121+
# <sys/cdefs.h> (for the __P prototype macro), a glibc/BSD header musl does
122+
# not ship. (2) It uses the transitional LFS64 API (struct stat64, open64,
123+
# lseek64, ...) which musl 1.2.5 removed entirely, so those names are
124+
# undefined. A single compat shim handles both: it defines __P/__BEGIN_DECLS
125+
# and macro-maps every *64 name back to its base (musl is 64-bit-off_t
126+
# natively, so the remap is exact). The shim lives at <srcdir>/sys/cdefs.h so
127+
# the in-source `#include <sys/cdefs.h>` lines resolve via the Makefile's
128+
# `-I..`, and it is force-included through CPPFLAGS so files that use stat64
129+
# without including cdefs.h still get the mappings (configure overrides
130+
# CFLAGS with "-g -O2 -Wall" but keeps CPPFLAGS, which the compile applies).
131+
# 0.5.3+ dropped both the header include and the *64 API, so this is gated to
132+
# 0.5.2 only.
133+
case "$version" in
134+
0.5.2)
135+
mkdir -p "${build_srcdir}/sys"
136+
cat > "${build_srcdir}/sys/cdefs.h" <<-'CDEFS'
137+
#ifndef _SHVR_SYS_CDEFS_H
138+
#define _SHVR_SYS_CDEFS_H
139+
#ifndef __P
140+
#define __P(args) args
141+
#endif
142+
#ifndef __BEGIN_DECLS
143+
#define __BEGIN_DECLS
144+
#define __END_DECLS
145+
#endif
146+
/* musl 1.2.5 dropped the LFS64 transitional names; map them back. */
147+
#define stat64 stat
148+
#define lstat64 lstat
149+
#define fstat64 fstat
150+
#define open64 open
151+
#define creat64 creat
152+
#define lseek64 lseek
153+
#define off64_t off_t
154+
#define ino64_t ino_t
155+
#define blkcnt64_t blkcnt_t
156+
#define fsblkcnt64_t fsblkcnt_t
157+
#define fsfilcnt64_t fsfilcnt_t
158+
#define dirent64 dirent
159+
#define readdir64 readdir
160+
#ifndef O_LARGEFILE
161+
#define O_LARGEFILE 0
162+
#endif
163+
#endif
164+
CDEFS
165+
export CPPFLAGS="-include ${build_srcdir}/sys/cdefs.h"
166+
;;
167+
esac
168+
115169
./configure \
116170
--host="$(shvr_musl_target)" \
117171
$libedit_flag \
@@ -123,7 +177,7 @@ shvr_build_dash ()
123177

124178
make
125179

126-
unset SOURCE_DATE_EPOCH TZ CC AR RANLIB CFLAGS LDFLAGS LIBS
180+
unset SOURCE_DATE_EPOCH TZ CC AR RANLIB CFLAGS LDFLAGS LIBS CPPFLAGS
127181

128182
mkdir -p "${SHVR_DIR_OUT}/dash_${version}/bin"
129183
cp "src/dash" "${SHVR_DIR_OUT}/dash_$version/bin/dash"

versions/dash.all

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
0.5.5.1 2009-01-14
1010
0.5.4 2007-07-12
1111
0.5.3 2005-11-26
12+
0.5.2 2005-09-26

versions/dash.excluded

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
# now installs bison (AC_PROG_YACC picks "bison -y"). Newer dash (>=0.5.5.1)
55
# ships a pre-generated arith.c and never needed it.
66

7-
# 0.5.2: autoreconf fails under strict modern automake -- the tree omits the
8-
# ./AUTHORS, ./NEWS, ./README files that GNU-mode automake requires.
9-
0.5.2
7+
# 0.5.2: RECOVERED (see VERSIONS.md, iteration 7). Three stacked breaks under
8+
# the modern musl toolchain: (1) autoreconf failed because the tree omits the
9+
# GNU-required ./AUTHORS/NEWS/README -- now built with `automake --foreign`;
10+
# (2) it would otherwise pull in libedit (only --with-libedit >=0.5.4) -- now
11+
# skipped like 0.5.3; (3) the sources include <sys/cdefs.h> and use the LFS64
12+
# API (struct stat64/open64/lseek64) that musl 1.2.5 dropped -- a compat shim
13+
# at <srcdir>/sys/cdefs.h supplies __P and macro-maps the *64 names back to
14+
# their base symbols, force-included via CPPFLAGS. No longer excluded.
15+
#
16+
# (No versions are currently excluded for dash.)

0 commit comments

Comments
 (0)