Commit Graph

2286 Commits (master)

Author SHA1 Message Date
Justine Tunney b4dffa4726 Add more win32 definitions to cosmopolitan.a 2021-01-27 22:18:23 -08:00
Justine Tunney efc66f8525 Fix our remarkable 184kb x86_64 emulator
Here's how to build it from source and try it out!

    m=tiny
    make -j18 MODE=$m o/$m/tool/build/tinyemu.com
    make -j18 MODE=$m o/$m/tool/viz/deathstar.com
    o/$m/tool/build/tinyemu.com o/$m/tool/viz/deathstar.com
2021-01-27 20:02:23 -08:00
Justine Tunney d7ac16a9ed Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
Justine Tunney de703b182c Fix amalgamated release objects for older distros
We now pass -Wa,--nocompress-debug-sections to GCC so it won't use ELF
compression, since that causes "unable to initialize decompress status
for section .debug_aranges" when linked with past releases of binutils

Please note: this issue only impacts users who download cosmopolitan.a
from the website. Building from source isn't impacted, since we vendor
GCC 9.2.0 and Binutils 2.32 static binaries in the third_party folder.

Thanks @vshymanskyy for reporting this!
See #32
2021-01-27 16:21:01 -08:00
Justine Tunney 45b72485ad Fix XNU / FreeBSD / OpenBSD / RHEL5 / NT bugs
For the first time ever, all tests in this codebase now pass, when
run automatically on macos, freebsd, openbsd, rhel5, rhel7, alpine
and windows via the network using the runit and runitd build tools

- Fix vfork exec path etc.
- Add XNU opendir() support
- Add OpenBSD opendir() support
- Add Linux history to syscalls.sh
- Use copy_file_range on FreeBSD 13+
- Fix system calls with 7+ arguments
- Fix Windows with greater than 16 FDs
- Fix RUNIT.COM and RUNITD.COM flakiness
- Fix OpenBSD munmap() when files are mapped
- Fix long double so it's actually long on Windows
- Fix OpenBSD truncate() and ftruncate() thunk typo
- Let Windows fcntl() be used on socket files descriptors
- Fix Windows fstat() which had an accidental printf statement
- Fix RHEL5 CLOCK_MONOTONIC by not aliasing to CLOCK_MONOTONIC_RAW

This is wonderful. I never could have dreamed it would be possible
to get it working so well on so many platforms with tiny binaries.

