Skip to content

Commit 07fa45b

Browse files
author
Andy C
committed
[main] Fix 'oils-for-unix-static osh'
We use a .startswith() check [test/spec-compat] Polish and publish a new report With binary sizes Build a statically-linked Oils
1 parent 6e6c13f commit 07fa45b

File tree

5 files changed

+130
-57
lines changed

5 files changed

+130
-57
lines changed

bin/oils_for_unix.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ def AppBundleMain(argv):
101101
else:
102102
bundle = 'oils-for-unix' # _bin/cxx-dbg/oils-for-unix
103103

104-
# for legacy oils-ref.ovm
105-
if main_name == bundle or (main_name == 'oils-ref' and len(ext)):
104+
# oils-for-unix-static is allowed
105+
# oils-ref.ovm
106+
if main_name.startswith(bundle) or (main_name == 'oils-ref' and len(ext)):
106107
arg_r.Next()
107108
first_arg = arg_r.Peek()
108109
if first_arg is None:

devtools/release-native.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ make-tar() {
116116
local tar_gz=_release/${app_name}-${OILS_VERSION}.tar.gz
117117
gzip -c $tar > $tar_gz
118118

119-
ls -l _release
119+
ls -l --si _release
120120
}
121121

122122
test-tar() {

test/alpine.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,11 @@ if test $name = oils-ref; then
228228
time make $target
229229
$target --version
230230
else
231-
_build/oils.sh
231+
_build/oils.sh --skip-rebuild
232232
_bin/cxx-opt-sh/osh --version
233+
234+
build/static-oils.sh
235+
_bin/cxx-opt-sh/osh-static --version
233236
fi
234237
235238
./install
@@ -252,13 +255,19 @@ test-tar() {
252255

253256
copy-static() {
254257
local chroot_dir=${1:-$CHROOT_OILS_TAR}
255-
local dir=_tmp/musl
258+
local dir=_tmp/musl-libc
256259
mkdir -p $dir
257260
cp -v \
258-
$CHROOT_OILS_TAR/src/oils-for-unix-$OILS_VERSION/_bin/cxx-opt-sh/oils-for-unix.static* \
261+
$CHROOT_OILS_TAR/src/oils-for-unix-$OILS_VERSION/_bin/cxx-opt-sh/oils-for-unix-static* \
259262
$dir
263+
ls -l --si $dir
260264
}
261265

266+
build-static-musl() {
267+
copy-tar
268+
test-tar
269+
copy-static
270+
}
262271

263272
#
264273
# cpp tarball

test/spec-compat-html.sh

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
# Create reports, published at https://pages.oils.pub/
44
#
55
# Usage:
6-
# ./spec-compat-html.sh <function name>
6+
# test/spec-compat-html.sh <function name>
7+
#
8+
# Examples:
9+
# $0 deploy
710
#
811
# TODO:
9-
# - Deploy HTML
10-
# - add tree html
1112
# - improve pages.oils.pub/ index.html
12-
# - Epoch or Build timestamp on page
13+
# - Add epoch or Build timestamp on page - that's at the top
1314
# - Improve
1415
# - summary/percentages in TOP.html?
1516
# - More shells: might as well include ash, dash, ysh
@@ -180,7 +181,7 @@ html-summary-header() {
180181
181182
<h1>$report - Shell Compatibility</h1>
182183
183-
<p>Back to <a href="TOP.html">TOP.html</a>.
184+
<p>Back to <a href="TOP.html">TOP.html</a>
184185
</p>
185186
EOF
186187
}
@@ -270,6 +271,8 @@ Here are some summary tables. **Click** on the column headers to sort:
270271
- [Delta OSH](DELTA-osh.html)
271272
- Compare each shell's passing count vs. OSH
272273
274+
[tree.html](tree.html)
275+
273276
### Notes and Caveats
274277
275278
- Some tests may fail for innocuous reasons, e.g. printing `'$'` versus `\$`
@@ -314,9 +317,10 @@ TODO: Add other shells, and be more specific about versions.
314317
315318
### More Comparisons
316319
320+
- [Binary Sizes](binary-sizes.txt)
321+
317322
Possibly TODO
318323
319-
- Binary size
320324
- Build times
321325
- Lines of code?
322326
- [Oils has a "compressed" implementation](https://www.oilshell.org/blog/2024/09/line-counts.html)
@@ -358,7 +362,7 @@ EOF
358362
}
359363

360364
write-compare-html() {
361-
local spec_subdir='compat'
365+
local spec_subdir=${1:-'compat'}
362366
local dir=_tmp/spec/$spec_subdir
363367

364368
local out=$dir/TOP.html
@@ -369,16 +373,25 @@ write-compare-html() {
369373
return
370374
fi
371375

372-
write-summary-html PASSING "$@"
373-
write-summary-html DELTA-osh "$@"
374-
write-summary-html DELTA-bash "$@"
376+
write-summary-html PASSING "$spec_subdir"
377+
write-summary-html DELTA-osh "$spec_subdir"
378+
write-summary-html DELTA-bash "$spec_subdir"
379+
380+
echo
381+
test/spec-compat.sh binary-sizes | tee $dir/binary-sizes.txt
382+
}
383+
384+
write-tree-html() {
385+
local dir=${1:-_tmp/spec/compat}
386+
tree -H './' -T 'Files in spec-compat Report' --charset=ascii $dir \
387+
> $dir/tree.html
375388
}
376389

377390
# TODO: Publish this script
378391
multi() { ~/git/tree-tools/bin/multi "$@"; }
379392

380393
deploy() {
381-
local epoch=${1:-2025-06-19}
394+
local epoch=${1:-2025-06-26}
382395

383396
local dest=$PWD/../pages/spec-compat/$epoch
384397

@@ -393,6 +406,8 @@ deploy() {
393406
find spec/compat -name '*.html' -o -name '*.tsv' | multi cp $dest/renamed-tmp
394407
popd
395408

409+
write-tree-html $dest/renamed-tmp/spec/compat
410+
396411
# Work around Jekyll rule for Github pages
397412
#mv -v $dest/_tmp $dest/renamed-tmp
398413

test/spec-compat.sh

Lines changed: 88 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
#
55
# Usage:
66
# test/spec-compat.sh <function name>
7+
#
8+
# Examples:
9+
# $0 build-static-oils # Build Oils binaries
10+
# $0 build-brush T # Pull and build
11+
# $0 build-sush T # Pull and build
12+
# $0 osh-all # Run spec tests, and make report
13+
# # Includes binary size report
714

815
: ${LIB_OSH=stdlib/osh}
916
source $LIB_OSH/bash-strict.sh
@@ -18,12 +25,6 @@ source test/spec-common.sh
1825
OSH_TARGET=_bin/cxx-asan/osh
1926
OSH=$PWD/$OSH_TARGET
2027

21-
# To compare against:
22-
# - toysh
23-
# - brush
24-
# - rusty_bash
25-
# - ksh93 - Debian package
26-
2728
# Metrics
2829
# - binary size - stripped
2930
# - lines of source code - I think we get this from DWARF debug info
@@ -121,28 +122,58 @@ build-sush() {
121122
popd
122123
}
123124

125+
build-static-oils() {
126+
devtools/release-native.sh make-tar
127+
128+
# Static binary with glibc
129+
build/static-oils.sh
130+
131+
# Static binary with musl libc
132+
test/alpine.sh build-static-musl
133+
}
134+
124135
binary-sizes() {
125-
local oils=_bin/cxx-opt/bin/oils_for_unix.mycpp.stripped
126-
ninja $oils
136+
local oils_dynamic=_bin/cxx-opt/bin/oils_for_unix.mycpp.stripped
137+
ninja $oils_dynamic
127138

128-
pushd $BRUSH_DIR
139+
pushd $BRUSH_DIR >/dev/null
129140
local out=target/release/brush.stripped
130141
strip -o $out target/release/brush
131142
local brush=$BRUSH_DIR/$out
132-
popd
143+
popd >/dev/null
133144

134-
pushd $SUSH_DIR
145+
pushd $SUSH_DIR >/dev/null
135146
local out=target/release/sush.stripped
136147
strip -o $out target/release/sush
137148
local sush=$SUSH_DIR/$out
138-
popd
149+
popd >/dev/null
150+
151+
local -a oils=(
152+
$oils_dynamic
153+
154+
# 2.4 M musl libc
155+
_tmp/musl-libc/oils-for-unix-static.stripped
156+
157+
# 3.4 MB with glibc
158+
_bin/cxx-opt-sh/oils-for-unix-static.stripped
159+
)
160+
local -a other=(
161+
162+
$brush $sush $TOYBOX_DIR/sh
163+
# our bash isn't stripped
164+
# $(which bash) $(which dash) $(which mksh) $(which ksh)
165+
)
139166

140167
echo
141-
ls -l --si $oils $brush $sush $TOYBOX_DIR/sh
168+
ls -l --si --sort=none "${oils[@]}"
169+
echo
170+
ls -l --si --sort=none "${other[@]}"
142171

143-
# These aren't dynamically linked to GNU readline, or libstdc++
172+
# Rust binaries aren't dynamically linked to GNU readline, or libstdc++
173+
echo
174+
ldd "${oils[@]}" || true # fails if not dynamic
144175
echo
145-
ldd $oils $brush $sush $TOYBOX_DIR/sh
176+
ldd "${other[@]}"
146177
}
147178

148179
symbols() {
@@ -188,39 +219,56 @@ install-geiger() {
188219
cargo install --locked cargo-geiger
189220
}
190221

191-
# This is DESTRUCTIVE
192-
geiger-report() {
193-
if true; then
194-
pushd ../../shells/brush
222+
# This is DESTRUCTIVE for some reason.
223+
# It cleans the build and rebuilds every time.
224+
geiger-brush() {
225+
. ~/.cargo/env
226+
227+
pushd ../../shells/brush
195228

196-
. ~/.cargo/env
229+
pushd brush-core
230+
cargo geiger
231+
popd
197232

198-
# doesn't work
199-
#time cargo geiger --workspace
200-
#time cargo geiger --package brush-core --package brush-parser
233+
pushd brush-interactive
234+
cargo geiger
235+
popd
201236

202-
popd
203-
fi
237+
pushd brush-parser
238+
cargo geiger
239+
popd
240+
241+
pushd brush-shell
242+
cargo geiger
243+
popd
244+
245+
# doesn't work
246+
#time cargo geiger --workspace
247+
#time cargo geiger --package brush-core --package brush-parser
204248

205-
if false; then
206-
pushd ../../shells/rusty_bash
249+
#time cargo geiger --workspace
207250

208-
. ~/.cargo/env
251+
popd
252+
}
253+
254+
geiger-sush() {
255+
. ~/.cargo/env
209256

210-
# this cleans the build
211-
#
212-
# Functions Expressions Impls Traits Methods
213-
# 181/1056 9377/45040 114/158 30/32 463/2887
214-
#
215-
# x/y
216-
# x = unsafe used by build
217-
# y = unsafe in crate
257+
pushd ../../shells/rusty_bash
218258

219-
# ~7 seconds
220-
time cargo geiger
259+
# this cleans the build
260+
#
261+
# Functions Expressions Impls Traits Methods
262+
# 181/1056 9377/45040 114/158 30/32 463/2887
263+
#
264+
# x/y
265+
# x = unsafe used by build
266+
# y = unsafe in crate
221267

222-
popd
223-
fi
268+
# ~7 seconds
269+
time cargo geiger
270+
271+
popd
224272
}
225273

226274
#

0 commit comments

Comments
 (0)