Skip to content

Commit

Permalink
Include more programs in cosmocc
Browse files Browse the repository at this point in the history
The Cosmopolitan Compiler Collection now includes the following programs

- `ar.ape` is a faster alternative to `ar rcsD` for creating determistic
  static archives. It's ~10x faster than GNU because it isn't quadratic.
  It'll even outperform LLVM ar by 2x, thanks to writev/copy_file_range.

- `sha256sum.ape` is a faster alternative to the `sha256sum` command. It
  goes 2x faster since it leverages vectorized assembly implementations.

- `resymbol` is a brand new program we invented, like objcopy, that lets
  you rename all the global symbols in a .o file to have a new suffix or
  prefix. In the future, this will be used by cosmocc automatically when
  building -O3 math kernels, that need to be vectorized for all hardware

- `gzip.ape` is a faster version of the `gzip` command, that is included
  by most Linux distros. It gains better performance using Chromium Zlib
  which, once again, includes highly optimized assembly, that Mark Adler
  won't merge into the official MS-DOS compatible zlib codebase.

- `cocmd` is the cosmopolitan shell. It can function as a faster `sh -c`
  alternative than bash and dash as the `SHELL = /opt/cosmocc/bin/cocmd`
  at the top of your Makefile. Please note you should be using the cosmo
  fork of GNU make (already included), since normal make won't recognize
  this as a bourne-compatible shell and remove the execve() optimization
  which makes things slower. In some ways that's true. This doesn't have
  a complete POSIX shell implementation. However it's enough for cosmo's
  mono repo. It also implements faster behaviors in some respects.

The following programs are also introduced, which aren't as interesting.
The main reason why they're here is so Cosmopolitan's mono repo shall be
able to remove build/bootstrap/ in future editions. That way we can keep
build utilities better up to date, without bloating the git history much

- `chmod.ape` for hermeticity
- `cp.ape` for hermeticity
- `echo.ape` for hermeticity
- `objbincopy` is an objcopy-like tool that's used to build ape loader
- `package.ape` is used for strict dependency checking of object graph
- `rm.ape` for hermeticity
- `touch.ape` for hermeticity
  • Loading branch information
jart committed Jul 1, 2024
1 parent 78d3b86 commit ca4cf67
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 178 deletions.
Binary file removed build/bootstrap/rollup
Binary file not shown.
1 change: 1 addition & 0 deletions third_party/make/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ is_bourne_compatible_shell (const char *path)
"sh",
"bash",
"dash",
"cocmd",
"ksh",
"rksh",
"zsh",
Expand Down
177 changes: 0 additions & 177 deletions tool/build/rollup.c

This file was deleted.

35 changes: 34 additions & 1 deletion tool/cosmocc/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ make -j64 m=$AMD64 \
o/$AMD64/tool/build/zipobj.dbg \
o/$AMD64/tool/build/apelink.dbg \
o/$AMD64/tool/build/pecheck.dbg \
o/$AMD64/tool/build/ar.dbg \
o/$AMD64/tool/build/chmod.dbg \
o/$AMD64/tool/build/cocmd.dbg \
o/$AMD64/tool/build/compile.dbg \
o/$AMD64/tool/build/cp.dbg \
o/$AMD64/tool/build/echo.dbg \
o/$AMD64/tool/build/gzip.dbg \
o/$AMD64/tool/build/objbincopy.dbg \
o/$AMD64/tool/build/package.dbg \
o/$AMD64/tool/build/rm.dbg \
o/$AMD64/tool/build/touch.dbg \
o/$AMD64/tool/build/sha256sum.dbg \
o/$AMD64/tool/build/resymbol.dbg \
o/$AMD64/third_party/make/make.dbg \
o/$AMD64/third_party/ctags/ctags.dbg

Expand All @@ -64,6 +77,19 @@ make -j64 m=$ARM64 \
o/$ARM64/tool/build/zipobj.dbg \
o/$ARM64/tool/build/apelink.dbg \
o/$ARM64/tool/build/pecheck.dbg \
o/$ARM64/tool/build/ar.dbg \
o/$ARM64/tool/build/chmod.dbg \
o/$ARM64/tool/build/cocmd.dbg \
o/$ARM64/tool/build/compile.dbg \
o/$ARM64/tool/build/cp.dbg \
o/$ARM64/tool/build/echo.dbg \
o/$ARM64/tool/build/gzip.dbg \
o/$ARM64/tool/build/objbincopy.dbg \
o/$ARM64/tool/build/package.dbg \
o/$ARM64/tool/build/rm.dbg \
o/$ARM64/tool/build/touch.dbg \
o/$ARM64/tool/build/sha256sum.dbg \
o/$ARM64/tool/build/resymbol.dbg \
o/$ARM64/third_party/make/make.dbg \
o/$ARM64/third_party/ctags/ctags.dbg

Expand Down Expand Up @@ -146,7 +172,9 @@ cp -af tool/cosmocc/bin/* "$OUTDIR/bin/"
cp -f o/$AMD64/ape/ape.elf "$OUTDIR/bin/ape-x86_64.elf"
cp -f o/$AMD64/ape/ape.macho "$OUTDIR/bin/ape-x86_64.macho"
cp -f o/$ARM64/ape/ape.elf "$OUTDIR/bin/ape-aarch64.elf"
for x in assimilate march-native mktemper fixupobj zipcopy apelink pecheck mkdeps zipobj; do

for x in assimilate march-native mktemper fixupobj zipcopy apelink pecheck mkdeps zipobj \
ar chmod cocmd cp echo gzip objbincopy package rm touch sha256sum resymbol; do
ape $APELINK \
-l o/$AMD64/ape/ape.elf \
-l o/$ARM64/ape/ape.elf \
Expand All @@ -155,6 +183,11 @@ for x in assimilate march-native mktemper fixupobj zipcopy apelink pecheck mkdep
o/$AMD64/tool/build/$x.dbg \
o/$ARM64/tool/build/$x.dbg
done

for x in ar chmod cp echo gzip package rm touch sha256sum; do
mv "$OUTDIR/bin/$x" "$OUTDIR/bin/$x.ape"
done

for x in make ctags; do
ape $APELINK \
-l o/$AMD64/ape/ape.elf \
Expand Down

0 comments on commit ca4cf67

Please sign in to comment.