Commit graph

2074 commits

Author SHA1 Message Date
Justine Tunney
91de6f1f5d
Release Cosmopolitan 3.2.2 2024-01-05 21:00:22 -08:00
Justine Tunney
fad1279c61
Make cosmo_dlopen() safer and faster
If cosmo_dlopen() is linked on AMD64 then the runtime will switch to
using %gs for thread-local storage. This eliminates the need for the
imported symbol trampoline. It's now safer to pass function pointers
back and forth with imported libraries. Your program gets recompiled
at runtime to make it happen and the overhead is a few milliseconds.
2024-01-05 20:42:19 -08:00
Jōshin
c0eacf2eb1
clang-format 2024-01-05 23:21:52 -05:00
Justine Tunney
c60b150fcf
Release Cosmopolitan v3.2.1 2024-01-05 15:36:57 -08:00
Jōshin
80ec6c9283
Try to detect kernel version for P flag (#1059) 2024-01-05 15:19:46 -08:00
Justine Tunney
2d93788ce3
Fix --ftrace with cosmo_dlopen()
This change ensures function call logging won't crash the process when
cosmo_dlopen() is called.
2024-01-05 15:13:07 -08:00
Jōshin
15548b523c
Cleanup apeinstall.sh (#1057) 2024-01-05 13:45:14 -08:00
Jōshin
412a200ae4
Support binfmt_misc P flag in APE loader (#1058)
This allows ape to automatically preserve `argv[0]` [as of Linux kernel
5.12][0] if the [binfmt_misc][1] registration contains the P flag.

This also removes may_path_search, which was identical to the literally
flag in usage. As a result, FindCommand is subsumed into Commandv.

[0]: https://patchew.org/QEMU/20210222105004.1642234-1-laurent@vivier.eu/
[1]: https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html
2024-01-05 12:35:01 -08:00
Justine Tunney
44a463e4d2
Invent *cosmo_dltramp() function 2024-01-05 09:11:51 -08:00
Justine Tunney
0de6a08988
Upgrade mono repo to cosmocc 3.2
The toolchain will now be downloaded going forward from multiple pinned
URLs which have shasums. Either wget or curl must be installed.

This change unblocks #1053
2024-01-05 08:02:04 -08:00
Paul Kulchenko
a334f9cc33
Update redbean ProgramDirectory to return a list of previously set directories (#1021) 2024-01-05 02:17:55 -08:00
Jōshin
3315b6ef11
Store StrlenDevFd in n (#1056) 2024-01-04 23:17:37 -05:00
Justine Tunney
e93c8c4f8f
Fix typo 2024-01-04 13:59:36 -08:00
Justine Tunney
0e49bed660
Support 40 cosmo_dlopen() function parameters
Our dynamic linking implementation is now able to support functions with
dozens of parameters. In addition to having extra integral arguments you
can now pass vector registers using intrinsic types. Lastly, you can now
return multiple values, which is useful for functions returning structs.
2024-01-04 13:41:26 -08:00
Justine Tunney
a3deef70c2
Release Cosmopolitan v3.2 2024-01-04 09:39:48 -08:00
Justine Tunney
873069fcd7
Fix -Xaarch64 in cosmocc
It's now possible to pass flags like -Xaarch64-march=armv8.2-a+dotprod
so that cosmocc will use newer ARM ISAs. For AMD64 there's another one
worth mentioning, which looks like this: -Xx86_64-mssse3
2024-01-04 07:22:05 -08:00
Justine Tunney
3864f78b88
Give GNU Make limitless stacks 2024-01-04 03:26:26 -08:00
Justine Tunney
796148790f
Remove hard coded paths from APE bootloader
This increases risk of fork bomb but is needed to support the NixOS.
Upstream dependencies of APE (uname, mkdir, dd, chmod, gzip, and mv)
will be removed from releases, and deleted from the cosmo.zip server

See #12
2024-01-03 17:55:19 -08:00
Justine Tunney
34ed1fcbea
Fix bugs with DNS library on Windows 2024-01-03 17:39:57 -08:00
Justine Tunney
1bb52c223b
Add missing build dependency 2024-01-03 17:04:21 -08:00
Justine Tunney
31dcdefaa8
Update bootstrap binaries
It's now possible to build the monorepo on FreeBSD ARM64.
2024-01-03 17:03:51 -08:00
Jōshin
2902b76168
mmake gets smarter about locating make
- Check `$COSMOCC`, defaulting to `/opt/cosmocc`.

- Try to get the full path of the repo `make.com`. I'm not aware of
  a way of getting the path that defines a zsh function, so the best
  fallback available is `$PWD`.
2024-01-01 23:34:35 -05:00
Justine Tunney
307823ae00
Upgrade to superconfigure z0.0.29 2024-01-01 19:31:58 -08:00
Jōshin
9801f2d1db
Remove COSMOPOLITAN_PROGRAM_EXECUTABLE (#1047) 2024-01-01 07:25:16 -08:00
Jōshin
68dbe5312f
Prepend getcwd to exename early in init (#1048) 2024-01-01 07:23:23 -08:00
Justine Tunney
2f89c2482a
Delete some dead code 2024-01-01 00:13:16 -08:00
Justine Tunney
9e6faa5256
Fix --ftrace on Windows 2024-01-01 00:00:42 -08:00
Jōshin
b02d13ccde
Re-enable/fix non-argv[0] exe name tests (#1046) 2023-12-31 11:53:15 -08:00
Justine Tunney
81949f038e
Mint APE Loader v1.10 2023-12-31 11:43:13 -08:00
Jōshin
c9550afe5e
Fix loader usage, shave off a few bytes (#1016)
* Remove -f from loader usage

-f was removed in 1.5. As there is now only one flag, a couple more
bytes can be shaved off as well.

* Further loader golf

Shaves off a few bytes, paying for the cost of `RealPath` and then some
on x86_64 and offsetting some of the cost to aarch64.

* Shave off a few more bytes

Removes `-h` and flags from usage. Keeps flag-parsing logic the same,
i.e. still accepts `-h` / `--help`. Only difference is what fd and rc
the usage uses.

Still over 1k north of 8192.
2023-12-31 11:33:42 -08:00
Jōshin
10b4693e37
Sanity-check set-id interpreter script paths (#1029) 2023-12-31 07:46:27 -08:00
Jōshin
14fe83facd
aarch64 loader passes os (#1042)
* Reorder Launch arguments, pass aarch64 os

Third and fourth arguments are now identical between cosmo and Launch.
By passing sp as argument 4, we save a bit of register juggling.

Fourth argument (os) is now always passed by the loader on aarch64. It
is not yet processed by cosmo. Pushing this change separately, as the
cosmo side turns out to be somewhat more involved.

* cosmo2 receives os from loader

FreeBSD aarch64 now traps early rather than pretending to be Linux.
o/aarch64/examples/env.com still works on Linux and Xnu.
2023-12-31 06:42:36 -08:00
Justine Tunney
d8ad34686a
Implement issetugid() on NetBSD 2023-12-30 14:58:16 -08:00
Justine Tunney
83107f78ed
Introduce FreeBSD ARM64 support
It's 100% passing test fleet. Solid as a rock.
2023-12-29 20:14:02 -08:00
Justine Tunney
43fe5956ad
Use DNS implementation from Musl Libc
Now that our socket system call polyfills are good enough to support
Musl's DNS library we should be using that rather than the barebones
domain name system implementation we rolled on our own. There's many
benefits to making this change. So many, that I myself wouldn't feel
qualified to enumerate them all. The Musl DNS code had to be changed
in order to support Windows of course, which looks very solid so far
2023-12-28 23:04:35 -08:00
Justine Tunney
1a28e35c62
Use good locks in dlmalloc
Using mere spin locks causes runitd.com to go painstakingly slow on
NetBSD for reasons that aren't clear yet.
2023-12-28 04:57:36 -08:00
Justine Tunney
80fca1f7c3
Make getprogramexecutablename_test pass fleet 2023-12-28 04:57:36 -08:00
Justine Tunney
8b0e42a31b
Make zipos_test hermetic 2023-12-28 04:57:36 -08:00
Paul Kulchenko
6be9477b9e
Fix redbean to only check additional content types when Lua is present (#1033)
Closes #971
2023-12-28 01:08:19 -08:00
Justine Tunney
ce0143e2a1
Fix madvise() on Windows 2023-12-27 22:41:46 -08:00
Justine Tunney
f51fd97644
Fix MODE=dbg build break 2023-12-27 22:24:27 -08:00
Jōshin
5c35863524
Rename __zipos_free -> __zipos_drop (#1043)
Removes the separate decref function, uses keep/drop in the internal
API.
2023-12-26 12:08:57 -05:00
Jōshin
fd772b9b2a
mmake uses $MAKE if available 2023-12-26 10:27:04 -05:00
Jōshin
4c6f928fbf
Disable argv[0] tests on non-XnuSilicon (#1015)
Adds a TODO explaining the correct condition.
2023-12-24 19:43:32 -05:00
Jōshin
25266b037b
Save a redundant load in zipos read/seek (#1037)
When h->pos has changed to something other than SIZE_MAX, we don't need
the extra atomic load.
2023-12-24 19:40:18 -05:00
Jōshin
bb2602a524
Minor mmake cleanup 2023-12-23 11:09:50 -05:00
mataha
1bc48bc8e4
Update stb (#885)
This commit and, by extension, PR attempts to update `stb` in the most
straightforward way possible as well as include fixes from main repo's
unmerged PRs for cases rearing their ugly heads during everyday usage:

 - stb#1299: stb_rect_pack: Make rect_height_compare a stable sort
 - stb#1402: stb_image: Fix "unused invalid_chunk" with STBI_FAILURE_USERMSG
 - stb#1404: stb_image: Fix gif two_back memory address
 - stb#1420: stb_image: Improve error reporting if file operations fail
   within *_from_file functions
 - stb#1445: stb_vorbis: Few static analyzers fixes
 - stb#1487: stb_vorbis: Fix residue classdata bounding for
   f->temp_memory_required
 - stb#1490: stb_vorbis: Fix broken clamp in codebook_decode_deinterleave_repeat
 - stb#1496: stb_image: Fix pnm only build
 - stb#1497: stb_image: Fix memory leaks if stbi__convert failed
 - stb#1498: stb_vorbis: Fix memory leaks in stb_vorbis
 - stb#1499: stb_vorbis: Minor change to prevent the undefined behavior -
   left shift of a negative value
 - stb#1500: stb_vorbis: Fix signed integer overflow

Includes additional small fixes that I felt didn't warrant a separate PR.
2023-12-22 21:39:27 -08:00
Jōshin
7faffde303
Fix buffer overflow in TryPath (#1035)
Missed this when changing the code back to be like the old version.
com is now a parameter.

The only plausible way to trigger this would be to pass a loader
pathname close to MAX_PATH characters long, and then remove that
path prior to the first sys_faccessat.
2023-12-18 23:02:16 -05:00
Jōshin
85e4c020a3
mmake: formatting + aarch64 tab-completion helper
o/aarch64/* is turned into o/$mode/* in a way analogous to o//, so
aarch64 systems can use tab complete for alternate modes just like
x86_64 can.
2023-12-18 21:29:32 -05:00
Jōshin
1280797db2
Fix indentation, make llvm happy (#1032)
clang says "label at end of switch statement is a C2x extension."
2023-12-18 20:48:33 -05:00