Fixes #31
Fixes #25
Fixes #14
2021-01-25 18:31:17 -08:00
Justine Tunney c20dad3534 Fix another bootloader glitch (#20)
Thanks again to @Theldus for reporting this
2021-01-17 17:55:42 -08:00
Justine Tunney 23b1b462c9 Update website documentation html 2021-01-17 17:55:12 -08:00
Justine Tunney 78add3cb17 Fix AR.COM on RHEL7 (#24)
Doing this required improving the copyfd() polyfill needed by
copy_file_range() so it'll work harder to avoid short writes.
2021-01-17 10:28:52 -08:00
Justine Tunney 565edd051f Remove dependency on ragel command 2021-01-17 09:42:52 -08:00
Justine Tunney 92b794002b Fix pmovmskb mnemonic in memeqmask
This change unbreaks test/libc/nexgen32e/memeqmask_test.c which appears
to currently be the only reference to this api. It was originally meant
to be used for speeding up terminal video rendering. We might delete it

Fixes #26
2021-01-16 21:52:14 -08:00
Justine Tunney 8fa47acecc Fix memcpy on sandybridge and ivybridge
This bug impacts folks who purchased Intel chips made in 2011-2012.
We're now using `vxorps` instead of `vpxor` which is great since it
means we do not need to change `X86_HAVE(AVX)` to `X86_HAVE(AVX2)`,
because AVX2 is only available on Haswell and later.

Fixes #16
2021-01-16 21:36:55 -08:00
Justine Tunney 2ad0d05d31 Avoid mapping above 4gb on Windows 7 x64 (#19)
Windows 7 support is now confirmed to be working. However it comes at
the cost of needing to workaround this tragically oppressive behavior
which is imposed for reasons unknown.

Fixes #19
2021-01-16 19:18:37 -08:00
Justine Tunney f0600a898c Fix metal bugs so deathstar.com runs in qemu (#20)
- Remove XD bit in page tables
- Fix cylinder+head+sector arithmetic
- Implement fstat() for serial file descriptors on metal

Here's how to boot an Actually Portable Executable in QEMU:

    make -j12 o//tool/viz/deathstar.com
    qemu-system-x86_64 -serial stdio -fda o//tool/viz/deathstar.com

Here's a screenshot of DEATHSTAR.COM booted in QEMU:
https://justine.lol/cosmopolitan/cosmo-metal-qemu.png

Thus metal support is in much better shape now, but still incomplete.
Only a few system calls have been polyfilled. To figure out which ones
your program needs, simply boot it in the blinkenlights emulator with a
breakpoint, and press CTRL-C to continue to the system call breakpoint.
If it doesn't break then you should be good. (Note: to emulate normally
you can press 'c' and use CTRL-T and ALT-T to tune the speed.)

    m=tiny
    make -j12 SILENT=0 MODE=$m          \
      o/$m/tool/build/blinkenlights.com \
      o/$m/tool/viz/deathstar.com
    o/$m/tool/build/blinkenlights.com   \
      -r -t -b systemfive.linux         \
      o/$m/tool/viz/deathstar.com

Thank @Theldus for the bug report that made this change possible.
Fixes #20 which explains this change further.
2021-01-16 17:52:15 -08:00
Justine Tunney 58d9659d53 Remove call to SetDefaultDllDirectories (#19)
This API isn't present in Windows 7 SP1.
2021-01-16 17:50:29 -08:00
Justine Tunney eb5d094715 Disable spawnve_test (#14)
Multiple users have reported that this test fails, for reasons that
are currently unknown. It's possible that, some type of environment
variable configuration, e.g. PATH, CC, etc. is causing the failure.

Once the root cause is identified and addressed we'll re-enable it.
Anyone who is able to help us do that, please comment on the issue.
2021-01-16 12:43:06 -08:00
Justine Tunney 58d5cf1c27 Link zipos into NESEMU1
A regression occurred where LIBC_ZIPOS support wasn't being properly
linked into Cosmopolitan NESEMU1. Main modules that link zip support
need to have the following declaration to guaranteed zip: polyfills:

    STATIC_YOINK("zip_uri_support");

Doing that, means system calls such as open(), mmap(), fstat(), etc.
will do the right thing when encountering zip: prefixed URLs. Please
also note that in the near future we're going to change it to zip://
after more closely examining the relevant URI RFCs.

Fixes #28
Closes #29
Thanks @nikhedonia for the report!
2021-01-16 12:32:54 -08:00
Justine Tunney 9f68d6eee9 Fix link order in cosmopolitan.a
It turned out that the linker was doing the wrong with the amalgamation
library concerning weak stubs. A regression test has been added and new
binaries have been uploaded to https://justine.lol/cosmopolitan/

Ideally this should be fixed by building a tool that turns multiple .a
files into a single .a file with deduplication. As a workaround for now
the cosmopolitan.a build is restructured to not include LIBC_STUBS which
meant technical debt needed to be paid off where non-stub interfaces
were moved to LIBC_INTRIN and LIBC_NEXGEN32E.

Thank @PerfectProductions in #31 for the report!
2021-01-16 12:05:41 -08:00
Justine Tunney 04f1d89f84 Replace .pushsection directives (#30) 2021-01-10 13:36:31 -08:00
Justine Tunney 28316891e9 Fix discrepancy in chibicc ND_NOT codegen (#21) 2020-12-30 00:32:51 -08:00
Justine Tunney 79ff43adf5 Apply touchups to last commit 2020-12-29 23:52:27 -08:00
Justine Tunney 81ef162703 Create integrated assembler for chibicc
All we need now to complete the triforce is an integrated linker. That
way Cosmpolitan will let C be a "build anywhere run anywhere" language.
2020-12-29 22:40:59 -08:00
Justine Tunney 5eddadafbd Fix strtol 2020-12-29 22:40:52 -08:00
Justine Tunney 1df136323b Add timingsafe_memcmp #13 2020-12-28 20:01:15 -08:00
Justine Tunney 0e85b136ae Fix Windows 7 support (#19)
This change pays off technical debt with the function -> DLL mappings in
libc/nt/master.sh, which was originally defined based on binary analysis
on Windows 10. It's now been updated so the kernel32/kernelbase/advapi32
imports should be exactly as they are written, on the MSDN documentation
and that wouldn't have been easy without Geoff Chappell's work thank him

https://www.geoffchappell.com/studies/windows/win32/index.htm
2020-12-28 13:52:02 -08:00
Justine Tunney 12065100e1 Add l suffix to yoink nop 2020-12-28 11:38:38 -08:00
Justine Tunney de09bec215 Fix strlcpy 2020-12-27 21:35:38 -08:00
Justine Tunney 37a4c70c36 Change license 2020-12-27 17:18:44 -08:00
Justine Tunney 548dcb9f08 Further refine documentation 2020-12-27 17:05:03 -08:00
Justine Tunney 1bc3a25505 Improve documentation
The Cosmo API documentation page is pretty good now
https://justine.lol/cosmopolitan/documentation.html
2020-12-27 07:02:35 -08:00
Justine Tunney 13437dd19b Auto-generate some documentation 2020-12-26 02:09:07 -08:00
Justine Tunney 117d0111ab Fix space path bug in printvideo.com (#11)
In addition to removing the URI downloading support. It was originally
intended to have this command play YouTube videos too but that support
was never completed. Latest release binaries can be obtained via:

    wget https://justine.lol/printvideo.com      # 284k ape executable
    wget https://justine.lol/printvideo.com.dbg
2020-12-24 16:13:13 -08:00
Justine Tunney 830334d767 Hunt down some small bugs 2020-12-24 16:01:48 -08:00
Justine Tunney 95b142e4e5 Make minor improvements 2020-12-23 23:42:56 -08:00
Justine Tunney 04caf6f9ad Delete unused third party projects 2020-12-19 13:49:39 -08:00
Justine Tunney 113eeabd85 Fix another build error
It would appear o/depend can't help with generated files.
2020-12-19 13:47:51 -08:00
Justine Tunney 14d0292732 Fiddle around with chibicc 2020-12-19 13:39:09 -08:00
Justine Tunney 921f63da68 Fix build bug 2020-12-19 13:37:31 -08:00
Justine Tunney b562d6fdb3 Make minor improvements 2020-12-19 11:21:04 -08:00
Justine Tunney 1fc91f3580 Fold conv package into fmt
Both packages had nearly identical dependency requirements, so merging
them should help reduce the complexity of the build graph.
2020-12-09 16:52:00 -08:00
Justine Tunney 978b7858f9 Fix minor foss build issue 2020-12-09 14:40:35 -08:00
Justine Tunney 15280753e2 Integrate more chibicc changes 2020-12-09 13:53:02 -08:00
Justine Tunney 2ed7956be4 Integrate upstream chibicc changes 2020-12-09 04:13:14 -08:00
Justine Tunney 9df2cef4c4 Enhance chibicc 2020-12-09 04:00:48 -08:00
Justine Tunney 8da931a7f6 Add chibicc
This program popped up on Hacker News recently. It's the only modern
compiler I've ever seen that doesn't have dependencies and is easily
modified. So I added all of the missing GNU extensions I like to use
which means it might be possible soon to build on non-Linux and have
third party not vendor gcc binaries.
2020-12-06 16:20:21 -08:00
Justine Tunney e44a0cf6f8 Make improvements 2020-12-01 03:43:40 -08:00
Justine Tunney 3e4fd4b0ad Add epoll and do more release readiness changes
This change also pays off some of the remaining technical debt with
stdio, file descriptors, and memory managemnt polyfills.
2020-11-28 12:01:51 -08:00
Justine Tunney a9ea949df8 Rename NOTICE to LICENSE (#10) 2020-11-28 02:08:08 -08:00
Justine Tunney ea0b5d9d1c Get Cosmopolitan into releasable state
A new rollup tool now exists for flattening out the headers in a way
that works better for our purposes than cpp. A lot of the API clutter
has been removed. APIs that aren't a sure thing in terms of general
recommendation are now marked internal.

There's now a smoke test for the amalgamation archive and gigantic
header file. So we can now guarantee you can use this project on the
easiest difficulty setting without the gigantic repository.

A website is being created, which is currently a work in progress:
https://justine.storage.googleapis.com/cosmopolitan/index.html
2020-11-25 08:19:00 -08:00
Justine Tunney dba7552c1e Add Conway's Game of Life 2020-11-18 08:26:03 -08:00
Justine Tunney db33973e0a Get fork() working on Windows
This is done without using Microsoft's internal APIs. MAP_PRIVATE
mappings are copied to the subprocess via a pipe, since Microsoft
doesn't want us to have proper COW pages. MAP_SHARED mappings are
remapped without needing to do any copying. Global variables need
copying along with the stack and the whole heap of anonymous mem.
This actually improves the reliability of the redbean http server
although one shouldn't expect 10k+ connections on a home computer
that isn't running software built to serve like Linux or FreeBSD.
2020-11-13 03:14:39 -08:00