Skip to content

Commit 07d8be6

Browse files
committed
Merge upstream/dev
2 parents b4d4e71 + 8d24508 commit 07d8be6

126 files changed

Lines changed: 676 additions & 589 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Checkout sources
1616
uses: actions/checkout@main
1717
- name: Build
18-
run: bin/package make -j5
18+
run: bin/package make -j5 CCFLAGS=-Og
1919
- name: Regression tests
2020
run: |
2121
PS4="$PS4[ci.yml] "
@@ -30,13 +30,13 @@ jobs:
3030
sed --regexp-extended --in-place=.orig \
3131
'/^SHOPT (AUDIT|BGX|BRACEPAT|DEVFD|DYNAMIC|EDPREDICT|ESH|FIXEDARRAY|HISTEXPAND|MULTIBYTE|NAMESPACE|OPTIMIZE|SPAWN|STATS|SUID_EXEC|VSH)=/ s/=1?/=0/' \
3232
src/cmd/ksh93/SHOPT.sh &&
33-
bin/package make -j5 &&
33+
bin/package make -j5 CCFLAGS=-Og &&
3434
: default regression tests with SHOPTs disabled &&
3535
script -q -e -c "bin/shtests" &&
3636
: enable SHOPT_SCRIPTONLY, rebuild ksh &&
3737
sed --regexp-extended --in-place=.orig \
3838
'/^SHOPT SCRIPTONLY=/ s/=0?/=1/' \
3939
src/cmd/ksh93/SHOPT.sh &&
40-
bin/package make -j5 &&
40+
bin/package make -j5 CCFLAGS=-Og &&
4141
: default regression tests with SHOPT_SCRIPTONLY enabled &&
4242
script -q -e -c "bin/shtests"

