From f8414ac2b5ef5120417d6f3f945f7059cdddabeb Mon Sep 17 00:00:00 2001
From: Cem Keylan <cem@ckyln.com>
Date: Mon, 10 Feb 2020 10:17:39 +0300
Subject: gcc: https://github.com/kisslinux/repo#96ad6fb

---
 core/gcc/build                           |  6 ++-
 core/gcc/checksums                       |  2 +
 core/gcc/patches/invalid_tls_model.patch | 26 ++++++++++
 core/gcc/patches/static-pie.patch        | 88 ++++++++++++++++++++++++++++++++
 core/gcc/sources                         |  4 +-
 core/gcc/version                         |  2 +-
 6 files changed, 125 insertions(+), 3 deletions(-)
 create mode 100644 core/gcc/patches/invalid_tls_model.patch
 create mode 100644 core/gcc/patches/static-pie.patch

(limited to 'core/gcc')

diff --git a/core/gcc/build b/core/gcc/build
index ef0e87db..29c1226c 100755
--- a/core/gcc/build
+++ b/core/gcc/build
@@ -1,5 +1,8 @@
 #!/bin/sh -e
 
+patch -p1 < invalid_tls_model.patch
+patch -p1 < static-pie.patch
+
 # Make sure gmp is built with generic options.
 cp -v gcc/gmp/configfsf.guess gcc/gmp/config.guess
 cp -v gcc/gmp/configfsf.sub   gcc/gmp/config.sub
@@ -35,7 +38,8 @@ export libat_cv_have_ifunc=no
     --enable-threads \
     --enable-tls \
     --enable-languages=c,c++ \
-    --build=x86_64-pc-linux-musl
+    --build=x86_64-pc-linux-musl \
+    --disable-bootstrap
 
 make
 make DESTDIR="$1" install
diff --git a/core/gcc/checksums b/core/gcc/checksums
index 30470230..b469a51c 100644
--- a/core/gcc/checksums
+++ b/core/gcc/checksums
@@ -3,3 +3,5 @@ ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206  gcc-9.2.0.tar.
 1d3be708604eae0e42d578ba93b390c2a145f17743a744d8f3f8c2ad5855a38a  mpfr-4.0.2.tar.xz
 6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e  mpc-1.1.0.tar.gz
 765614b3396d70bca3fa0ae4a813632486c6dca320e2bd13c8c39dca52be4a4c  c99
