Get aarch64 hello world working

$ m=aarch64-tiny
    $ make -j8 m=$m o/$m/tool/hello/hello.com o/third_party/qemu/qemu-aarch64
    $ o/third_party/qemu/qemu-aarch64 o/$m/tool/hello/hello.com
    hello world
    $ ls -hal o/$m/tool/hello/hello.com
    -rwxr-xr-x 1 jart jart 4.0K May  9 05:04 o/aarch64-tiny/tool/hello/hello.com
This commit is contained in:
Justine Tunney 2023-05-09 02:35:05 -07:00
parent e5e3cdf447
commit ae0ee59614
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
174 changed files with 1454 additions and 851 deletions

12
tool/hello/hello.c Normal file
View file

@ -0,0 +1,12 @@
#include "libc/calls/calls.h"
#include "libc/str/str.h"
// hello world with minimal build system dependencies
static ssize_t Write(int fd, const char *s) {
return write(fd, s, strlen(s));
}
int main(int argc, char *argv[]) {
Write(1, "hello world\n");
}

39
tool/hello/hello.mk Normal file
View file

@ -0,0 +1,39 @@
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
PKGS += TOOL_HELLO
TOOL_HELLO_SRCS := $(wildcard tool/hello/*.c)
TOOL_HELLO_OBJS = $(TOOL_HELLO_SRCS:%.c=o/$(MODE)/%.o)
TOOL_HELLO_COMS = $(TOOL_HELLO_SRCS:%.c=o/$(MODE)/%.com)
TOOL_HELLO_BINS = $(TOOL_HELLO_COMS) $(TOOL_HELLO_COMS:%=%.dbg)
TOOL_HELLO_DIRECTDEPS = \
LIBC_CALLS \
LIBC_INTRIN \
LIBC_NEXGEN32E \
LIBC_RUNTIME \
LIBC_STR \
LIBC_STUBS
TOOL_HELLO_DEPS := \
$(call uniq,$(foreach x,$(TOOL_HELLO_DIRECTDEPS),$($(x))))
o/$(MODE)/tool/hello/hello.pkg: \
$(TOOL_HELLO_OBJS) \
$(foreach x,$(TOOL_HELLO_DIRECTDEPS),$($(x)_A).pkg)
o/$(MODE)/tool/hello/%.com.dbg: \
$(TOOL_HELLO_DEPS) \
o/$(MODE)/tool/hello/%.o \
o/$(MODE)/tool/hello/hello.pkg \
$(CRT) \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
$(TOOL_HELLO_OBJS): \
$(BUILD_FILES) \
tool/hello/hello.mk
.PHONY: o/$(MODE)/tool/hello
o/$(MODE)/tool/hello: $(TOOL_HELLO_BINS) $(TOOL_HELLO_CHECKS)