diff --git a/dka64/patches/gcc-7.3.0-RC-20180122.patch b/dka64/patches/gcc-7.3.0-RC-20180122.patch new file mode 100644 index 0000000..12e8716 --- /dev/null +++ b/dka64/patches/gcc-7.3.0-RC-20180122.patch @@ -0,0 +1,190 @@ +diff -NBaur gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64.c gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64.c +--- gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64.c 2017-11-03 15:01:10.970890000 +0000 ++++ gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64.c 2018-01-22 20:15:07.232099998 +0000 +@@ -10009,8 +10009,24 @@ + || !register_operand (target, Pmode)) + target = gen_reg_rtx (Pmode); + +- /* Can return in any reg. */ +- emit_insn (gen_aarch64_load_tp_hard (target)); ++ if (TARGET_HARD_TP) ++ { ++ /* Can return in any reg. */ ++ emit_insn (gen_aarch64_load_tp_hard (target)); ++ } ++ else ++ { ++ /* Always returned in r0. Immediately copy the result into a pseudo, ++ otherwise other uses of r0 (e.g. setting up function arguments) may ++ clobber the value. */ ++ ++ rtx tmp; ++ ++ emit_insn (gen_aarch64_load_tp_soft ()); ++ ++ tmp = gen_rtx_REG (DImode, R0_REGNUM); ++ emit_move_insn (target, tmp); ++ } + return target; + } + +diff -NBaur gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64-elf-raw.h gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64-elf-raw.h +--- gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64-elf-raw.h 2017-01-01 12:07:43.905435000 +0000 ++++ gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64-elf-raw.h 2018-01-22 20:15:07.232099998 +0000 +@@ -22,6 +22,7 @@ + #ifndef GCC_AARCH64_ELF_RAW_H + #define GCC_AARCH64_ELF_RAW_H + ++#define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %L %(libgloss) --end-group" + #define STARTFILE_SPEC " crti%O%s crtbegin%O%s crt0%O%s" + #define ENDFILE_SPEC \ + " crtend%O%s crtn%O%s " \ +diff -NBaur gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64.h gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64.h +--- gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64.h 2017-09-21 13:16:31.171118000 +0100 ++++ gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64.h 2018-01-22 20:15:07.232099998 +0000 +@@ -887,6 +887,10 @@ + /* Check TLS Descriptors mechanism is selected. */ + #define TARGET_TLS_DESC (aarch64_tls_dialect == TLS_DESCRIPTORS) + ++/* Check selected thread pointer access sequence to use. */ ++#define TARGET_HARD_TP (target_thread_pointer == TP_HARD) ++#define TARGET_SOFT_TP (target_thread_pointer == TP_SOFT) ++ + extern enum aarch64_code_model aarch64_cmodel; + + /* When using the tiny addressing model conditional and unconditional branches +diff -NBaur gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64.md gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64.md +--- gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64.md 2017-04-05 12:48:02.927619000 +0100 ++++ gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64.md 2018-01-22 20:15:07.236099934 +0000 +@@ -5230,11 +5230,22 @@ + (define_insn "aarch64_load_tp_hard" + [(set (match_operand:DI 0 "register_operand" "=r") + (unspec:DI [(const_int 0)] UNSPEC_TLS))] +- "" +- "mrs\\t%0, tpidr_el0" ++ "TARGET_HARD_TP" ++ "mrs\\t%0, tpidr_el0\\t// aarch64_load_tp_hard" + [(set_attr "type" "mrs")] + ) + ++(define_insn "aarch64_load_tp_soft" ++ [(set (reg:DI 0) (unspec:DI [(const_int 0)] UNSPEC_TLS)) ++ (clobber (reg:DI IP0_REGNUM)) ++ (clobber (reg:DI IP1_REGNUM)) ++ (clobber (reg:DI LR_REGNUM)) ++ (clobber (reg:CC CC_REGNUM))] ++ "TARGET_SOFT_TP" ++ "bl\\t__aarch64_read_tp\\t// aarch64_load_tp_soft" ++ [(set_attr "type" "branch")] ++) ++ + ;; The TLS ABI specifically requires that the compiler does not schedule + ;; instructions in the TLS stubs, in order to enable linker relaxation. + ;; Therefore we treat the stubs as an atomic sequence. +diff -NBaur gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64.opt gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64.opt +--- gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64.opt 2017-03-17 17:05:23.131899000 +0000 ++++ gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64.opt 2018-01-22 20:15:07.236099934 +0000 +@@ -115,6 +115,20 @@ + EnumValue + Enum(aarch64_tls_size) String(48) Value(48) + ++mtp= ++Target RejectNegative Joined Enum(aarch64_tp_type) Var(target_thread_pointer) Init(TP_HARD) ++Specify how to access the thread pointer. ++ ++Enum ++Name(aarch64_tp_type) Type(enum aarch64_tp_type) ++Valid arguments to -mtp=: ++ ++EnumValue ++Enum(aarch64_tp_type) String(hard) Value(TP_HARD) ++ ++EnumValue ++Enum(aarch64_tp_type) String(soft) Value(TP_SOFT) ++ + march= + Target RejectNegative ToLower Joined Var(aarch64_arch_string) + -march=ARCH Use features of architecture ARCH. +diff -NBaur gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64-opts.h gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64-opts.h +--- gcc-7.3.0-RC-20180122/gcc/config/aarch64/aarch64-opts.h 2017-01-20 00:03:20.347898000 +0000 ++++ gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/aarch64-opts.h 2018-01-22 20:15:07.232099998 +0000 +@@ -48,6 +48,12 @@ + TLS_DESCRIPTORS + }; + ++/* Which thread pointer access sequence to use. */ ++enum aarch64_tp_type { ++ TP_HARD, ++ TP_SOFT ++}; ++ + /* The code model defines the address generation strategy. + Most have a PIC and non-PIC variant. */ + enum aarch64_code_model { +diff -NBaur gcc-7.3.0-RC-20180122/gcc/config/aarch64/t-aarch64 gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/t-aarch64 +--- gcc-7.3.0-RC-20180122/gcc/config/aarch64/t-aarch64 2017-01-01 12:07:43.905435000 +0000 ++++ gcc-7.3.0-RC-20180122-aarch64/gcc/config/aarch64/t-aarch64 2018-01-22 20:15:07.236099934 +0000 +@@ -68,5 +68,7 @@ + $(srcdir)/config/aarch64/cortex-a57-fma-steering.c + + comma=, +-MULTILIB_OPTIONS = $(subst $(comma),/, $(patsubst %, mabi=%, $(subst $(comma),$(comma)mabi=,$(TM_MULTILIB_CONFIG)))) +-MULTILIB_DIRNAMES = $(subst $(comma), ,$(TM_MULTILIB_CONFIG)) ++MULTILIB_OPTIONS = mcmodel=large fPIC ++MULTILIB_DIRNAMES = large pic ++MULTILIB_REQUIRED = mcmodel=large fPIC ++MULTILIB_MATCHES = fPIC=fpic fPIC=fpie fPIC=fPIE +diff -NBaur gcc-7.3.0-RC-20180122/gcc/gcc.c gcc-7.3.0-RC-20180122-aarch64/gcc/gcc.c +--- gcc-7.3.0-RC-20180122/gcc/gcc.c 2017-09-15 09:18:34.015147000 +0100 ++++ gcc-7.3.0-RC-20180122-aarch64/gcc/gcc.c 2018-01-22 20:15:07.236099934 +0000 +@@ -779,6 +779,11 @@ + #endif + #endif + ++#ifndef LIBGLOSS_SPEC ++# define LIBGLOSS_SPEC "-lsysbase" ++#endif ++ ++ + /* config.h can define STARTFILE_SPEC to override the default crt0 files. */ + #ifndef STARTFILE_SPEC + #define STARTFILE_SPEC \ +@@ -1074,6 +1079,7 @@ + static const char *lib_spec = LIB_SPEC; + static const char *link_gomp_spec = ""; + static const char *libgcc_spec = LIBGCC_SPEC; ++static const char *libgloss_spec = LIBGLOSS_SPEC; + static const char *endfile_spec = ENDFILE_SPEC; + static const char *startfile_spec = STARTFILE_SPEC; + static const char *linker_name_spec = LINKER_NAME; +@@ -1579,6 +1585,7 @@ + INIT_STATIC_SPEC ("lib", &lib_spec), + INIT_STATIC_SPEC ("link_gomp", &link_gomp_spec), + INIT_STATIC_SPEC ("libgcc", &libgcc_spec), ++ INIT_STATIC_SPEC ("libgloss", &libgloss_spec), + INIT_STATIC_SPEC ("startfile", &startfile_spec), + INIT_STATIC_SPEC ("cross_compile", &cross_compile), + INIT_STATIC_SPEC ("version", &compiler_version), +diff -NBaur gcc-7.3.0-RC-20180122/libgcc/crtstuff.c gcc-7.3.0-RC-20180122-aarch64/libgcc/crtstuff.c +--- gcc-7.3.0-RC-20180122/libgcc/crtstuff.c 2017-01-01 12:07:43.905435000 +0000 ++++ gcc-7.3.0-RC-20180122-aarch64/libgcc/crtstuff.c 2018-01-22 20:15:07.236099934 +0000 +@@ -47,6 +47,7 @@ + + /* Target machine header files require this define. */ + #define IN_LIBGCC2 ++#define USED_FOR_TARGET + + /* FIXME: Including auto-host is incorrect, but until we have + identified the set of defines that need to go into auto-target.h, +diff -NBaur gcc-7.3.0-RC-20180122/libgcc/Makefile.in gcc-7.3.0-RC-20180122-aarch64/libgcc/Makefile.in +--- gcc-7.3.0-RC-20180122/libgcc/Makefile.in 2017-04-19 09:08:44.446150000 +0100 ++++ gcc-7.3.0-RC-20180122-aarch64/libgcc/Makefile.in 2018-01-22 20:15:07.236099934 +0000 +@@ -844,7 +844,7 @@ + # libgcc_eh.a, only LIB2ADDEH matters. If we do, only LIB2ADDEHSTATIC and + # LIB2ADDEHSHARED matter. (Usually all three are identical.) + +-c_flags := -fexceptions ++c_flags := -fno-exceptions + + ifeq ($(enable_shared),yes) +