From b78e485e3877bb345011c0ffb45271fb4d2e8182 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 3 Aug 2015 22:23:43 +0200 Subject: [PATCH] start to create a toolchain for HermitCore --- hermit/Makefile | 2 +- hermit/newlib/Makefile | 19 +++++++++++++------ hermit/newlib/examples/Makefile | 25 ++++++++++++++++++------- hermit/newlib/gcc | 2 +- hermit/newlib/pte | 2 +- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/hermit/Makefile b/hermit/Makefile index 4f7fcfb8e..af9451c06 100644 --- a/hermit/Makefile +++ b/hermit/Makefile @@ -54,7 +54,7 @@ STRIP_DEBUG = --strip-debug KEEP_DEBUG = --only-keep-debug OUTPUT_FORMAT = -O elf32-i386 -CFLAGS_FOR_NEWLIB = $(STACKPROT) -mtune=native +CFLAGS_FOR_NEWLIB = -O2 -mtune=native #$(STACKPROT) LDFLAGS_FOR_NEWLIB = NASMFLAGS_FOR_NEWLIB = -felf64 CFLAGS_FOR_TOOLS = -O2 -Wall diff --git a/hermit/newlib/Makefile b/hermit/newlib/Makefile index c06ae67d3..05da53470 100644 --- a/hermit/newlib/Makefile +++ b/hermit/newlib/Makefile @@ -1,14 +1,13 @@ TOPDIR = $(shell pwd) ARCH = x86 -TARGET=x86_64-hermit-elf64 +TARGET=x86_64-hermit NEWLIB = $(TOPDIR)/$(ARCH)/$(TARGET) RM = rm -rf CD = cd MKDIR = mkdir TMP = $(TOPDIR)/tmp -OPT = --disable-shared --disable-multilib --disable-newlib-multithread --disable-newlib-reent-small -ARCHOPT = #-mavx2 -mfma +OPT = --disable-shared --disable-multilib --enable-newlib-multithread #--disable-newlib-reent-small # Prettify output V = 0 @@ -18,14 +17,21 @@ ifeq ($V,0) endif default: $(ARCH) - $Q$(MAKE) ARCH=$(ARCH) TARGET=$(TARGET) CFLAGS+="$(ARCHOPT) -ffreestanding -O3 -Wall -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C examples depend - $Q$(MAKE) ARCH=$(ARCH) TARGET=$(TARGET) CFLAGS+="$(ARCHOPT) -ffreestanding -O3 -Wall -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C examples + $Q$(MAKE) -C examples depend + $Q$(MAKE) -C examples $(ARCH): @echo Build newlib $Q$(RM) $(TMP) $Q$(MKDIR) $(TMP) - $Q$(CD) $(TMP); $(TOPDIR)/src/configure --target=$(TARGET) --prefix=$(TOPDIR)/$(ARCH) $(OPT) && $(MAKE) && $(MAKE) install + $Q$(MKDIR) $(TMP)/binutils + $Q$(CD) $(TMP)/binutils; $(TOPDIR)/binutils/configure --target=$(TARGET) --prefix=$(TOPDIR)/$(ARCH) --disable-shared --disable-nls --disable-gdb --disable-libdecnumber --disable-readline --disable-sim && $(MAKE) && $(MAKE) install + $Q$(MKDIR) $(TMP)/newlib + $Q$(CD) $(TMP)/newlib; $(TOPDIR)/src/configure --target=$(TARGET) --prefix=$(TOPDIR)/$(ARCH) $(OPT) && $(MAKE) && $(MAKE) install + $Q$(MAKE) TARGET=$(TARGET) CFLAGS+="-I. -Iplatform/hermit -ffreestanding -O3 -Wall -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C pte depend + $Q$(MAKE) TARGET=$(TARGET) CFLAGS+="-I. -Iplatform/hermit -ffreestanding -O3 -Wall -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C pte + $Q$(MKDIR) $(TMP)/gcc + $Q$(CD) $(TMP)/gcc; $(TOPDIR)/gcc/configure --target=$(TARGET) --prefix=$(TOPDIR)/$(ARCH) --without-headers --with-newlib --enable-languages=c --disable-nls --disable-shared --disable-libssp --enable-threads=single && $(MAKE) && $(MAKE) install clean: @echo Cleaning newlib @@ -34,5 +40,6 @@ clean: veryclean: @echo Propper cleaning newlib + $Q$(MAKE) -C pte veryclean $Q$(MAKE) -C examples veryclean $Q$(RM) $(TOPDIR)/$(ARCH) diff --git a/hermit/newlib/examples/Makefile b/hermit/newlib/examples/Makefile index 44327ea2e..c07dd35fd 100644 --- a/hermit/newlib/examples/Makefile +++ b/hermit/newlib/examples/Makefile @@ -1,16 +1,27 @@ ARCH = x86 -NEWLIB = ../x86/x86_64-hermit-elf64 +TARGET=x86_64-hermit MAKE = make STRIP_DEBUG = --strip-debug KEEP_DEBUG = --only-keep-debug -override LDFLAGS += -T link.ld +# Set your own cross compiler tool chain prefix here +override CROSSCOMPREFIX = ../$(ARCH)/bin/$(TARGET)- -# Default section offsets in x86-64 ELF files are aligned to the page-size. -# For x86-64 the pagesize is huge (2 MB) with the consquence of large sparse -# ELF files (which lead to a huge initrd). To solve this, we manually set the page-size to 4 KB. -# Furthermore, we use a large memory model to deal with real 64bit application. -override LDFLAGS += -Wl,-n,-z,max-page-size=0x1000 +override CC_FOR_TARGET = $(CROSSCOMPREFIX)gcc +override CXX_FOR_TARGET = $(CROSSCOMPREFIX)g++ +override GCC_FOR_TARGET = $(CROSSCOMPREFIX)gcc +override CPP_FOR_TARGET = $(CROSSCOMPREFIX)cpp +override AR_FOR_TARGET = $(CROSSCOMPREFIX)ar +override AS_FOR_TARGET = $(CROSSCOMPREFIX)as +override LD_FOR_TARGET = $(CROSSCOMPREFIX)ld +override NM_FOR_TARGET = $(CROSSCOMPREFIX)nm +override OBJDUMP_FOR_TARGET = $(CROSSCOMPREFIX)objdump +override OBJCOPY_FOR_TARGET = $(CROSSCOMPREFIX)objcopy +override RANLIB_FOR_TARGET = $(CROSSCOMPREFIX)ranlib +override STRIP_FOR_TARGET = $(CROSSCOMPREFIX)strip +override READELF_FOR_TARGET = $(CROSSCOMPREFIX)readelf + +override CFLAGS=-O3 -mtune=native # Prettify output V = 0 diff --git a/hermit/newlib/gcc b/hermit/newlib/gcc index 103e14549..04ee6b976 160000 --- a/hermit/newlib/gcc +++ b/hermit/newlib/gcc @@ -1 +1 @@ -Subproject commit 103e1454982e711374d12cac05d48238f982a4ea +Subproject commit 04ee6b97699cdc73d040eb202cf607666103ac82 diff --git a/hermit/newlib/pte b/hermit/newlib/pte index dd62610a3..a4ea10a70 160000 --- a/hermit/newlib/pte +++ b/hermit/newlib/pte @@ -1 +1 @@ -Subproject commit dd62610a3d3ca59b1034e73286a7d3f5903b0bee +Subproject commit a4ea10a709d75839c0ae34b0fef2bed51a97c5fc