bin/package

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ command=${0##*/}
125125
case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
126126
0123) USAGE=$'
127127
[-?
128-
@(#)$Id: '$command$' (ksh 93u+m) 2026-02-10 $
128+
@(#)$Id: '$command$' (ksh 93u+m) 2026-03-31 $
129129
]
130130
[-author?Glenn Fowler <gsf@research.att.com>]
131131
[-author?Contributors to https://github.com/ksh93/ksh]
@@ -145,8 +145,9 @@ case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
145145
[+?Note that no environment variables need be set by the user;
146146
\b'$command$'\b determines the environment based on the current working
147147
directory. The \buse\b action starts a \bsh\b(1) with the environment
148-
initialized. \bCC\b, \bCCFLAGS\b, \bHOSTTYPE\b and \bSHELL\b may be set
149-
by explicit command argument assignments to override the defaults.]
148+
initialized. \bCC\b, \bCCFLAGS\b, \bHOSTTYPE\b, \bHOSTTAG\b and \bSHELL\b
149+
may be set by explicit command argument assignments to override the
150+
defaults.]
150151
[+?The command arguments are composed of a sequence of words: zero or
151152
more \aqualifiers\a, one \aaction\a, and zero or more action-specific
152153
\aarguments\a, and zero or more \aname=value\a definitions.
@@ -277,6 +278,13 @@ case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
277278
shared libraries. All other architecture-dependent logic is handled
278279
either by the \bAST\b \biffe\b(1) command or by component-specific
279280
configure scripts.]
281+
[+?\b$HOSTTAG\b may contain a short string that, if present, will be added
282+
to the detected \b$HOSTTYPE\b separated by a comma. This is useful to
283+
maintain several object code directories for the same architecture (for
284+
example, with different \bCCFLAGS\b or built from different \bgit\b(1)
285+
branches) under \barch\b while still auto-detecting \b$HOSTTYPE\b.
286+
The value must not contain whitespace or other shell-unsafe characters.
287+
If \bHOSTTYPE\b is specified manually, \bHOSTTAG\b is ignored.]
280288
[+?Each component contains a \bMAM\b (make abstract machine)
281289
file (\bMamfile\b). A Mamfile contains a portable makefile description
282290
written in a simple dependency tree language using indented
@@ -406,9 +414,9 @@ DESCRIPTION
406414

407415
Note that no environment variables need be set by the user; package
408416
determines the environment based on the current working directory. The use
409-
action starts a sh(1) with the environment initialized. CC, CCFLAGS, HOSTTYPE
410-
and SHELL may be set by explicit command argument assignments to override the
411-
defaults.
417+
action starts a sh(1) with the environment initialized. CC, CCFLAGS,
418+
HOSTTYPE, HOSTTAG and SHELL may be set by explicit command argument
419+
assignments to override the defaults.
412420

413421
The command arguments are composed of a sequence of words: zero or more
414422
qualifiers, one action, and zero or more action-specific arguments, and zero
@@ -481,8 +489,8 @@ DESCRIPTION
481489
build is done in the $INSTALLROOT directory tree viewpathed on top of
482490
the $PACKAGEROOT directory tree. Leaf directory names matching the
483491
|-separated shell pattern $MAKESKIP are ignored. The view action is
484-
done before making. option operands are passed to the underlying make
485-
command.
492+
done before making. option operands are passed to the underlying
493+
mamake command.
486494
results [ failed ] [ path ] [ old ] [make | test | write ]
487495
List results and interesting messages captured by the most recent
488496
make (default), test or write action. old specifies the previous
@@ -527,6 +535,14 @@ DETAILS
527535
libraries. All other architecture-dependent logic is handled either by the
528536
AST iffe(1) command or by component-specific configure scripts.
529537

538+
$HOSTTAG may contain a short string that, if present, will be added to the
539+
detected $HOSTTYPE separated by a comma. This is useful to maintain several
540+
object code directories for the same architecture (for example, with
541+
different CCFLAGS or built from different git(1) branches) under arch while
542+
still auto-detecting $HOSTTYPE. The value must not contain whitespace or
543+
other shell-unsafe characters. If HOSTTYPE is specified manually, HOSTTAG is
544+
ignored.
545+
530546
Each component contains a MAM (make abstract machine) file (Mamfile). A
531547
Mamfile contains a portable makefile description written in a simple
532548
dependency tree language using indented make...done blocks.
@@ -543,7 +559,7 @@ SEE ALSO
543559
pkgadd(1), pkgmk(1), rpm(1), sh(1), tar(1), optget(3)
544560

545561
IMPLEMENTATION
546-
version package (ksh 93u+m) 2026-02-10
562+
version package (ksh 93u+m) 2026-03-31
547563
author Glenn Fowler <gsf@research.att.com>
548564
author Contributors to https://github.com/ksh93/ksh
549565
copyright (c) 1994-2012 AT&T Intellectual Property
@@ -605,7 +621,8 @@ do case $i in
605621
assign="$assign $n=$vq"
606622
eval "$n=\$v"
607623
;;
608-
CC) eval "$n=\$v"
624+
CC | HOSTTAG)
625+
eval "$n=\$v"
609626
;;
610627
CCFLAGS)
611628
eval "$n=\$v"
@@ -1545,6 +1562,11 @@ int b(void) { return 0; }
15451562
set -- $_hostinfo_
15461563
_hostinfo_=$*
15471564

1565+
# add host tag if given
1566+
case $HOSTTAG in
1567+
?*) _hostinfo_=${_hostinfo_},$HOSTTAG ;;
1568+
esac
1569+
15481570
# restore the global state
15491571

15501572
PATH=$path

src/cmd/INIT/Mamfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ note *
1313
make install virtual
1414
loop DIR bin include/ast lib/lib lib/probe/C/make lib/probe/C/mam
1515
make %{INSTALLROOT}/%{DIR}
16-
exec - test -d %{@} && touch %{@} || mkdir -p %{@}
16+
exec - mkdir -p %{@}
1717
done
1818
done
1919

src/cmd/INIT/README-mamake.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,6 @@ The *operand string* is any arbitrary text until the end of the line.
245245
A `make`...`done` block defines the rule named *target* using the other commands described here.
246246
Unless the `virtual` attribute is used, *target* names the pathname of the file generated or referenced by the rule.
247247

