Skip to content

Commit

Permalink
Get codebase completely working with LLVM
Browse files Browse the repository at this point in the history
You can now build Cosmopolitan with Clang:

    make -j8 MODE=llvm
    o/llvm/examples/hello.com

The assembler and linker code is now friendly to LLVM too.
So it's not needed to configure Clang to use binutils under
the hood. If you love LLVM then you can now use pure LLVM.
  • Loading branch information
jart committed Feb 9, 2021
1 parent 0e36cb3 commit e75ffde
Show file tree
Hide file tree
Showing 4,528 changed files with 7,787 additions and 11,651 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ include third_party/gdtoa/gdtoa.mk # │ You can finally call malloc()
include libc/time/time.mk #
include libc/alg/alg.mk #
include libc/stdio/stdio.mk #
include third_party/f2c/f2c.mk #
include third_party/blas/blas.mk #
include net/net.mk #
include libc/log/log.mk #
include dsp/core/core.mk #
Expand Down Expand Up @@ -203,7 +201,7 @@ CHECKS = $(foreach x,$(PKGS),$($(x)_CHECKS))

bins: $(BINS)
check: $(CHECKS)
test: $(TESTS)
test: $(TESTS) all
depend: o/$(MODE)/depend
tags: TAGS HTAGS

Expand Down
43 changes: 26 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

[Cosmopolitan Libc](https://justine.lol/cosmopolitan/index.html) makes C
a build-once run-anywhere language, like Java, except it doesn't need an
interpreter or virtual machine. Instead, it reconfigures stock GCC to
output a POSIX-approved polyglot format that runs natively on Linux +
Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS with the best possible
performance and the tiniest footprint imaginable.
interpreter or virtual machine. Instead, it reconfigures stock GCC and
Clang to output a POSIX-approved polyglot format that runs natively on
Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS with the best
possible performance and the tiniest footprint imaginable.

## Background

Expand All @@ -18,24 +18,33 @@ libc](https://justine.lol/cosmopolitan/index.html) website. We also have

## Getting Started

Cosmopolitan can be compiled from source on any Linux distro.
If you're doing your development work on Linux or BSD then you need just
five files to get started:

```sh
wget https://justine.lol/cosmopolitan/cosmopolitan-amalgamation-0.1.2.zip
unzip cosmopolitan-amalgamated-0.1.2.zip
echo 'main() { printf("hello world\n"); }' >hello.c
gcc -g -O -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone \
-o hello.com.dbg hello.c -fuse-ld=bfd -Wl,-T,ape.lds \
-include cosmopolitan.h crt.o ape.o cosmopolitan.a
objcopy -S -O binary hello.com.dbg hello.com
./hello.com
```

If you're developing on Windows or MacOS then you need to download an
x86_64-pc-linux-gnu toolchain beforehand. See the [Compiling on
Windows](https://justine.lol/cosmopolitan/windows-compiling.html)
tutorial. It's needed because the ELF object format is what makes
universal binaries possible.

Cosmopolitan can also be compiled from source on any Linux distro.

```sh
wget https://justine.lol/cosmopolitan/cosmopolitan-0.1.2.tar.gz
tar xf cosmopolitan-0.1.2.tar.gz # see releases page
cd cosmopolitan-0.1.2
make -j16
o//examples/hello.com
find o -name \*.com | xargs ls -rShal | less
```

Alternatively you can use the release binaries:

```sh
unzip cosmopolitan-amalgamated-0.1.2.zip # see releases page
echo 'main() { printf("hello world\n"); }' >hello.c
gcc -g -O -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc \
-o hello.com.dbg hello.c -Wl,--gc-sections -Wl,-z,max-page-size=0x1000 -fuse-ld=bfd \
-Wl,-T,ape.lds -include cosmopolitan.h crt.o ape.o cosmopolitan.a
objcopy -SO binary hello.com.dbg hello.com
./hello.com
```
Loading

0 comments on commit e75ffde

Please sign in to comment.