mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
build: use jinx in the build system
now uses jinx to build a cross toolchain, mlibc, bash and the kernel. also made scheduler temporarily run /usr/bin/bash instead of /sbin/init
This commit is contained in:
@@ -1,57 +1,68 @@
|
||||
CC=x86_64-elf-gcc
|
||||
.phony: all kernel
|
||||
all: jinx
|
||||
LDFLAGS="" CFLAGS="" ./jinx build-all
|
||||
./jinx sysroot
|
||||
make sysroot
|
||||
make sysdisk.iso
|
||||
|
||||
jinx:
|
||||
curl https://raw.githubusercontent.com/mintsuki/jinx/trunk/jinx > jinx
|
||||
chmod +x jinx
|
||||
|
||||
|
||||
|
||||
XCC=x86_64-elf-gcc
|
||||
TARGET=x86_64
|
||||
SRCDIR=$(PWD)/src/
|
||||
OBJDIR=$(PWD)/bin/
|
||||
ISO=$(PWD)/boot/$(TARGET)/iso
|
||||
KERNEL=$(ISO)/kernel
|
||||
INITRD=$(ISO)/initrd
|
||||
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
|
||||
KERNELDEPS=$(call rwildcard,bin,*.o)
|
||||
KERNELSRCDEPS=$(call rwildcard,src,*.c)
|
||||
INCLUDEDIR=$(SRCDIR)/include
|
||||
ARCHINCLUDE=$(SRCDIR)/arch/$(TARGET)/include
|
||||
KERNEL=$(ISO)/kernel
|
||||
INITRD=$(ISO)/initrd
|
||||
CFLAGS=-c -ffreestanding -mcmodel=kernel -O2 -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -nostdlib -I$(INCLUDEDIR) -I$(ARCHINCLUDE) --debug
|
||||
LDFLAGS=-ffreestanding -nostdlib -lgcc -Wl,-T,kernel.ld -debug
|
||||
ISO=$(PWD)/boot/$(TARGET)/iso
|
||||
SRCDIR=$(PWD)/src/
|
||||
OBJDIR=$(PWD)/bin/
|
||||
|
||||
sysroot:
|
||||
rm -f $(INITRD)
|
||||
cd sysroot; tar -cf $(INITRD) *
|
||||
|
||||
#TODO make it so we don't need to rebuild everything when a header is changed
|
||||
|
||||
export OBJDIR SRCDIR LDFLAGS CFLAGS INCLUDEDIR TARGET CC
|
||||
export OBJDIR SRCDIR LDFLAGS CFLAGS INCLUDEDIR TARGET XCC
|
||||
|
||||
.phony: all
|
||||
all: $(KERNEL)
|
||||
kernel: $(KERNEL)
|
||||
|
||||
srcdir:
|
||||
$(MAKE) -C src
|
||||
|
||||
$(KERNEL): srcdir $(KERNELSRCDEPS) kernel.ld
|
||||
mkdir -p $(ISO)
|
||||
$(CC) $(LDFLAGS) -o $@ $(call rwildcard,bin,*.o)
|
||||
$(XCC) $(LDFLAGS) -o $@ $(call rwildcard,bin,*.o)
|
||||
|
||||
.phony: rebuildinitrd
|
||||
rebuildinitrd:
|
||||
rm $(INITRD)
|
||||
cd initrd;tar -cf $(INITRD) *
|
||||
|
||||
$(INITRD): $(shell find initrd)
|
||||
cd initrd;tar -cf $(INITRD) *
|
||||
|
||||
sysdisk.iso: $(ISO) $(INITRD)
|
||||
sysdisk.iso: $(ISO)
|
||||
mkdir -p $(ISO)
|
||||
cp liminebg.bmp limine.cfg limine/limine.sys limine/limine-cd.bin limine/limine-cd-efi.bin $(ISO)
|
||||
xorriso -as mkisofs -b limine-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot limine-cd-efi.bin -efi-boot-part --efi-boot-image --protective-msdos-label $(ISO) -o sysdisk.iso
|
||||
|
||||
run: $(KERNEL) sysdisk.iso
|
||||
run:
|
||||
qemu-system-x86_64 -cdrom sysdisk.iso -m 8G -smp cpus=6
|
||||
|
||||
run-kvm: $(KERNEL) sysdisk.iso
|
||||
run-kvm: $(KERNEL)
|
||||
qemu-system-x86_64 -cdrom sysdisk.iso -m 8G -smp cpus=6 -enable-kvm
|
||||
|
||||
test: $(KERNEL) sysdisk.iso
|
||||
test: $(KERNEL)
|
||||
qemu-system-x86_64 -monitor stdio -cdrom sysdisk.iso -d int -no-reboot -no-shutdown -m 8G -smp cpus=6
|
||||
|
||||
test-kvm: $(KERNEL) sysdisk.iso
|
||||
test-kvm: $(KERNEL)
|
||||
qemu-system-x86_64 -monitor stdio -cdrom sysdisk.iso -no-reboot -no-shutdown -m 8G -smp cpus=6 -enable-kvm
|
||||
|
||||
clean:
|
||||
./jinx clean
|
||||
rm -f jinx
|
||||
rm $(call rwildcard,src,*.o) $(KERNELDEPS)
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
# Astral
|
||||
|
||||
Astral is a 64 bit operating system for the x86-64 architecture written in C.
|
||||
|
||||
It's early in its development and is not production ready.
|
||||
As of now it has a few ports like bash and mlibc.
|
||||
|
||||
## Building
|
||||
|
||||
You will need an x86-64-elf-gcc cross compiler and nasm.
|
||||
The build process needs xorriso and curl on the host.
|
||||
|
||||
To build the kernel run ``make``
|
||||
To build the iso run ``make sysdisk.iso``
|
||||
To build the ISO, run ``make``. This will create a file named ``sysdisk.iso``
|
||||
|
||||
## Testing
|
||||
|
||||
There is a make target to run Astral under qemu with kvm. Run ``make test``
|
||||
There are a few targets in the makefile to run Astral with qemu:
|
||||
|
||||
``make run``
|
||||
|
||||
``make run-kvm``
|
||||
|
||||
If you wish to use the qemu monitor, use the test targets:
|
||||
|
||||
``make test``
|
||||
|
||||
``make test-kvm``
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
name=autoconf
|
||||
revision=1
|
||||
from_source=autoconf
|
||||
imagedeps="gcc"
|
||||
|
||||
|
||||
configure() {
|
||||
|
||||
${source_dir}/configure --prefix=${prefix}
|
||||
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
make -j${parallelism}
|
||||
|
||||
}
|
||||
|
||||
install() {
|
||||
|
||||
make install DESTDIR="${dest_dir}"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
name=automake
|
||||
revision=1
|
||||
from_source=automake
|
||||
imagedeps="gcc"
|
||||
hostdeps="autoconf"
|
||||
|
||||
configure() {
|
||||
|
||||
${source_dir}/configure --prefix=${prefix}
|
||||
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
make -j${parallelism}
|
||||
|
||||
}
|
||||
|
||||
install() {
|
||||
|
||||
DESTDIR="${dest_dir}" make install-strip
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
name=binutils-cross
|
||||
revision=1
|
||||
from_source=binutils-cross
|
||||
imagedeps="base-devel gcc"
|
||||
hostdeps="automake autoconf"
|
||||
|
||||
|
||||
configure() {
|
||||
|
||||
|
||||
${source_dir}/configure --target=x86_64-astral --prefix=${prefix} --with-sysroot=${sysroot_dir} --disable-werror
|
||||
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
make -j${parallelism}
|
||||
|
||||
}
|
||||
|
||||
install() {
|
||||
|
||||
make install DESTDIR="${dest_dir}"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
name=gcc-cross
|
||||
revision=1
|
||||
from_source=gcc-cross
|
||||
imagedeps="base-devel"
|
||||
hostdeps="automake autoconf binutils-cross"
|
||||
deps="mlibc-headers"
|
||||
|
||||
configure() {
|
||||
|
||||
${source_dir}/configure --target=x86_64-astral --prefix=${prefix} --with-sysroot=${sysroot_dir} --enable-languages=c,c++
|
||||
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
make all-gcc all-target-libgcc -j7
|
||||
|
||||
}
|
||||
|
||||
install(){
|
||||
|
||||
make DESTDIR="${dest_dir}" install-gcc install-target-libgcc
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
this is just a test
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
export CFLAGS="-O2 -march=x86-64 -pipe -mtune=generic"
|
||||
export CXXFLAGS="${CFLAGS}"
|
||||
@@ -0,0 +1,48 @@
|
||||
diff -ru bash-5.1/externs.h bash-5.1-patched/externs.h
|
||||
--- bash-5.1/externs.h 2020-05-27 11:36:41.000000000 -0300
|
||||
+++ bash-5.1-patched/externs.h 2022-08-20 18:54:03.346557110 -0300
|
||||
@@ -290,7 +290,7 @@
|
||||
#endif /* !HAVE_GETDTABLESIZE */
|
||||
|
||||
#if !defined (HAVE_GETHOSTNAME)
|
||||
-extern int gethostname PARAMS((char *, int));
|
||||
+extern int gethostname PARAMS((char *, size_t));
|
||||
#endif /* !HAVE_GETHOSTNAME */
|
||||
|
||||
extern int getmaxgroups PARAMS((void));
|
||||
diff -ru bash-5.1/subst.c bash-5.1-patched/subst.c
|
||||
--- bash-5.1/subst.c 2020-11-16 12:33:15.000000000 -0300
|
||||
+++ bash-5.1-patched/subst.c 2022-08-20 19:06:46.039884500 -0300
|
||||
@@ -32,6 +32,7 @@
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
+#include <limits.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
diff -ru bash-5.1/support/config.sub bash-5.1-patched/support/config.sub
|
||||
--- bash-5.1/support/config.sub 2020-11-18 16:40:12.000000000 -0300
|
||||
+++ bash-5.1-patched/support/config.sub 2022-08-20 18:20:06.006572931 -0300
|
||||
@@ -1720,7 +1720,7 @@
|
||||
| skyos* | haiku* | rdos* | toppers* | drops* | es* \
|
||||
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
|
||||
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
|
||||
- | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*)
|
||||
+ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | astral*)
|
||||
;;
|
||||
# This one is extra strict with allowed versions
|
||||
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
|
||||
diff -ru bash-5.1/support/shobj-conf bash-5.1-patched/support/shobj-conf
|
||||
--- bash-5.1/support/shobj-conf 2019-12-13 11:51:17.000000000 -0300
|
||||
+++ bash-5.1-patched/support/shobj-conf 2022-09-14 21:09:42.592996760 -0300
|
||||
@@ -79,6 +79,9 @@
|
||||
SHOBJ_LDFLAGS='-shared -bglobalized -unres_symbols ignore'
|
||||
;;
|
||||
|
||||
+astral*-*gcc*)
|
||||
+ SHOBJ_CFLAGS=-fpic
|
||||
+ ;;
|
||||
sunos4*-*gcc*)
|
||||
SHOBJ_CFLAGS=-fpic
|
||||
SHOBJ_LD=/usr/bin/ld
|
||||
@@ -0,0 +1,162 @@
|
||||
diff -ruN binutils-2.39/bfd/config.bfd binutils-2.39-patched/bfd/config.bfd
|
||||
--- binutils-2.39/bfd/config.bfd 2022-07-08 06:46:47.000000000 -0300
|
||||
+++ binutils-2.39-patched/bfd/config.bfd 2022-08-07 18:29:37.305269269 -0300
|
||||
@@ -695,6 +695,11 @@
|
||||
targ_selvecs="i386_elf32_vec"
|
||||
want64=true
|
||||
;;
|
||||
+ x86_64-*-astral*)
|
||||
+ targ_defvec=x86_64_elf64_vec
|
||||
+ targ_selvecs=i386_elf32_vec
|
||||
+ want64=true
|
||||
+ ;;
|
||||
x86_64-*-netbsd* | x86_64-*-openbsd*)
|
||||
targ_defvec=x86_64_elf64_vec
|
||||
targ_selvecs="i386_elf32_vec iamcu_elf32_vec i386_coff_vec i386_pei_vec x86_64_pe_vec x86_64_pei_vec"
|
||||
diff -ruN binutils-2.39/config.sub binutils-2.39-patched/config.sub
|
||||
--- binutils-2.39/config.sub 2022-07-08 06:46:47.000000000 -0300
|
||||
+++ binutils-2.39-patched/config.sub 2022-08-07 18:26:48.218610095 -0300
|
||||
@@ -1754,7 +1754,7 @@
|
||||
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
|
||||
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
|
||||
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
|
||||
- | fiwix* )
|
||||
+ | fiwix* | astral* )
|
||||
;;
|
||||
# This one is extra strict with allowed versions
|
||||
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
|
||||
diff -ruN binutils-2.39/gas/configure.tgt binutils-2.39-patched/gas/configure.tgt
|
||||
--- binutils-2.39/gas/configure.tgt 2022-07-08 06:46:47.000000000 -0300
|
||||
+++ binutils-2.39-patched/gas/configure.tgt 2022-08-07 18:31:46.391930215 -0300
|
||||
@@ -221,6 +221,7 @@
|
||||
h8300-*-elf) fmt=elf ;;
|
||||
h8300-*-linux*) fmt=elf em=linux ;;
|
||||
|
||||
+ i386-*-astral*) fmt=elf ;;
|
||||
i386-*-beospe*) fmt=coff em=pe ;;
|
||||
i386-*-beos*) fmt=elf ;;
|
||||
i386-*-elfiamcu) fmt=elf arch=iamcu ;;
|
||||
diff -ruN binutils-2.39/ld/configure.tgt binutils-2.39-patched/ld/configure.tgt
|
||||
--- binutils-2.39/ld/configure.tgt 2022-07-29 04:37:48.000000000 -0300
|
||||
+++ binutils-2.39-patched/ld/configure.tgt 2022-08-07 18:34:19.615256758 -0300
|
||||
@@ -986,6 +986,10 @@
|
||||
;;
|
||||
visium-*-elf) targ_emul=elf32visium
|
||||
;;
|
||||
+x86_64-*-astral*)
|
||||
+ targ_emul=elf_x86_64_astral
|
||||
+ targ_extra_emuls="elf_i386_astral elf_x86_64 elf_i386"
|
||||
+ ;;
|
||||
x86_64-*-rdos*) targ_emul=elf64rdos
|
||||
;;
|
||||
x86_64-*-cloudabi*) targ_emul=elf_x86_64_cloudabi
|
||||
diff -ruN binutils-2.39/ld/emulparams/elf_i386_astral.sh binutils-2.39-patched/ld/emulparams/elf_i386_astral.sh
|
||||
--- binutils-2.39/ld/emulparams/elf_i386_astral.sh 1969-12-31 21:00:00.000000000 -0300
|
||||
+++ binutils-2.39-patched/ld/emulparams/elf_i386_astral.sh 2022-08-07 19:16:14.135145355 -0300
|
||||
@@ -0,0 +1,4 @@
|
||||
+source_sh ${srcdir}/emulparams/elf_i386.sh
|
||||
+TEXT_START_ADDR=0x10000000
|
||||
+GENERATE_SHLIB_SCRIPT=yes
|
||||
+GENERATE_PIE_SCRIPT=yes
|
||||
diff -ruN binutils-2.39/ld/emulparams/elf_x86_64_astral.sh binutils-2.39-patched/ld/emulparams/elf_x86_64_astral.sh
|
||||
--- binutils-2.39/ld/emulparams/elf_x86_64_astral.sh 1969-12-31 21:00:00.000000000 -0300
|
||||
+++ binutils-2.39-patched/ld/emulparams/elf_x86_64_astral.sh 2022-08-07 18:36:20.838584720 -0300
|
||||
@@ -0,0 +1,4 @@
|
||||
+source_sh ${srcdir}/emulparams/elf_x86_64.sh
|
||||
+TEXT_START_ADDR=0x10000000
|
||||
+GENERATE_SHLIB_SCRIPT=yes
|
||||
+GENERATE_PIE_SCRIPT=yes
|
||||
diff -ruN binutils-2.39/ld/Makefile.am binutils-2.39-patched/ld/Makefile.am
|
||||
--- binutils-2.39/ld/Makefile.am 2022-07-08 06:46:48.000000000 -0300
|
||||
+++ binutils-2.39-patched/ld/Makefile.am 2022-08-07 19:17:46.965141264 -0300
|
||||
@@ -275,6 +275,7 @@
|
||||
eelf32xtensa.c \
|
||||
eelf32z80.c \
|
||||
eelf_i386.c \
|
||||
+ eelf_i386_astral.c \
|
||||
eelf_i386_be.c \
|
||||
eelf_i386_fbsd.c \
|
||||
eelf_i386_haiku.c \
|
||||
@@ -453,6 +454,7 @@
|
||||
eelf64tilegx_be.c \
|
||||
eelf_mipsel_haiku.c \
|
||||
eelf_x86_64.c \
|
||||
+ eelf_x86_64_astral.c \
|
||||
eelf_x86_64_cloudabi.c \
|
||||
eelf_x86_64_fbsd.c \
|
||||
eelf_x86_64_haiku.c \
|
||||
@@ -766,6 +768,7 @@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32xtensa.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32z80.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386.Pc@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_astral.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_be.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_fbsd.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_haiku.Pc@am__quote@
|
||||
@@ -941,6 +944,7 @@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64tilegx_be.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_mipsel_haiku.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64.Pc@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_astral.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_haiku.Pc@am__quote@
|
||||
diff -ruN binutils-2.39/ld/Makefile.in binutils-2.39-patched/ld/Makefile.in
|
||||
--- binutils-2.39/ld/Makefile.in 2022-08-05 06:56:53.000000000 -0300
|
||||
+++ binutils-2.39-patched/ld/Makefile.in 2022-08-07 19:17:51.741807718 -0300
|
||||
@@ -529,6 +529,7 @@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
+runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@@ -772,6 +773,7 @@
|
||||
eelf32xtensa.c \
|
||||
eelf32z80.c \
|
||||
eelf_i386.c \
|
||||
+ eelf_i386_astral.c \
|
||||
eelf_i386_be.c \
|
||||
eelf_i386_fbsd.c \
|
||||
eelf_i386_haiku.c \
|
||||
@@ -949,6 +951,7 @@
|
||||
eelf64tilegx_be.c \
|
||||
eelf_mipsel_haiku.c \
|
||||
eelf_x86_64.c \
|
||||
+ eelf_x86_64_astral.c \
|
||||
eelf_x86_64_cloudabi.c \
|
||||
eelf_x86_64_fbsd.c \
|
||||
eelf_x86_64_haiku.c \
|
||||
@@ -1441,6 +1444,7 @@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64tilegx.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64tilegx_be.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386.Po@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_astral.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_be.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_fbsd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_haiku.Po@am__quote@
|
||||
@@ -1451,6 +1455,7 @@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_mipsel_haiku.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_s390.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64.Po@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_astral.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_haiku.Po@am__quote@
|
||||
@@ -2432,6 +2437,7 @@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32xtensa.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32z80.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386.Pc@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_astral.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_be.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_fbsd.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_haiku.Pc@am__quote@
|
||||
@@ -2607,6 +2613,7 @@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64tilegx_be.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_mipsel_haiku.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64.Pc@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_astral.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_haiku.Pc@am__quote@
|
||||
@@ -0,0 +1,109 @@
|
||||
diff -ruN gcc-12.1.0/config.sub gcc-12.1.0-patched/config.sub
|
||||
--- gcc-12.1.0/config.sub 2022-05-06 04:30:56.000000000 -0300
|
||||
+++ gcc-12.1.0-patched/config.sub 2022-09-14 19:57:47.513031678 -0300
|
||||
@@ -1749,7 +1749,7 @@
|
||||
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
|
||||
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
|
||||
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
|
||||
- | fiwix* )
|
||||
+ | fiwix* | astral* )
|
||||
;;
|
||||
# This one is extra strict with allowed versions
|
||||
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
|
||||
diff -ruN gcc-12.1.0/fixincludes/mkfixinc.sh gcc-12.1.0-patched/fixincludes/mkfixinc.sh
|
||||
--- gcc-12.1.0/fixincludes/mkfixinc.sh 2022-05-06 04:30:56.000000000 -0300
|
||||
+++ gcc-12.1.0-patched/fixincludes/mkfixinc.sh 2022-09-14 19:59:55.153030645 -0300
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
# Check for special fix rules for particular targets
|
||||
case $machine in
|
||||
+ *-astral* | \
|
||||
+ *-*-astral* | \
|
||||
i?86-*-cygwin* | \
|
||||
i?86-*-mingw32* | \
|
||||
x86_64-*-mingw32* | \
|
||||
diff -ruN gcc-12.1.0/gcc/config/astral.h gcc-12.1.0-patched/gcc/config/astral.h
|
||||
--- gcc-12.1.0/gcc/config/astral.h 1969-12-31 21:00:00.000000000 -0300
|
||||
+++ gcc-12.1.0-patched/gcc/config/astral.h 2022-09-14 19:58:16.803031441 -0300
|
||||
@@ -0,0 +1,24 @@
|
||||
+#undef TARGET_ASTRAL
|
||||
+#define TARGET_ASTRAL 1
|
||||
+
|
||||
+#undef LIB_SPEC
|
||||
+#define LIB_SPEC "-lc"
|
||||
+
|
||||
+#undef LINK_SPEC
|
||||
+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!shared: %{!static: %{rdynamic:-export-dynamic}}} %{!dynamic-linker:-dynamic-linker /usr/lib/ld.so}"
|
||||
+
|
||||
+#undef STARTFILE_SPEC
|
||||
+#define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
|
||||
+
|
||||
+#undef ENDFILE_SPEC
|
||||
+#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
|
||||
+
|
||||
+#undef TARGET_OS_CPP_BUILTINS
|
||||
+#define TARGET_OS_CPP_BUILTINS() \
|
||||
+ do { \
|
||||
+ builtin_define ("__astral__"); \
|
||||
+ builtin_define ("__unix__"); \
|
||||
+ builtin_assert ("system=astral"); \
|
||||
+ builtin_assert ("system=unix"); \
|
||||
+ builtin_assert ("system=posix"); \
|
||||
+ } while(0);
|
||||
diff -ruN gcc-12.1.0/gcc/config.gcc gcc-12.1.0-patched/gcc/config.gcc
|
||||
--- gcc-12.1.0/gcc/config.gcc 2022-05-06 04:30:56.000000000 -0300
|
||||
+++ gcc-12.1.0-patched/gcc/config.gcc 2022-09-14 19:57:58.466364923 -0300
|
||||
@@ -773,6 +773,12 @@
|
||||
tmake_file="${tmake_file} t-dragonfly"
|
||||
target_has_targetdm=yes
|
||||
;;
|
||||
+*-*-astral*)
|
||||
+ gas=yes
|
||||
+ gnu_ld=yes
|
||||
+ default_use_cxa_atexit=yes
|
||||
+ use_gcc_stdint=provide
|
||||
+ ;;
|
||||
*-*-freebsd*)
|
||||
# This is the generic ELF configuration of FreeBSD. Later
|
||||
# machine-specific sections may refine and add to this
|
||||
@@ -1087,6 +1093,9 @@
|
||||
esac
|
||||
|
||||
case ${target} in
|
||||
+x86_64-*-astral*)
|
||||
+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h glibc-stdint.h i386/i386elf.h i386/x86-64.h astral.h"
|
||||
+ ;;
|
||||
aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
|
||||
tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
|
||||
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-elf-raw.h"
|
||||
diff -ruN gcc-12.1.0/libgcc/config.host gcc-12.1.0-patched/libgcc/config.host
|
||||
--- gcc-12.1.0/libgcc/config.host 2022-05-06 04:30:59.000000000 -0300
|
||||
+++ gcc-12.1.0-patched/libgcc/config.host 2022-09-14 19:59:26.003030881 -0300
|
||||
@@ -751,6 +751,10 @@
|
||||
;;
|
||||
x86_64-*-openbsd*)
|
||||
;;
|
||||
+x86_64-*-astral*)
|
||||
+ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o"
|
||||
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
|
||||
+ ;;
|
||||
i[34567]86-*-linux*)
|
||||
extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
|
||||
tmake_file="${tmake_file} i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules"
|
||||
diff -ruN gcc-12.1.0/libstdc++-v3/crossconfig.m4 gcc-12.1.0-patched/libstdc++-v3/crossconfig.m4
|
||||
--- gcc-12.1.0/libstdc++-v3/crossconfig.m4 2022-05-06 04:31:00.000000000 -0300
|
||||
+++ gcc-12.1.0-patched/libstdc++-v3/crossconfig.m4 2022-09-14 19:58:39.359697928 -0300
|
||||
@@ -8,7 +8,12 @@
|
||||
arm*-*-symbianelf*)
|
||||
# This is a freestanding configuration; there is nothing to do here.
|
||||
;;
|
||||
-
|
||||
+ *-astral*)
|
||||
+ GLIBCXX_CHECK_COMPILER_FEATURES
|
||||
+ GLIBCXX_CHECK_LINKER_FEATURES
|
||||
+ GLIBCXX_CHECK_MATH_SUPPORT
|
||||
+ GLIBCXX_CHECK_STDLIB_SUPPORT
|
||||
+ ;;
|
||||
avr*-*-*)
|
||||
AC_DEFINE(HAVE_ACOSF)
|
||||
AC_DEFINE(HAVE_ASINF)
|
||||
@@ -0,0 +1,11 @@
|
||||
--- gcc-12.1.0/libgcc/libgcov.h 2022-05-06 04:30:59.000000000 -0300
|
||||
+++ gcc-12.1.0-patched/libgcc/libgcov.h 2022-09-15 17:13:09.406451175 -0300
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef GCC_LIBGCOV_H
|
||||
#define GCC_LIBGCOV_H
|
||||
|
||||
+#include <stdint.h>
|
||||
+
|
||||
/* work around the poisoned malloc/calloc in system.h. */
|
||||
#ifndef xmalloc
|
||||
#define xmalloc malloc
|
||||
@@ -0,0 +1,13 @@
|
||||
--- mlibc-2.3.0/meson.build 2022-06-20 06:58:47.000000000 -0300
|
||||
+++ mlibc-2.3.0-patched/meson.build 2022-09-14 17:04:01.893118263 -0300
|
||||
@@ -142,6 +142,10 @@
|
||||
rtdl_include_dirs += include_directories('sysdeps/dripos/include')
|
||||
libc_include_dirs += include_directories('sysdeps/dripos/include')
|
||||
subdir('sysdeps/dripos')
|
||||
+elif host_machine.system() == 'astral'
|
||||
+ rtdl_include_dirs += include_directories('sysdeps/astral/include')
|
||||
+ libc_include_dirs += include_directories('sysdeps/astral/include')
|
||||
+ subdir('sysdeps/astral')
|
||||
else
|
||||
error('No sysdeps defined for OS: ' + host_machine.system())
|
||||
endif
|
||||
@@ -0,0 +1,11 @@
|
||||
diff --no-dereference -ruN mlibc-2.3.0/options/ansi/generic/string-stubs.cpp mlibc-2.3.0-patched/options/ansi/generic/string-stubs.cpp
|
||||
--- mlibc-2.3.0/options/ansi/generic/string-stubs.cpp 2022-06-20 06:58:47.000000000 -0300
|
||||
+++ mlibc-2.3.0-patched/options/ansi/generic/string-stubs.cpp 2022-09-14 17:05:03.059784408 -0300
|
||||
@@ -391,7 +391,6 @@
|
||||
case ENOPROTOOPT: s = "Protocol not available (ENOPROTOOPT)"; break;
|
||||
case ENOTEMPTY: s = "Directory not empty (ENOTEMPTY)"; break;
|
||||
case ENOTRECOVERABLE: s = "Sate not recoverable (ENOTRECOVERABLE)"; break;
|
||||
- case ENOTSUP: s = "Operation not supported (ENOTSUP)"; break;
|
||||
case ENOTTY: s = "Inappropriate ioctl for device (ENOTTY)"; break;
|
||||
case EOVERFLOW: s = "Value too large for defined datatype (EOVERFLOW)"; break;
|
||||
#ifndef __linux__
|
||||
@@ -0,0 +1,345 @@
|
||||
diff -ruN --no-dereference mlibc-2.3.0/sysdeps/astral/crt-x86_64/crt0.S mlibc-fixed/sysdeps/astral/crt-x86_64/crt0.S
|
||||
--- mlibc-2.3.0/sysdeps/astral/crt-x86_64/crt0.S 1969-12-31 21:00:00.000000000 -0300
|
||||
+++ mlibc-fixed/sysdeps/astral/crt-x86_64/crt0.S 2022-09-15 10:41:51.696638158 -0300
|
||||
@@ -0,0 +1,7 @@
|
||||
+
|
||||
+.section .text
|
||||
+.global _start
|
||||
+_start:
|
||||
+ mov $main, %rdi
|
||||
+ call __mlibc_entry
|
||||
+
|
||||
diff -ruN --no-dereference mlibc-2.3.0/sysdeps/astral/generic/astral.cpp mlibc-fixed/sysdeps/astral/generic/astral.cpp
|
||||
--- mlibc-2.3.0/sysdeps/astral/generic/astral.cpp 1969-12-31 21:00:00.000000000 -0300
|
||||
+++ mlibc-fixed/sysdeps/astral/generic/astral.cpp 2022-09-15 10:41:51.696638158 -0300
|
||||
@@ -0,0 +1,6 @@
|
||||
+#include <astral/syscall.h>
|
||||
+
|
||||
+int arch_ctl(int func, void* arg){
|
||||
+ long ret;
|
||||
+ return syscall(SYSCALL_ARCH_CTL, &ret, func, (uint64_t)arg);
|
||||
+}
|
||||
diff -ruN --no-dereference mlibc-2.3.0/sysdeps/astral/generic/entry.cpp mlibc-fixed/sysdeps/astral/generic/entry.cpp
|
||||
--- mlibc-2.3.0/sysdeps/astral/generic/entry.cpp 1969-12-31 21:00:00.000000000 -0300
|
||||
+++ mlibc-fixed/sysdeps/astral/generic/entry.cpp 2022-09-15 10:41:51.696638158 -0300
|
||||
@@ -0,0 +1,34 @@
|
||||
+
|
||||
+#include <stdint.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <bits/ensure.h>
|
||||
+#include <mlibc/elf/startup.h>
|
||||
+
|
||||
+// defined by the POSIX library
|
||||
+void __mlibc_initLocale();
|
||||
+
|
||||
+extern "C" uintptr_t *__dlapi_entrystack();
|
||||
+
|
||||
+extern char **environ;
|
||||
+static mlibc::exec_stack_data __mlibc_stack_data;
|
||||
+
|
||||
+struct LibraryGuard {
|
||||
+ LibraryGuard();
|
||||
+};
|
||||
+
|
||||
+static LibraryGuard guard;
|
||||
+
|
||||
+LibraryGuard::LibraryGuard() {
|
||||
+ __mlibc_initLocale();
|
||||
+
|
||||
+ // Parse the exec() stack.
|
||||
+ mlibc::parse_exec_stack(__dlapi_entrystack(), &__mlibc_stack_data);
|
||||
+ mlibc::set_startup_data(__mlibc_stack_data.argc, __mlibc_stack_data.argv,
|
||||
+ __mlibc_stack_data.envp);
|
||||
+}
|
||||
+
|
||||
+extern "C" void __mlibc_entry(int (*main_fn)(int argc, char *argv[], char *env[])) {
|
||||
+ auto result = main_fn(__mlibc_stack_data.argc, __mlibc_stack_data.argv, environ);
|
||||
+ exit(result);
|
||||
+}
|
||||
+
|
||||
diff -ruN --no-dereference mlibc-2.3.0/sysdeps/astral/generic/generic.cpp mlibc-fixed/sysdeps/astral/generic/generic.cpp
|
||||
--- mlibc-2.3.0/sysdeps/astral/generic/generic.cpp 1969-12-31 21:00:00.000000000 -0300
|
||||
+++ mlibc-fixed/sysdeps/astral/generic/generic.cpp 2022-09-15 10:41:51.696638158 -0300
|
||||
@@ -0,0 +1,167 @@
|
||||
+#include <bits/ensure.h>
|
||||
+#include <mlibc/debug.hpp>
|
||||
+#include <mlibc/all-sysdeps.hpp>
|
||||
+#include <errno.h>
|
||||
+#include <astral/syscall.h>
|
||||
+#include <astral/archctl.h>
|
||||
+
|
||||
+#define STUB_ONLY { __ensure(!"STUB_ONLY function was called"); __builtin_unreachable(); }
|
||||
+
|
||||
+namespace mlibc {
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ uid_t sys_getuid(){
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ gid_t sys_getgid(){
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ uid_t sys_geteuid(){
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ gid_t sys_getegid(){
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ pid_t sys_getpid(){
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ pid_t sys_getppid(){
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ int sys_getpgid(pid_t pid, pid_t* pgid){
|
||||
+ *pgid = 1;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ int sys_clock_get(int clock, time_t *secs, long *nanos){
|
||||
+ *secs = 0;
|
||||
+ *nanos = 0;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ int sys_ioctl(int fd, unsigned long request, void *arg, int *result){
|
||||
+ return ENOSYS;
|
||||
+ }
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ int sys_sigaction(int, const struct sigaction *__restrict,
|
||||
+ struct sigaction *__restrict){
|
||||
+ return ENOSYS;
|
||||
+ }
|
||||
+
|
||||
+ // stub
|
||||
+
|
||||
+ int sys_sigprocmask(int how, const sigset_t *__restrict set, sigset_t *__restrict retrieve){
|
||||
+ return ENOSYS;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ void sys_libc_log(const char *message){
|
||||
+ long ret;
|
||||
+ syscall(SYSCALL_LIBC_LOG, &ret, (uint64_t)message);
|
||||
+ }
|
||||
+
|
||||
+ [[noreturn]] void sys_libc_panic(){
|
||||
+ for(;;);
|
||||
+ sys_libc_log("LIBC PANIC!");
|
||||
+ sys_exit(1);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+
|
||||
+ [[noreturn]] void sys_exit(int status){
|
||||
+ sys_libc_log("libc: Program requested exit");
|
||||
+ while(1);
|
||||
+ }
|
||||
+
|
||||
+ int sys_tcb_set(void* pointer){
|
||||
+ return arch_ctl(ARCH_CTL_FSBASE, pointer);
|
||||
+ }
|
||||
+ [[gnu::weak]] int sys_futex_tid(){
|
||||
+ long ret;
|
||||
+ syscall(SYSCALL_GETTID, &ret);
|
||||
+ return ret;
|
||||
+ }
|
||||
+ int sys_futex_wait(int *pointer, int expected, const struct timespec *time) STUB_ONLY
|
||||
+ int sys_futex_wake(int *pointer) STUB_ONLY
|
||||
+ int sys_anon_allocate(size_t size, void **pointer){
|
||||
+ return sys_vm_map(NULL, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, 0, 0, pointer);
|
||||
+ }
|
||||
+ int sys_anon_free(void* pointer, size_t size){
|
||||
+ sys_libc_log("libc: sys_anon_free is not implemented");
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ int sys_open(const char* pathname, int flags, mode_t mode, int* fd){
|
||||
+ long ret;
|
||||
+ long err = syscall(SYSCALL_OPEN, &ret, (uint64_t)pathname, flags, mode);
|
||||
+ *fd = (int)ret;
|
||||
+ return err;
|
||||
+ };
|
||||
+ int sys_read(int fd, void* buff, size_t count, ssize_t *bytes_read){
|
||||
+ return syscall(SYSCALL_READ, bytes_read, fd, (uint64_t)buff, count);
|
||||
+ }
|
||||
+ int sys_write(int fd, const void* buff, size_t count, ssize_t *bytes_written){
|
||||
+ return syscall(SYSCALL_WRITE, bytes_written, fd, (uint64_t)buff, count);
|
||||
+ }
|
||||
+ int sys_seek(int fd, off_t offset, int whence, off_t *new_offset){
|
||||
+ return syscall(SYSCALL_LSEEK, new_offset, fd, offset, whence);
|
||||
+ }
|
||||
+
|
||||
+ int sys_close(int fd){
|
||||
+ long ret;
|
||||
+ return syscall(SYSCALL_CLOSE, &ret, fd);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ [[gnu::weak]] int sys_stat(fsfd_target fsfdt, int fd, const char* path, int flags, struct stat *statbuf){
|
||||
+ long ret;
|
||||
+ switch(fsfdt){
|
||||
+ case fsfd_target::path:
|
||||
+ return syscall(SYSCALL_STAT, &ret, (uint64_t)path, (uint64_t)statbuf);
|
||||
+ case fsfd_target::fd:
|
||||
+ return syscall(SYSCALL_FSTAT, &ret, (uint64_t)path, (uint64_t)statbuf);
|
||||
+ default:
|
||||
+ sys_libc_log("libc: sys_stat: Unknown fsfd target");
|
||||
+ return ENOSYS;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ int sys_vm_map(void *hint, size_t size, int prot, int flags, int fd, off_t offset, void** window){
|
||||
+ long ret = syscall(SYSCALL_MMAP, (int64_t*)window, (uint64_t)hint, size, prot, flags, fd, offset);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ int sys_vm_unmap(void* pointer, size_t size) STUB_ONLY
|
||||
+
|
||||
+ int sys_isatty(int fd){
|
||||
+ long ret;
|
||||
+ return syscall(SYSCALL_ISATTY, &ret, fd);
|
||||
+ }
|
||||
+
|
||||
+} // namespace mlibc
|
||||
+
|
||||
diff -ruN --no-dereference mlibc-2.3.0/sysdeps/astral/include/astral/archctl.h mlibc-fixed/sysdeps/astral/include/astral/archctl.h
|
||||
--- mlibc-2.3.0/sysdeps/astral/include/astral/archctl.h 1969-12-31 21:00:00.000000000 -0300
|
||||
+++ mlibc-fixed/sysdeps/astral/include/astral/archctl.h 2022-09-15 10:41:51.696638158 -0300
|
||||
@@ -0,0 +1,11 @@
|
||||
+#ifndef _ASTRAL_SYSCALL_ARCHCTL_INCLUDE
|
||||
+#define _ASTRAL_SYSCALL_ARCHCTL_INCLUDE
|
||||
+
|
||||
+#include <astral/syscall.h>
|
||||
+
|
||||
+#define ARCH_CTL_GSBASE 0
|
||||
+#define ARCH_CTL_FSBASE 1
|
||||
+
|
||||
+int arch_ctl(int func, void* arg);
|
||||
+
|
||||
+#endif
|
||||
diff -ruN --no-dereference mlibc-2.3.0/sysdeps/astral/include/astral/syscall.h mlibc-fixed/sysdeps/astral/include/astral/syscall.h
|
||||
--- mlibc-2.3.0/sysdeps/astral/include/astral/syscall.h 1969-12-31 21:00:00.000000000 -0300
|
||||
+++ mlibc-fixed/sysdeps/astral/include/astral/syscall.h 2022-09-15 10:41:51.696638158 -0300
|
||||
@@ -0,0 +1,37 @@
|
||||
+#ifndef _SYSCALL_H_INCLUDE
|
||||
+#define _SYSCALL_H_INCLUDE
|
||||
+
|
||||
+#define SYSCALL_LIBC_LOG 0
|
||||
+#define SYSCALL_MMAP 1
|
||||
+#define SYSCALL_ARCH_CTL 2
|
||||
+#define SYSCALL_GETTID 3
|
||||
+#define SYSCALL_OPEN 4
|
||||
+#define SYSCALL_READ 5
|
||||
+#define SYSCALL_LSEEK 6
|
||||
+#define SYSCALL_CLOSE 7
|
||||
+#define SYSCALL_ISATTY 8
|
||||
+#define SYSCALL_WRITE 9
|
||||
+#define SYSCALL_STAT 10
|
||||
+#define SYSCALL_FSTAT 11
|
||||
+
|
||||
+#include <stddef.h>
|
||||
+#include <stdint.h>
|
||||
+
|
||||
+static long syscall(long func, long* ret, uint64_t p1 = 0, uint64_t p2 = 0, uint64_t p3 = 0, uint64_t p4 = 0, uint64_t p5 = 0, uint64_t p6 = 0){
|
||||
+
|
||||
+ volatile long err;
|
||||
+
|
||||
+ register uint64_t r4 asm("r10") = p4;
|
||||
+ register uint64_t r5 asm("r8") = p5;
|
||||
+ register uint64_t r6 asm("r9") = p6;
|
||||
+
|
||||
+ asm volatile("syscall"
|
||||
+ : "=a"(*ret), "=d"(err)
|
||||
+ : "a"(func), "D"(p1), "S"(p2), "d"(p3), "r"(r4),
|
||||
+ "r"(r5), "r"(r6)
|
||||
+ : "memory", "rcx", "r11");
|
||||
+ return err;
|
||||
+
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
diff -ruN --no-dereference mlibc-2.3.0/sysdeps/astral/meson.build mlibc-fixed/sysdeps/astral/meson.build
|
||||
--- mlibc-2.3.0/sysdeps/astral/meson.build 1969-12-31 21:00:00.000000000 -0300
|
||||
+++ mlibc-fixed/sysdeps/astral/meson.build 2022-09-15 10:41:51.696638158 -0300
|
||||
@@ -0,0 +1,55 @@
|
||||
+
|
||||
+rtdl_sources += files(
|
||||
+ 'generic/generic.cpp',
|
||||
+ 'generic/astral.cpp',
|
||||
+)
|
||||
+
|
||||
+libc_sources += files(
|
||||
+ 'generic/entry.cpp',
|
||||
+ 'generic/astral.cpp',
|
||||
+ 'generic/generic.cpp',
|
||||
+)
|
||||
+
|
||||
+if not no_headers
|
||||
+ install_headers(
|
||||
+ 'include/abi-bits/abi.h',
|
||||
+ 'include/abi-bits/auxv.h',
|
||||
+ 'include/abi-bits/seek-whence.h',
|
||||
+ 'include/abi-bits/vm-flags.h',
|
||||
+ 'include/abi-bits/errno.h',
|
||||
+ 'include/abi-bits/fcntl.h',
|
||||
+ 'include/abi-bits/in.h',
|
||||
+ 'include/abi-bits/resource.h',
|
||||
+ 'include/abi-bits/stat.h',
|
||||
+ 'include/abi-bits/signal.h',
|
||||
+ 'include/abi-bits/socket.h',
|
||||
+ 'include/abi-bits/termios.h',
|
||||
+ 'include/abi-bits/time.h',
|
||||
+ 'include/abi-bits/blkcnt_t.h',
|
||||
+ 'include/abi-bits/blksize_t.h',
|
||||
+ 'include/abi-bits/dev_t.h',
|
||||
+ 'include/abi-bits/gid_t.h',
|
||||
+ 'include/abi-bits/ino_t.h',
|
||||
+ 'include/abi-bits/mode_t.h',
|
||||
+ 'include/abi-bits/nlink_t.h',
|
||||
+ 'include/abi-bits/pid_t.h',
|
||||
+ 'include/abi-bits/uid_t.h',
|
||||
+ 'include/abi-bits/access.h',
|
||||
+ 'include/abi-bits/wait.h',
|
||||
+ 'include/abi-bits/utsname.h',
|
||||
+ 'include/abi-bits/limits.h',
|
||||
+ subdir: 'abi-bits'
|
||||
+ )
|
||||
+endif
|
||||
+
|
||||
+if not headers_only
|
||||
+ crt = custom_target('crt0',
|
||||
+ build_by_default: true,
|
||||
+ command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
+ input: 'crt-x86_64/crt0.S',
|
||||
+ output: 'crt0.o',
|
||||
+ install: true,
|
||||
+ install_dir: get_option('libdir')
|
||||
+ )
|
||||
+endif
|
||||
+
|
||||
@@ -0,0 +1,21 @@
|
||||
name=astral
|
||||
revision=1
|
||||
from_source=astral
|
||||
hostdeps="gcc-cross binutils-cross"
|
||||
imagedeps="base-devel nasm"
|
||||
|
||||
configure() {
|
||||
true
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
pushd ${base_dir}
|
||||
make kernel XCC=x86_64-astral-gcc
|
||||
popd
|
||||
|
||||
}
|
||||
|
||||
install() {
|
||||
true
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
name=bash
|
||||
revision=1
|
||||
from_source=bash
|
||||
imagedeps="base-devel"
|
||||
hostdeps="gcc-cross binutils-cross"
|
||||
deps="mlibc"
|
||||
|
||||
configure() {
|
||||
|
||||
${source_dir}/configure --host=x86_64-astral --prefix=${prefix} --disable-readline --without-bash-malloc
|
||||
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
make -j ${parallelism}
|
||||
|
||||
}
|
||||
|
||||
install() {
|
||||
|
||||
make install DESTDIR=${dest_dir}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
name=mlibc
|
||||
from_source=mlibc
|
||||
revision=1
|
||||
hostdeps="gcc-cross binutils-cross"
|
||||
imagedeps="meson ninja git base-devel binutils"
|
||||
allow_network="yes"
|
||||
|
||||
|
||||
configure() {
|
||||
meson --cross-file ${base_dir}/util/crossfile --prefix=${prefix} ${source_dir}
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
ninja
|
||||
|
||||
}
|
||||
|
||||
install() {
|
||||
DESTDIR=${dest_dir} ninja install
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
name=mlibc-headers
|
||||
from_source=mlibc
|
||||
revision=1
|
||||
imagedeps="ninja meson base-devel"
|
||||
|
||||
configure() {
|
||||
meson --cross-file ${base_dir}/util/crossfile --prefix=${prefix} -Dheaders_only=true ${source_dir}
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
ninja
|
||||
|
||||
}
|
||||
|
||||
install() {
|
||||
DESTDIR=${dest_dir} ninja install
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
name=astral
|
||||
version=0
|
||||
source_dir="src"
|
||||
|
||||
regenerate() {
|
||||
true
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
name=autoconf
|
||||
version=2.69
|
||||
source_method=tarball
|
||||
tarball_url="https://ftp.gnu.org/gnu/autoconf/autoconf-${version}.tar.xz"
|
||||
tarball_sha512=995d3e5a8eb1eb37e2b7fae53c6ec7a9b4df997286b7d643344818f94636756b1bf5ff5ea9155e755cb9461149a853dfbf2886fc6bd7132e5afa9c168e306e9b
|
||||
|
||||
regenerate() {
|
||||
true
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
name=automake
|
||||
version=1.15.1
|
||||
source_method=tarball
|
||||
tarball_url="https://ftp.gnu.org/gnu/automake/automake-${version}.tar.gz"
|
||||
tarball_sha512=f0d4717ebe2c76cec5d487de090f6e1c0f784b0d382fd964ffa846287e2a364a52531a26ab98b7033ac04ed302a247b3b114299def54819a03439bfc962ff61b
|
||||
|
||||
regenerate() {
|
||||
true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
name=bash
|
||||
version=5.1
|
||||
source_method=tarball
|
||||
tarball_url="https://ftp.gnu.org/gnu/bash/bash-${version}.tar.gz"
|
||||
tarball_sha512=c44a0ce381469219548a3a27589af3fea4f22eda1ca4e9434b59fc16da81b471c29ce18e31590e0860a6a251a664b68c2b45e3a17d22cfc02799ffd9a208390c
|
||||
regenerate() {
|
||||
true
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
name=binutils-cross
|
||||
version=2.39
|
||||
source_method=tarball
|
||||
tarball_url="https://ftpmirror.gnu.org/binutils/binutils-${version}.tar.xz"
|
||||
tarball_sha512=68e038f339a8c21faa19a57bbc447a51c817f47c2e06d740847c6e9cc3396c025d35d5369fa8c3f8b70414757c89f0e577939ddc0d70f283182504920f53b0a3
|
||||
hostdeps="autoconf automake"
|
||||
|
||||
regenerate() {
|
||||
(cd ld && automake)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
name=gcc-cross
|
||||
version=12.1.0
|
||||
source_method=tarball
|
||||
tarball_url="https://ftp.gnu.org/gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"
|
||||
tarball_sha512=2121d295292814a6761edf1fba08c5f633ebe16f52b80e7b73a91050e71e1d2ed98bf17eebad263e191879561c02b48906c53faa4c4670c486a26fc75df23900
|
||||
hostdeps="automake autoconf"
|
||||
|
||||
regenerate() {
|
||||
(cd libstdc++-v3 && autoconf)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
name=mlibc
|
||||
version=2.3.0
|
||||
source_method=tarball
|
||||
tarball_url="https://github.com/managarm/mlibc/archive/refs/tags/${version}.tar.gz"
|
||||
tarball_sha512=3d5c866d43d1a5094954747f18b9cb3cbdbf7136ebc8b61de0d203fcf905220cdf59911c20ecd7bc085e57dcff721ca32f35990f9042ca7835bdaa98443f96d5
|
||||
hostdeps=""
|
||||
|
||||
regenerate() {
|
||||
mkdir -p ${source_dir}/sysdeps/astral/include/
|
||||
ln -sv ../../../abis/linux/x86_64/ ${source_dir}/sysdeps/astral/include/abi-bits
|
||||
true
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
objects := $(patsubst %.c,%.o,$(wildcard *.c))
|
||||
subdirs := arch/$(TARGET)/ include video sys fs
|
||||
OBJPATH=$(OBJDIR)
|
||||
CC=$(XCC)
|
||||
export
|
||||
|
||||
all: $(subdirs) $(objects)
|
||||
|
||||
@@ -399,7 +399,7 @@ void sched_runinit(){
|
||||
stdoutfd->flags = stderrfd->flags = O_WRONLY + 1;
|
||||
|
||||
vnode_t* node;
|
||||
ret = vfs_open(&node, vfs_root(), "sbin/init");
|
||||
ret = vfs_open(&node, vfs_root(), "usr/bin/bash");
|
||||
|
||||
if(ret){
|
||||
printf("Open failed: %s\n", strerror(ret));
|
||||
@@ -421,7 +421,7 @@ void sched_runinit(){
|
||||
arch_regs_setupuser(thread->regs, entry, stack, true);
|
||||
|
||||
timer_add(&arch_getcls()->schedreq, THREAD_QUANTUM, true);
|
||||
|
||||
|
||||
switch_thread(thread);
|
||||
|
||||
__builtin_unreachable();
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[host_machine]
|
||||
system = 'astral'
|
||||
cpu_family = 'x86_64'
|
||||
cpu = 'x86_64'
|
||||
endian = 'little'
|
||||
[binaries]
|
||||
c = 'x86_64-astral-gcc'
|
||||
cpp = 'x86_64-astral-g++'
|
||||
ar = 'x86_64-astral-ar'
|
||||
strip = 'x86_64-astral-strip'
|
||||
ld = 'x86_64-astral-ld'
|
||||
Reference in New Issue
Block a user