248-
`mamake` processes the commands within the block if the *target* is out
249-
of date or if the rule has the `virtual` attribute (see below).
250-
251248
The *target* may be repeated as the operand to the `done` command.
252249
In that case, it is matched against the current `make` *target* and
253250
any mismatch will produce a "mismatched done statement" error.
@@ -262,7 +259,9 @@ Dependencies may be defined in two ways:
262259
The dependency is defined as if that block were repeated at the `prev` command's location.
263260

264261
If the block contains one or more `exec` commands (see **Shell actions** below),
265-
the `done` command executes the shell script defined by them.
262+
then the `done` command will execute the shell script defined by them
263+
if the *target* is out of date
264+
or if the rule has the `virtual` attribute (see below).
266265

267266
A `make`...`done` rule may lack any `exec` action, in which case it declares a
268267
dependency (a file that must be present and whose timestamp is propagated to
@@ -274,17 +273,19 @@ by `done`. The one-line `makp` command (see below) may be used as a shorthand
274273
for the latter case.
275274

276275
Making a prerequisite that is currently being made, or one that has already
277-
been made, produces a warning; at strict level 3 and up, this is an error.
276+
been made, is an error.
278277

279278
One or more *attribute*s may be specified by appending them to the `make` command.
280-
(At strict levels < 2, they may also be appended to the `done` command; the effect
281-
is the same either way. At strict level 1, this produces a deprecation warning.)
282279
Attributes apply to the current rule only and do not propagate down to nested rules.
283280
The following *attribute*s are available:
284281

285282
* `dontcare`: Marks files that do not need to exist.
286283
If the file exists then its last-modified timestamp is checked and propagated,
287284
otherwise it is silently ignored.
285+
* `force`: The associated shell action (if any) is always run, regardless of
286+
whether the target file is outdated. In addition, no error is thrown if a
287+
regular target file's timestamp wasn't updated after running the associated
288+
shell action.
288289
* `ignore`: The timestamp associated with the *target* is ignored in dependency resolution.
289290
* `notrace`: Disables echoing (xtrace) of shell action commands.
290291
This does not disable the trace header for the containing rule (see *Shell actions* below).
@@ -294,6 +295,15 @@ The following *attribute*s are available:
294295
By convention, a virtual rule with target `install` performs pre-installation.
295296

296297
> *Obsolete:*
298+
>
299+
> At strict levels < 2:
300+
>
301+
> * Making a prerequisite that is currently being made, or one that has
302+
> already been made, is not an error, but produces a warning.
303+
> * Attributes may also be appended to the `done` command; the effect is the
304+
> same as appending them to `make`. At strict level 1, this produces a
305+
> deprecation warning.
306+
>
297307
> At strict level 4 and up, the following *attribute* is not available.
298308
>
299309
> * `implicit`: Equivalent to `dontcare`.
@@ -303,14 +313,14 @@ The following *attribute*s are available:
303313
> specifying these is an error.
304314
>
305315
> * `archive`: Ignored.
306-
> Historically used to mark the generation of an `ar`(1) archive.
316+
> Historically a no-op used to mark the generation of an `ar`(1) archive.
307317
> * `generated`: Marks rules that produce output files generated by a shell action.
308318
> The explicit assignment of this attribute is ignored at strict level 1.
309319
> The `exec` command implicitly assigns this attribute.
310320
> If a rule has this attribute, other rules dependent on this rule
311321
> will avoid applying viewpathing based on this rule.
312322
> * `joint`: Ignored.
313-
> Historically used to mark one of a group of rules that are built by a single shell action.
323+
> Historically a no-op used to mark a group of rules that are built by a single shell action.
314324
315325
### Simple prerequisite rules ###
316326

@@ -386,9 +396,9 @@ of the automatic variables for any `exec` line depends on the position
386396
of the line in the rule.
387397

388398
At strict level 5 and up, mamake throws a "target not updated" error if a
389-
generated file is not newer than the newest prerequisite after its
399+
generated regular file is not newer than the newest prerequisite after its
390400
associated shell action has been executed, unless the rule has the
391-
`dontcare` attribute.
401+
`dontcare` or `force` attribute.
392402

393403
#### Viewpathing ####
394404

@@ -644,6 +654,7 @@ maintain Mamfiles by hand. The following lists the important changes.
644654
`%{`*variable*`@`*sh-script*`}` have been added, allowing the editing of
645655
variable value fields. The fields are either written to the script's
646656
standard input as lines, or passed as positional parameters.
657+
* The `force` attribute has been added.
647658
* **At strict level 1 and up:**
648659
* Appending attributes to `done` instead of `make` is deprecated
649660
and produces a warning.
@@ -677,7 +688,7 @@ maintain Mamfiles by hand. The following lists the important changes.
677688
are expected to be compatible with parallel processing.
678689
* Unless the `dontcare` attribute is specified, it is an error for a
679690
shell action to fail to update the timestamp of any pre-existing
680-
target file associated with its rule.
691+
regular target file associated with its rule.
681692

682693
## Appendix: mamake compiled against libast ##
683694

src/cmd/INIT/iffe.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ esac
3333
set -o noglob
3434

3535
command=iffe
36-
version=2026-02-10
36+
version=2026-02-30
3737

3838
# DEFPATH should be inherited from package(1)
3939
case $DEFPATH in
@@ -3019,7 +3019,10 @@ $src
30193019
execute $tmp.sh <&$nullin || e=1
30203020
;;
30213021
run*|norun*)
3022-
(eval "$src") <&$nullin || e=1
3022+
case $verbose in
3023+
0) (eval "$src") 9>&$nullout ;;
3024+
*) (eval "$src") 9>&$stderr ;;
3025+
esac <&$nullin || e=1
30233026
;;
30243027
mac*|nomac*)
30253028
if compile $cc -E -P $tmp.c <&$nullin >$tmp.i

