aboutsummaryrefslogtreecommitdiffstats
path: root/main/gcc/03_all_gcc48_Makefile.in.patch
blob: 9f6c520cfa59244924762021c6ae7c7f788a988d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
2012-01-17	Magnus Granberg		<zorry@gentoo.org>

		* Makefile.in	We add -fno-stack-protector to BOOT_CFLAGS, LIBCFLAGS and
			LIBCXXFLAGS if enable_esp yes.
		* gcc/Makefile.in	Add -fno-PIE. to ALL_CFLAGS and
			ALL_CXXFLAGS if enable_esp yes.
			Echo enable_esp and enable_crtbeginP to tmp-libgcc.mvars.
		* libgcc/Makefile.in	Add crtbeginP.o to EXTRA_PARTS if enable_crtbeginP yes
			We add new file crtbeginP.o if enable_crtbeginP yes
			Add -fno-PIE. to CRTSTUFF_CFLAGS.

--- a/Makefile.in	2010-01-22 08:35:38.000000000 -0500
+++ b/Makefile.in	2010-02-07 15:10:59.000000000 -0500
@@ -350,9 +350,17 @@
 BUILD_PREFIX = @BUILD_PREFIX@
 BUILD_PREFIX_1 = @BUILD_PREFIX_1@
 
+# Some stuff don't compile with SSP
+enable_esp = @enable_esp@
+ifeq ($(enable_esp),yes)
+ESP_NOSSP_CFLAGS = -fno-stack-protector
+else
+ESP_NOSSP_CFLAGS=
+endif
+
 # Flags to pass to stage2 and later makes.  They are defined
 # here so that they can be overridden by Makefile fragments.
-BOOT_CFLAGS= -g -O2
+BOOT_CFLAGS= -g -O2 $(ESP_NOSSP_CFLAGS)
 BOOT_LDFLAGS=
 BOOT_ADAFLAGS=-gnatpg -gnata
 
@@ -403,9 +403,9 @@
 
 CFLAGS = @CFLAGS@
 LDFLAGS = @LDFLAGS@
-LIBCFLAGS = $(CFLAGS)
+LIBCFLAGS = $(CFLAGS) $(ESP_NOSSP_CFLAGS)
 CXXFLAGS = @CXXFLAGS@
-LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
+LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates $(ESP_NOSSP_CFLAGS)
 GOCFLAGS = $(CFLAGS)
 
 TFLAGS =
--- a/gcc/Makefile.in	2011-11-09 02:20:14.000000000 +0100
+++ b/gcc/Makefile.in	2011-12-24 22:28:08.864804375 +0100
@@ -247,6 +247,14 @@ LINKER_FLAGS = $(CFLAGS)
 endif
 endif
 
+# We don't want to compile the compiler with -fPIE, it make PCH fail.
+enable_esp = @enable_esp@
+ifeq ($(enable_esp),yes)
+ESP_NOPIE_CFLAGS = -fno-PIE
+else
+ESP_NOPIE_CFLAGS=
+endif
+
 # -------------------------------------------
 # Programs which operate on the build machine
 # -------------------------------------------
@@ -974,12 +982,13 @@ INTERNAL_CFLAGS = -DIN_GCC @CROSS@
 
 # This is the variable actually used when we compile. If you change this,
 # you probably want to update BUILD_CFLAGS in configure.ac
-ALL_CFLAGS = $(T_CFLAGS) $(CFLAGS-$@) \
+ALL_CFLAGS = $(ESP_NOPIE_CFLAGS) $(T_CFLAGS) $(CFLAGS-$@) \
   $(CFLAGS) $(INTERNAL_CFLAGS) $(COVERAGE_FLAGS) $(WARN_CFLAGS) @DEFS@
 
 # The C++ version.
-ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS) $(INTERNAL_CFLAGS) \
-  $(COVERAGE_FLAGS) $(NOEXCEPTION_FLAGS) $(WARN_CXXFLAGS) @DEFS@
+ALL_CXXFLAGS = $(ESP_NOPIE_CFLAGS) $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS) \
+  $(INTERNAL_CFLAGS) $(COVERAGE_FLAGS) $(NOEXCEPTION_FLAGS) \
+  $(WARN_CXXFLAGS) @DEFS@
 
 # Likewise.  Put INCLUDES at the beginning: this way, if some autoconf macro
 # puts -I options in CPPFLAGS, our include files in the srcdir will always
@@ -1814,6 +1823,8 @@ libgcc.mvars: config.status Makefile spe
 	echo GCC_CFLAGS = '$(GCC_CFLAGS)' >> tmp-libgcc.mvars
 	echo INHIBIT_LIBC_CFLAGS = '$(INHIBIT_LIBC_CFLAGS)' >> tmp-libgcc.mvars
 	echo TARGET_SYSTEM_ROOT = '$(TARGET_SYSTEM_ROOT)' >> tmp-libgcc.mvars
+	echo enable_esp = '$(enable_esp)' >> tmp-libgcc.mvars
+	echo enable_crtbeginP = '@enable_crtbeginP@' >> tmp-libgcc.mvars
 
 	mv tmp-libgcc.mvars libgcc.mvars
 
--- a/libgcc/Makefile.in	2011-11-22 04:01:02.000000000 +0100
+++ b/libgcc/Makefile.in	2011-12-25 15:18:22.449610631 +0100
@@ -219,6 +219,17 @@ else
 DECNUMINC =
 endif
 
+ifeq ($(enable_esp),yes)
+ESP_NOPIE_CFLAGS = -fno-PIE
+else
+ESP_NOPIE_CFLAGS=
+endif
+
+# We add crtbeginP.o to the EXTRA_PARTS list if enable_crtbeginP = yes
+ifeq ($(enable_crtbeginP),yes)
+EXTRA_PARTS += crtbeginP.o
+endif
+
 # Options to use when compiling libgcc2.a.
 #
 LIBGCC2_DEBUG_CFLAGS = -g
@@ -279,7 +290,7 @@ INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CF
 CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
   -finhibit-size-directive -fno-inline -fno-exceptions \
   -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
-  -fno-stack-protector \
+  -fno-stack-protector $(ESP_NOPIE_CFLAGS) \
   $(INHIBIT_LIBC_CFLAGS)
 
 # Extra flags to use when compiling crt{begin,end}.o.
@@ -966,6 +977,13 @@ crtendS$(objext): $(srcdir)/crtstuff.c
 # This is a version of crtbegin for -static links.
 crtbeginT$(objext): $(srcdir)/crtstuff.c
 	$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN -DCRTSTUFFT_O
+
+# This is a version of crtbegin for -static -fPIE links.
+ifeq ($(enable_crtbeginP),yes)
+crtbeginP$(objext): $(srcdir)/crtstuff.c
+	$(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
+	  -c $< -DCRT_BEGIN -DCRTSTUFFT_O -DCRTSTUFFS_O
+endif
 endif
 
 ifeq ($(CUSTOM_CRTIN),)