Skip to content

Commit 394d7f6

Browse files
committed
Migrate yash to data-driven versions; patch 2.61 to build with gcc 9.4
Step 4 of the per-shell migration. Heredocs in variants/yash.sh are replaced with shvr_read_versions reads from versions/yash.{current,all}. shvr_versioninfo_yash is extended to parse <major>.<minor>[.<patch>] into version_major / version_minor / version_patch (mirrors oksh and loksh). shvr_series_yash emits <major>.<minor> so patch series like 2.58..2.58.1 dedupe to 2.58.1. shvr_update_yash discovers tags from magicant/yash via shvr_versions_from_github_tags. Discovery surfaces 53 versions outside the heredoc range (2.61 plus 0.11..2.44). Probing in the toolchain image classified them into three bands; two are listed in versions/yash.excluded: - 2.41..2.44: arith.c declares iswdigit() in a way that conflicts with modern musl wctype.h, breaking the build. - <=2.40: upstream did not publish release tarballs (the URL pattern returns 404). Every patch within each affected series is enumerated so the series filter can't promote an even-older fallback into .all. The third band (2.61, the only version newer than the heredoc) had a real preprocessor bug: common.h's #if defined(__has_builtin) && __has_builtin(...) guard does not short-circuit at preprocessor time. On compilers where __has_builtin is built-in (not a macro), defined(__has_builtin) is false but the unguarded second clause still has to parse, and gcc 9.4 rejects __has_builtin(x) as an unknown function-like macro. Fixed by patches/yash/2.61/001-common-h-has-builtin-guard.diff, which converts the single guarded #if into nested #ifdef + #if. variants/yash.sh gains the same patches/<shell>/<version>/ application loop ksh.sh already uses, plus `patch` in deps_yash. Source and build checksums for 2.61 are committed.
1 parent 6ba77d2 commit 394d7f6

10 files changed

Lines changed: 174 additions & 25 deletions

File tree

.github/actions/downloads/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,11 @@ runs:
682682
shvr_shell: posh
683683
shvr_version: "0.12.6"
684684
cache_path: "posh/0.12.6"
685+
- uses: ./.github/actions/single-download
686+
with:
687+
shvr_shell: yash
688+
shvr_version: "2.61"
689+
cache_path: "yash/2.61"
685690
- uses: ./.github/actions/single-download
686691
with:
687692
shvr_shell: yash

.github/workflows/docker.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,10 @@ jobs:
711711
shell: posh
712712
version: "0.12.6"
713713
cache_path: "posh/0.12.6"
714+
- target: yash_2.61
715+
shell: yash
716+
version: "2.61"
717+
cache_path: "yash/2.61"
714718
- target: yash_2.60
715719
shell: yash
716720
version: "2.60"
@@ -875,8 +879,8 @@ jobs:
875879
osh_0.36.0
876880
posh_0.14.3
877881
posh_0.13.2
882+
yash_2.61
878883
yash_2.60
879-
yash_2.59
880884
yashrs_3.0.5
881885
yashrs_3.0.4
882886
yashrs_0.4.5
@@ -1019,6 +1023,7 @@ jobs:
10191023
posh_0.14.3
10201024
posh_0.13.2
10211025
posh_0.12.6
1026+
yash_2.61
10221027
yash_2.60
10231028
yash_2.59
10241029
yash_2.58.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1a8cabe5cfd939e7c9802a7f4f16d1be56b58a31f786a70727fa1b7f0d9fa683 yash
1+
60c955748303955b92631138bbb75f9fde90ab9b8d34fbe0e5dd8f14c63412e8 yash
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
01ce98e4a50d4910aa463adf68eb36f6d0112add51267f1b4fcf92cf48344b4f yash
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a214966f4ff8b293aa5521a4d3ef6e87d707579eee616aa2f8218edaa920d447 2.61.tar.gz
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-FileCopyrightText: 2026 Alexandre Gomes Gaigalas <alganet@gmail.com>
2+
# SPDX-License-Identifier: ISC
3+
#
4+
# yash 2.61's common.h uses
5+
# #if defined(__has_builtin) && __has_builtin(__builtin_unreachable)
6+
# to guard a __builtin_unreachable() call. C preprocessor #if does not
7+
# short-circuit at the syntactic level, so on compilers where
8+
# __has_builtin is built-in (not a macro), defined(__has_builtin) is
9+
# false but the second clause still has to parse — and __has_builtin(x)
10+
# is rejected as a function-like macro that doesn't exist. Splitting
11+
# the guard into nested #ifdef/#if avoids the parse of the inner clause
12+
# when the outer guard fails.
13+
--- common.h 2026-01-01 00:00:00 +0000
14+
+++ common.h 2026-01-01 00:00:00 +0000
15+
@@ -54,15 +54,19 @@
16+
# define DUMMY_INIT(dummy_initial_value) = (dummy_initial_value)
17+
#endif
18+
19+
-#if defined(__has_builtin) && __has_builtin(__builtin_unreachable)
20+
-# define UNREACHABLE() \
21+
+#ifdef __has_builtin
22+
+# if __has_builtin(__builtin_unreachable)
23+
+# define UNREACHABLE() \
24+
do { \
25+
assert(!"unreachable code"); \
26+
__builtin_unreachable(); \
27+
} while (0)
28+
+# else
29+
+# define UNREACHABLE() assert(!"unreachable code")
30+
+# endif
31+
#else
32+
# define UNREACHABLE() assert(!"unreachable code")
33+
#endif
34+
35+
#define ARGV(i) ((wchar_t *) argv[i])
36+