src/cmd/INIT/mamake.c

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* coded for portability
2929
*/
3030

31-
#define RELEASE_DATE "2026-03-26"
31+
#define RELEASE_DATE "2026-03-30"
3232
static char id[] = "\n@(#)$Id: mamake (ksh 93u+m) " RELEASE_DATE " $\0\n";
3333

3434
#if _PACKAGE_ast
@@ -178,6 +178,7 @@ static const char usage[] =
178178
#define RULE_notrace 0x0100 /* do not xtrace shell action */
179179
#define RULE_updated 0x0200 /* rule was outdated and remade */
180180
#define RULE_preexisted 0x0400 /* the rule's target preexisted */
181+
#define RULE_force 0x0800 /* always run the shell action */
181182

182183
#define STREAM_KEEP 0x0001 /* don't fclose() on pop() */
183184
#define STREAM_MUST 0x0002 /* push() file must exist */
@@ -1323,7 +1324,7 @@ static char *find(Buf_t *buf, char *file, struct stat *st)
13231324
}
13241325

13251326
/*
1326-
* bind r to a file and return the modify time
1327+
* bind r to a file
13271328
*/
13281329

13291330
static void bindfile(Rule_t *r)
@@ -1462,9 +1463,13 @@ static void print_nice_hdr(Rule_t *r)
14621463
fname, r->line, r->endline, rnamepre, rname);
14631464
/* -e option */
14641465
if (state.explain)
1466+
{
14651467
fprintf(stderr, "# reason: target %s\n",
1468+
r->flags & RULE_virtual ? "is virtual" :
1469+
r->flags & RULE_force ? "is forced" :
14661470
r->flags & RULE_preexisted ? "older than prerequisites" :
1467-
r->flags & RULE_virtual ? "is virtual" : "not found");
1471+
"not found");
1472+
}
14681473
}
14691474

