From 35b91319f9a9dfe921b50298ff684a4fa75d1812 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 1 Jun 2020 20:49:17 +0200 Subject: [PATCH] Adding patches for red-zone --- .gitignore | 2 ++ Makefile | 61 +++++++++++++++++++++++++++++++++++++-------- multilib.opt | 4 +++ patch-red-zone.diff | 19 ++++++++++++++ 4 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 multilib.opt create mode 100644 patch-red-zone.diff diff --git a/.gitignore b/.gitignore index 12eb267..21cbd9e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ gcc*/* binutils*/* gcc* binutils* +bin/* +build* diff --git a/Makefile b/Makefile index fe16f79..e20a9d7 100644 --- a/Makefile +++ b/Makefile @@ -22,23 +22,26 @@ # along with OS/K. If not, see . # #=----------------------------------------------------------------------------=# -.PHONY: retrieve compile showenv -.DEFAULT_GOAL := compile +.PHONY: retrieve compile showenv deflate configurebinutils binutils gcc clean +.DEFAULT_GOAL := gcc ## VERSIONS ------------------------------------------------------------------ # + +GCC_NAME = gcc-10.1.0 +BINUTILS_NAME =binutils-2.34 # GCC 10.1.0 -GCC_SOURCES = https://ftp.gnu.org/gnu/gcc/gcc-10.1.0/gcc-10.1.0.tar.xz +GCC_SOURCES = https://ftp.gnu.org/gnu/gcc/$(GCC_NAME)/$(GCC_NAME).tar.xz # BINUTILS 2.34 -BINUTILS_SOURCES = https://ftp.gnu.org/gnu/binutils/binutils-2.34.tar.xz +BINUTILS_SOURCES = https://ftp.gnu.org/gnu/binutils/$(BINUTILS_NAME).tar.xz ## VARIABLES ----------------------------------------------------------------- # #ENV -export NTHREADS := ${nproc} -export PREFIX := $(HOME)/opt/cross +export NTHREADS := $(shell nproc) +export PREFIX := $(shell pwd)/bin export TARGET := x86_64-elf export PATH := $(PREFIX)/bin:$(PATH) export XZ_DEFAULTS := -T $(NTHREADS) @@ -73,15 +76,51 @@ retrieve: showenv deflate: @echo ${CL2}[$@] ${NC}Deflate GCC sources...${CL3} - @tar -xaf $(GCCTARNAME) --threads NTHREADS - @echo ${CL2}[$@] ${NC}Deflate BINUTILS sources...${CL3} - @tar -xaf $(BINUTILSTARNAME) --threads NTHREADS + @tar -xaf $(GCCTARNAME) --skip-old-files + @echo ${CL2}[$@] ${NC}Deflate $(BINUTILS_NAME) sources...${CL3} + @tar -xaf $(BINUTILSTARNAME) --skip-old-files @echo ${CL2}[$@] ${CL}Success.${CL3} -compile: retrieve deflate +configurebinutils: retrieve deflate + @echo ${CL2}[$@] ${NC}Configuring $(BINUTILS_NAME)...${CL3} + @mkdir -p build-binutils + cd build-binutils && ../$(BINUTILS_NAME)/configure --target=$(TARGET) --prefix="$(PREFIX)" --with-sysroot --disable-nls --disable-werror @echo ${CL2}[$@] ${CL}Success.${CL3} +binutils: configurebinutils + @echo ${CL2}[$@] ${NC}Compiling $(BINUTILS_NAME)...${CL3} + cd build-binutils && make -j $(NTHREADS) + @echo ${CL2}[$@] ${NC}Compiling $(BINUTILS_NAME)...${CL3} + @mkdir -p bin + cd build-binutils && make install -j $(NTHREADS) + @echo ${CL2}[$@] ${CL}Success.${CL3} + +configuregcc: + @echo ${CL2}[$@] ${NC}Configuring $(GCC_NAME)...${CL3} + @cp multilib.opt $(GCC_NAME)/gcc/config/i386/t-x86_64-elf + @patch $(GCC_NAME)/gcc/config.gcc < patch-red-zone.diff + @mkdir -p build-gcc + cd build-gcc && ../$(GCC_NAME)/configure --target=$(TARGET) --prefix="$(PREFIX)" --disable-nls --enable-languages=c,c++ --without-headers + @echo ${CL2}[$@] ${CL}Success.${CL3} + +gcc: binutils configuregcc + @echo ${CL2}[$@] ${NC}Compiling $(GCC_NAME)...${CL3} + cd build-gcc && make all-gcc -j $(NTHREADS) + cd build-gcc && make all-target-libgcc -j $(NTHREADS) + @mkdir -p bin + cd build-gcc && make install-gcc -j $(NTHREADS) + cd build-gcc && make install-target-libgcc -j $(NTHREADS) + @echo ${CL2}[$@] ${CL}Success.${CL3} + +clean: + @mkdir -p build-gcc build-binutils + @cd build-gcc && rm -rf * + @cd build-binutils && rm -rf * + @rm -rf bin + @echo ${CL2}[$@] ${CL}Success.${CL3} + + remove_all: @rm -rf gcc* - @rm -rf binutils* + @rm -rf bin* @echo ${CL2}[$@] ${CL}Success.${CL3} diff --git a/multilib.opt b/multilib.opt new file mode 100644 index 0000000..30f8698 --- /dev/null +++ b/multilib.opt @@ -0,0 +1,4 @@ +# Add libgcc multilib variant without red-zone requirement + +MULTILIB_OPTIONS += mno-red-zone +MULTILIB_DIRNAMES += no-red-zone diff --git a/patch-red-zone.diff b/patch-red-zone.diff new file mode 100644 index 0000000..4739630 --- /dev/null +++ b/patch-red-zone.diff @@ -0,0 +1,19 @@ +--- config.gcc 2020-06-01 20:40:52.562801089 +0200 ++++ configm.gcc 2020-06-01 20:41:49.970576321 +0200 +@@ -180,7 +180,7 @@ + # the --with-sysroot configure option or the + # --sysroot command line option is used this + # will be relative to the sysroot. +-# target_type_format_char ++# target_type_format_char + # The default character to be used for formatting + # the attribute in a + # .type symbol_name, ${t_t_f_c} +@@ -1865,6 +1865,7 @@ + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h" + ;; + x86_64-*-elf*) ++ tmake_file="${tmake_file} i386/t-x86_64-elf" # include the new multilib configuration to prevent red-zone + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h" + ;; + x86_64-*-rtems*)