variants/yash.sh

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,42 @@ shvr_static_yash ()
1212

1313
shvr_current_yash ()
1414
{
15-
cat <<-@
16-
yash_2.60
17-
yash_2.59
18-
@
15+
shvr_read_versions yash current
1916
}
2017

2118
shvr_targets_yash ()
2219
{
23-
cat <<-@
24-
yash_2.60
25-
yash_2.59
26-
yash_2.58.1
27-
yash_2.57
28-
yash_2.56.1
29-
yash_2.55
30-
yash_2.54
31-
yash_2.53
32-
yash_2.52
33-
yash_2.51
34-
yash_2.50
35-
yash_2.49
36-
yash_2.48
37-
yash_2.47
38-
yash_2.46
39-
yash_2.45
40-
@
20+
shvr_read_versions yash all
21+
}
22+
23+
shvr_update_yash ()
24+
{
25+
. "${SHVR_DIR_SELF}/common/version_sources/github_releases.sh"
26+
shvr_versions_from_github_tags magicant/yash '([0-9]+\.[0-9]+(\.[0-9]+)?)' |
27+
shvr_merge_versions yash
28+
}
29+
30+
shvr_series_yash ()
31+
{
32+
shvr_versioninfo_yash "$1" || return 1
33+
printf '%s.%s\n' "${version_major}" "${version_minor}"
4134
}
4235

4336
shvr_versioninfo_yash ()
4437
{
4538
version="$1"
39+
version_major="${version%%\.*}"
40+
41+
if test "$version" = "$version_major"
42+
then return 1
43+
fi
44+
version_minor="${version#$version_major\.}"
45+
version_patch="${version_minor#*\.}"
46+
if test "$version_patch" = "$version_minor"
47+
then version_patch="0"
48+
else version_minor="${version_minor%\.*}"
49+
fi
50+
4651
build_srcdir="${SHVR_DIR_SRC}/yash/${version}"
4752
}
4853

@@ -68,6 +73,13 @@ shvr_build_yash ()
6873

6974
cd "${build_srcdir}"
7075

76+
if test -d "${SHVR_DIR_SELF}/patches/yash/$version"
77+
then
78+
find "${SHVR_DIR_SELF}/patches/yash/$version" -type f -o -type l | sort | while read -r patch_file
79+
do patch -p0 < "$patch_file"
80+
done
81+
fi
82+
7183
# Static musl build with reproducible flags
7284
export SOURCE_DATE_EPOCH=1
7385
export TZ=UTC
@@ -100,5 +112,5 @@ shvr_deps_yash ()
100112
{
101113
shvr_versioninfo_yash "$1"
102114
apt-get -y install \
103-
curl make xz-utils gettext
115+
curl make xz-utils gettext patch
104116
}

versions/yash.all

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2.61
2+
2.60
3+
2.59
4+
2.58.1
5+
2.57
6+
2.56.1
7+
2.55
8+
2.54
9+
2.53
10+
2.52
11+
2.51
12+
2.50
13+
2.49
14+
2.48
15+
2.47
16+
2.46
17+
2.45

versions/yash.current

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2.61
2+
2.60

versions/yash.excluded

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# 2.41..2.44: arith.c declares `extern int iswdigit(wint_t)` with a return
2+
# type that conflicts with modern wctype.h's `int iswdigit(wint_t)`
3+
# prototype against the musl headers.
4+
2.44
5+
2.43
6+
2.42
7+
2.41
8+
9+
# <=2.40: upstream did not publish release tarballs for these versions
10+
# (the URL https://github.com/magicant/yash/releases/download/$v/yash-$v.tar.xz
11+
# returns 404). Tags exist but the asset doesn't, so download saves the
12+
# 404 HTML page and the build fails at the tar step. Every patch within
13+
# each affected series is enumerated so the series filter can't promote
14+
# an even-older fallback into .all.
15+
2.40
16+
2.39
17+
2.38
18+
2.37
19+
2.36
20+
2.35
21+
2.34
22+
2.33.1
23+
2.33
24+
2.32.1
25+
2.32
26+
2.31
27+
2.30
28+
2.29
29+
2.28
30+
2.27
31+
2.26.1
32+
2.26
33+
2.25
34+
2.24
35+
2.23
36+
2.22
37+
2.21
38+
2.20
39+
2.19
40+
2.18
41+
2.17
42+
2.16
43+
2.15
44+
2.14
45+
2.13
46+
2.12
47+
2.11
48+
2.10
49+
2.9
50+
2.8
51+
2.7
52+
2.6
53+
2.5
54+
2.4
55+
2.3
56+
2.2.2
57+
2.2.1
58+
2.2
59+
2.1.1
60+
2.1
61+
2.0
62+
1.5
63+
1.4.1
64+
1.4
65+
1.3.1
66+
1.3
67+
1.2
68+
1.1
69+
1.0
70+
0.11

0 commit comments

Comments
 (0)