14701475
/*
@@ -1480,7 +1485,9 @@ static void check_shellaction(Rule_t *r, int e)
14801485
;
14811486
else if (status(NULL, 0, r->name, &fstat)) /* target file exists? */
14821487
{
1483-
if (fstat.st_mtime < r->origtime && (r->flags & (RULE_exists | RULE_dontcare)) == RULE_exists && state.strict >= 5)
1488+
char existed = (r->flags & RULE_exists) && !(r->flags & RULE_dontcare);
1489+
char notnew = fstat.st_mtime <= r->origtime && !(r->flags & RULE_force);
1490+
if (existed && notnew && S_ISREG(fstat.st_mode) && state.strict >= 5)
14841491
error_making(r, -2); /* "target not updated" */
14851492
r->time = fstat.st_mtime;
14861493
r->flags |= RULE_exists;
@@ -1913,6 +1920,10 @@ static void attributes(Rule_t *r, char *s)
19131920
if (n == 7 && !strncmp(t, "notrace", n))
19141921
flag = RULE_notrace;
19151922
break;
1923+
case 'f':
1924+
if (n == 5 && !strncmp(t, "force", n))
1925+
flag = RULE_force;
1926+
break;
19161927
}
19171928
if (flag > 0)
19181929
r->flags |= flag;
@@ -2288,26 +2299,32 @@ static void make(Rule_t *r, Makestate_t *parentstate)
22882299
st.bg = st.bg->next;
22892300
free(prev);
22902301
}
2291-
if (st.cmd && state.active && (state.force || r->time < st.modtime || !r->time && !st.modtime))
2292-
{
2293-
/* flag for -e */
2294-
if (r->time)
2295-
r->flags |= RULE_preexisted;
2296-
/* show a nice trace header */
2297-
if ((!PARALLEL(r) || state.chaos) && !(r->flags & RULE_error))
2298-
print_nice_hdr(r);
2299-
/* run the shell action */
2300-
run(r, use(st.cmd));
2301-
if (!r->pid)
2302-
propagate(r, NULL, &st.modtime);
2303-
r->flags |= RULE_updated;
2304-
}
2305-
else if (st.modtime > r->parenttime && r->flags & RULE_generated)
2302+
if (state.active)
23062303
{
2307-
/* if we didn't generate the target in this run, but it's newer than the parent
2308-
* target, then the generation of the parent target was probably interrupted
2309-
* and then resumed in this run, so include this target in %{?} for consistency */
2310-
r->flags |= RULE_updated;
2304+
char outdated;
2305+
outdated = r->time < st.modtime || !r->time && !st.modtime || state.force || r->flags & RULE_force;
2306+
s = st.cmd ? use(st.cmd) : NULL;
2307+
if (s && outdated)
2308+
{
2309+
/* flag for -e */
2310+
if (r->time)
2311+
r->flags |= RULE_preexisted;
2312+
/* show a nice trace header */
2313+
if ((!PARALLEL(r) || state.chaos) && !(r->flags & RULE_error))
2314+
print_nice_hdr(r);
2315+
/* run the shell action */
2316+
run(r, s);
2317+
if (!r->pid)
2318+
propagate(r, NULL, &st.modtime);
2319+
r->flags |= RULE_updated;
2320+
}
2321+
else if (st.modtime > r->parenttime && r->flags & RULE_generated)
2322+
{
2323+
/* if we didn't generate the target in this run, but it's newer than the parent
2324+
* target, then the generation of the parent target was probably interrupted
2325+
* and then resumed in this run, so include this target in %{?} for consistency */
2326+
r->flags |= RULE_updated;
2327+
}
23112328
}
23122329
r->flags |= RULE_made;
23132330
if (!(r->flags & (RULE_dontcare|RULE_error|RULE_exists|RULE_generated|RULE_virtual)))

src/cmd/builtin/Mamfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ setv INSTALLROOT ../../..
99
setv CC cc
1010
setv mam_cc_FLAGS %{mam_cc_TARGET} %{mam_cc_DLL} %{-debug-symbols?1?%{mam_cc_DEBUG} -D_BLD_DEBUG?%{mam_cc_OPTIMIZE}?} %{mam_cc_STDC}
1111
setv CCFLAGS
12-
setv CCLDFLAGS %{-strip-symbols?1?%{mam_cc_LD_STRIP}??}
12+
setv CCLDFLAGS %{-strip-symbols?1?%{mam_cc_LD_STRIP}??} %{mam_cc_EXPORT_DYNAMIC}
1313
setv IFFEFLAGS
1414
setv LDFLAGS
1515

@@ -59,7 +59,7 @@ make install virtual
5959
note *
6060

6161
make %{INSTALLROOT}/bin
62-
exec - test -d %{@} && touch %{@} || mkdir -p %{@}
62+
exec - mkdir -p %{@}
6363
done
6464
make %{INSTALLROOT}/bin/pty
6565
prev pty

0 commit comments

Comments
 (0)