+b0bf792c3f5278e768b7199cc94e8c57e364eb0b70dc5a226d47eb9e25e1dac9  invalid_tls_model.patch
+0d1e72a788dea767057893f63112ccc69755c40239c8ae141cf55e4075affad3  static-pie.patch
diff --git a/core/gcc/patches/invalid_tls_model.patch b/core/gcc/patches/invalid_tls_model.patch
new file mode 100644
index 00000000..b47a67d1
--- /dev/null
+++ b/core/gcc/patches/invalid_tls_model.patch
@@ -0,0 +1,26 @@
+--- a/gcc/libgomp/configure.tgt	2018-11-08 18:13:04.000000000 +0100
++++ b/gcc/libgomp/configure.tgt	2019-06-29 20:06:31.972950350 +0200
+@@ -10,23 +10,6 @@
+ #  XCFLAGS		Add extra compile flags to use.
+ #  XLDFLAGS		Add extra link flags to use.
+
+-# Optimize TLS usage by avoiding the overhead of dynamic allocation.
+-if test $gcc_cv_have_tls = yes ; then
+-  case "${target}" in
+-
+-    *-*-k*bsd*-gnu*)
+-	;;
+-
+-    *-*-linux* | *-*-gnu*)
+-	XCFLAGS="${XCFLAGS} -ftls-model=initial-exec -DUSING_INITIAL_EXEC_TLS"
+-	;;
+-
+-    *-*-rtems*)
+-	XCFLAGS="${XCFLAGS} -ftls-model=local-exec"
+-	;;
+-  esac
+-fi
+-
+ # Since we require POSIX threads, assume a POSIX system by default.
+ config_path="posix"
+
diff --git a/core/gcc/patches/static-pie.patch b/core/gcc/patches/static-pie.patch
new file mode 100644
index 00000000..e759f375
--- /dev/null
+++ b/core/gcc/patches/static-pie.patch
@@ -0,0 +1,88 @@
+diff --git a/gcc/common.opt b/gcc/common.opt
+index b52ef0b38c8..0ce5857e01d 100644
+--- a/gcc/gcc/common.opt
++++ b/gcc/gcc/common.opt
+@@ -3197,11 +3197,11 @@ Driver
+
+ no-pie
+ Driver RejectNegative Negative(shared)
+-Don't create a dynamically linked position independent executable.
++Don't create a position independent executable.
+
+ pie
+ Driver RejectNegative Negative(no-pie)
+-Create a dynamically linked position independent executable.
++Create a position independent executable.
+
+ static-pie
+ Driver RejectNegative Negative(pie)
+diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
+index 8620de3e42d..235328a2642 100644
+--- a/gcc/gcc/config/gnu-user.h
++++ b/gcc/gcc/config/gnu-user.h
+@@ -51,13 +51,12 @@
+ #define GNU_USER_TARGET_STARTFILE_SPEC \
+   "%{shared:; \
+      pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \
+-     static:crt1.o%s; \
+-     static-pie:rcrt1.o%s; \
++     static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \
+      " PIE_SPEC ":Scrt1.o%s; \
+      :crt1.o%s} " \
+    GNU_USER_TARGET_CRTI " \
+-   %{static:crtbeginT.o%s; \
+-     shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
++   %{shared|" PIE_SPEC ":crtbeginS.o%s; \
++     static:crtbeginT.o%s; \
+      :crtbegin.o%s} \
+    %{fvtable-verify=none:%s; \
+      fvtable-verify=preinit:vtv_start_preinit.o%s; \
+@@ -76,8 +75,7 @@
+   "%{fvtable-verify=none:%s; \
+      fvtable-verify=preinit:vtv_end_preinit.o%s; \
+      fvtable-verify=std:vtv_end.o%s} \
+-   %{static:crtend.o%s; \
+-     shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
++   %{shared|" PIE_SPEC ":crtendS.o%s; \
+      :crtend.o%s} " \
+    GNU_USER_TARGET_CRTN " " \
+    CRTOFFLOADEND
+@@ -106,7 +104,7 @@
+ #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
+
+ #if defined(HAVE_LD_EH_FRAME_HDR)
+-#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
++#define LINK_EH_SPEC "%{!static|" PIE_SPEC ":--eh-frame-hdr} "
+ #endif
+
+ #define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \
+diff --git a/gcc/gcc.c b/gcc/gcc.c
+index eb1610ba8b0..87560afb03c 100644
+--- a/gcc/gcc/gcc.c
++++ b/gcc/gcc/gcc.c
+@@ -900,7 +900,7 @@ proper position among the other output files.  */
+ #define NO_FPIE_AND_FPIC_SPEC	NO_FPIE_SPEC "|" NO_FPIC_SPEC
+ #define FPIE_OR_FPIC_SPEC	NO_FPIE_AND_FPIC_SPEC ":;"
+ #else
+-#define PIE_SPEC		"pie"
++#define PIE_SPEC		"pie|static-pie"
+ #define FPIE1_SPEC		"fpie"
+ #define NO_FPIE1_SPEC		FPIE1_SPEC ":;"
+ #define FPIE2_SPEC		"fPIE"
+@@ -924,12 +924,12 @@ proper position among the other output files.  */
+ #ifndef LINK_PIE_SPEC
+ #ifdef HAVE_LD_PIE
+ #ifndef LD_PIE_SPEC
+-#define LD_PIE_SPEC "-pie"
++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}"
+ #endif
+ #else
+ #define LD_PIE_SPEC ""
+ #endif
+-#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
++#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
+ #endif
+
+ #ifndef LINK_BUILDID_SPEC
+--
+2.17.1
diff --git a/core/gcc/sources b/core/gcc/sources
index a76e4eeb..19eabd0d 100644
--- a/core/gcc/sources
+++ b/core/gcc/sources
@@ -1,5 +1,7 @@
 https://gcc.gnu.org/pub/gcc/releases/gcc-9.2.0/gcc-9.2.0.tar.xz gcc
 https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz gcc/gmp
-https://www.mpfr.org/mpfr-current/mpfr-4.0.2.tar.xz gcc/mpfr
+https://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz gcc/mpfr
 https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz gcc/mpc
 files/c99
+patches/invalid_tls_model.patch
+patches/static-pie.patch
diff --git a/core/gcc/version b/core/gcc/version
index b821d350..257b3f16 100644
--- a/core/gcc/version
+++ b/core/gcc/version
@@ -1 +1 @@
-9.2.0 1
+9.2.0 2
-- 
cgit v1.2.3