]> git.ipfire.org Git - ipfire-2.x.git/blame - lfs/gcc
gcc: Update to 13.1.0
[ipfire-2.x.git] / lfs / gcc
CommitLineData
cd1a2927 1###############################################################################
cd1a2927 2# #
70df8302 3# IPFire.org - A linux based firewall #
4e6fcc73 4# Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
70df8302
MT
5# #
6# This program is free software: you can redistribute it and/or modify #
cd1a2927 7# it under the terms of the GNU General Public License as published by #
70df8302 8# the Free Software Foundation, either version 3 of the License, or #
cd1a2927
MT
9# (at your option) any later version. #
10# #
70df8302 11# This program is distributed in the hope that it will be useful, #
cd1a2927
MT
12# but WITHOUT ANY WARRANTY; without even the implied warranty of #
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14# GNU General Public License for more details. #
15# #
16# You should have received a copy of the GNU General Public License #
70df8302 17# along with this program. If not, see <http://www.gnu.org/licenses/>. #
cd1a2927 18# #
cd1a2927
MT
19###############################################################################
20
21###############################################################################
22# Definitions
23###############################################################################
24
25include Config
26
df1a3f56 27VER = 13.1.0
82b312a9 28
570590a2 29GMP_VER = 6.2.1
32bbae10 30MPFR_VER = 4.2.0
df1a3f56 31MPC_VER = 1.3.1
cd1a2927
MT
32
33THISAPP = gcc-$(VER)
11b5e5cb 34DL_FILE = $(THISAPP).tar.xz
dd714b8a 35DL_FROM = $(URL_IPFIRE)
cd1a2927 36DIR_APP = $(DIR_SRC)/$(THISAPP)
cd1a2927 37
05c54e82 38ifeq "$(PASS)" "1"
ed635824 39CFLAGS := $(patsubst -march=%,,$(CFLAGS))
f3c01b39 40CFLAGS := $(patsubst -mfpu=%,,$(CFLAGS))
ed635824 41CFLAGS := $(patsubst -mtune=%,,$(CFLAGS))
62a430f9 42CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS))
8675b78a 43CFLAGS := $(filter-out -fexceptions,$(CFLAGS))
11b5e5cb 44
11b5e5cb
AF
45CFLAGS := $(patsubst -mindirect-branch=%,,$(CFLAGS))
46CFLAGS := $(patsubst -mfunction-return=%,,$(CFLAGS))
d83422d1
AF
47CFLAGS := $(patsubst -fstack-clash-protection,,$(CFLAGS))
48CFLAGS := $(patsubst -fcf-protection,,$(CFLAGS))
11b5e5cb
AF
49endif
50
8675b78a 51CXXFLAGS := $(CFLAGS)
ff1d5f3a 52
6c4cc7ea 53# Normal build or $(TOOLS_DIR) build.
cd1a2927
MT
54#
55ifeq "$(ROOT)" ""
56 TARGET = $(DIR_INFO)/$(THISAPP)
afbd9856
MT
57 EXTRA_CONFIG = \
58 --prefix=/usr \
59 --libexecdir=/usr/lib \
60 --enable-shared \
61 --enable-threads=posix \
62 --enable-__cxa_atexit \
63 --enable-clocale=gnu \
eed179ac 64 --enable-languages=c,c++ \
afbd9856
MT
65 --disable-bootstrap \
66 --disable-nls
857d9bf2
MT
67 EXTRA_MAKE =
68 EXTRA_INSTALL =
b2af45b2
AF
69ifeq "$(PASS)" "A"
70 TARGET = $(DIR_INFO)/$(THISAPP)-libatomic
71endif
cd1a2927 72else
15679d9f 73ifeq "$(PASS)" "1"
cd1a2927 74 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
82b312a9
MT
75 EXTRA_CONFIG = \
76 --target=$(CROSSTARGET) \
6c4cc7ea 77 --prefix=$(TOOLS_DIR) \
764a3f1f 78 --with-sysroot=$(ROOT) \
6c4cc7ea
MT
79 --with-local-prefix=$(TOOLS_DIR) \
80 --with-native-system-header-dir=$(TOOLS_DIR)/include \
e111b836 81 --with-glibc-version=2.11 \
82b312a9
MT
82 --disable-nls \
83 --disable-shared \
e111b836 84 --disable-multilib \
82b312a9
MT
85 --disable-decimal-float \
86 --disable-threads \
764a3f1f 87 --disable-libatomic \
82b312a9
MT
88 --disable-libmudflap \
89 --disable-libssp \
8bc5ded2 90 --disable-libmpx \
82b312a9
MT
91 --disable-libgomp \
92 --disable-libquadmath \
764a3f1f
AF
93 --disable-libstdc++-v3 \
94 --disable-libvtv \
95 --disable-libcilkrts \
96 --disable-libitm \
97 --disable-libsanitizer \
82b312a9
MT
98 --with-newlib \
99 --without-headers \
100 --without-ppl \
101 --without-cloog \
764a3f1f 102 --enable-languages=c,c++
66c36198
PM
103 EXTRA_MAKE =
104 EXTRA_INSTALL =
cd1a2927 105else
764a3f1f 106ifeq "$(PASS)" "2"
cd1a2927 107 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
82b312a9 108 EXTRA_ENV = \
6f8f4522 109 CC="$(CROSSTARGET)-gcc" \
764a3f1f 110 CXX="$(CROSSTARGET)-g++" \
82b312a9
MT
111 AR="$(CROSSTARGET)-ar" \
112 RANLIB="$(CROSSTARGET)-ranlib"
113 EXTRA_CONFIG = \
c16a83df
MT
114 --build=$(BUILDTARGET) \
115 --host=$(BUILDTARGET) \
6c4cc7ea
MT
116 --prefix=$(TOOLS_DIR) \
117 --with-local-prefix=$(TOOLS_DIR) \
118 --with-native-system-header-dir=$(TOOLS_DIR)/include \
39f94ee8 119 --disable-bootstrap \
82b312a9
MT
120 --enable-languages=c,c++ \
121 --disable-libstdcxx-pch \
e111b836 122 --disable-multilib \
b45e371f 123 --disable-libgomp
66c36198
PM
124 EXTRA_MAKE =
125 EXTRA_INSTALL =
764a3f1f
AF
126else
127 # PASS=L # libstdc++-v3
128 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
129 EXTRA_ENV = \
6f8f4522 130 CC="$(CROSSTARGET)-gcc" \
764a3f1f
AF
131 AR="$(CROSSTARGET)-ar" \
132 RANLIB="$(CROSSTARGET)-ranlib"
133 EXTRA_CONFIG = \
134 --host=$(CROSSTARGET) \
6c4cc7ea 135 --prefix=$(TOOLS_DIR) \
764a3f1f
AF
136 --with-sysroot=$(ROOT) \
137 --disable-shared \
138 --disable-nls \
139 --disable-libstdcxx-threads \
140 --disable-libstdcxx-pch \
6c4cc7ea 141 --with-gxx-include-dir=$(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)
66c36198
PM
142 EXTRA_MAKE =
143 EXTRA_INSTALL =
764a3f1f 144endif
cd1a2927
MT
145endif
146endif
147
0c30619a
MT
148ifeq "$(BUILD_ARCH)" "aarch64"
149 EXTRA_CONFIG += \
150 --enable-standard-branch-protection
151endif
152
e3a093f5
MT
153ifeq "$(BUILD_ARCH)" "riscv64"
154 EXTRA_CONFIG += \
155 --with-arch=rv64gc \
156 --with-abi=lp64d
157endif
158
ed635824 159EXTRA_CONFIG += \
51777e5d 160 --disable-multilib \
4e6fcc73 161 --with-bugurl=https://bugzilla.ipfire.org \
ed635824 162 --disable-libunwind-exceptions \
8fa66ce7 163 --enable-gnu-unique-object
ed635824 164
51f9e7ac
MT
165export XCFLAGS = $(CFLAGS)
166export TCFLAGS = $(CFLAGS)
167
cd1a2927
MT
168###############################################################################
169# Top-level Rules
170###############################################################################
82b312a9
MT
171
172objects = $(DL_FILE) \
11b5e5cb
AF
173 gmp-$(GMP_VER).tar.xz \
174 mpfr-$(MPFR_VER).tar.xz \
8675b78a 175 mpc-$(MPC_VER).tar.gz
cd1a2927 176
41921bd9 177$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
176b1cc6 178gmp-$(GMP_VER).tar.xz = $(DL_FROM)/gmp-$(GMP_VER).tar.xz
11b5e5cb 179mpfr-$(MPFR_VER).tar.xz = $(DL_FROM)/mpfr-$(MPFR_VER).tar.xz
8675b78a 180mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
cd1a2927 181
df1a3f56 182$(DL_FILE)_BLAKE2 = b956a773cffe8b43bd6c9a99fe614f53f665438925a6b320975d301f547923e45d4d6fa577a143467fb03e0a9c1bab2b6719a1011d672367f3e644433a2d7606
9a7e4d85 183gmp-$(GMP_VER).tar.xz_BLAKE2 = c0d85f175392a50cfa01bc6b0a312b235946ad8b4f6f84f6dabd33d7a6f2cc75c9b0e1e33057be07750bfa0145b7c4cf3b6188a5be6ca9d7271ec2276c84ebcb
32bbae10 184mpfr-$(MPFR_VER).tar.xz_BLAKE2 = dd88ae3a6a910ad8faeb791b49c3b1085de5d0d4c49c637c124bf4d9bc79fb621d0d1d69e07d0642b9b678f6d355a5830d083dfd189e1e91d0e04c970c10bd64
df1a3f56 185mpc-$(MPC_VER).tar.gz_BLAKE2 = 76434e6f8830af3571836d51576bfebbc9701e9bbb5c4686f134081cd96cd90ae02f7ff42bf9e3957c7a7ba92b6b2d9cdabe18f0269271147521cd7f6a2d551c
cd1a2927
MT
186
187install : $(TARGET)
188
189check : $(patsubst %,$(DIR_CHK)/%,$(objects))
190
191download :$(patsubst %,$(DIR_DL)/%,$(objects))
192
9a7e4d85 193b2 : $(subst %,%_BLAKE2,$(objects))
cd1a2927
MT
194
195###############################################################################
9a7e4d85 196# Downloading, checking, b2sum
cd1a2927
MT
197###############################################################################
198
199$(patsubst %,$(DIR_CHK)/%,$(objects)) :
200 @$(CHECK)
201
202$(patsubst %,$(DIR_DL)/%,$(objects)) :
203 @$(LOAD)
204
9a7e4d85
PM
205$(subst %,%_BLAKE2,$(objects)) :
206 @$(B2SUM)
cd1a2927
MT
207
208###############################################################################
209# Installation Details
210###############################################################################
211
212$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
213 @$(PREBUILD)
8675b78a 214 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
dd714b8a 215 @mkdir $(DIR_SRC)/gcc-build
51f9e7ac 216
991d11d7
MT
217 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
218 cd $(DIR_APP) && sed -i gcc/Makefile.in \
219 -e 's@\./fixinc\.sh@-c true@' \
220 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
221
222ifeq "$(TOOLCHAIN)" "1"
82b312a9 223 # Build gmp and mpfr internally in toolchain.
11b5e5cb 224 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.xz
82b312a9 225 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
11b5e5cb 226 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.xz
82b312a9 227 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
8675b78a
MT
228 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
229 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
82b312a9 230
991d11d7 231ifeq "$(PASS)" "2"
764a3f1f 232 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
6c4cc7ea 233 `dirname $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
991d11d7
MT
234endif
235
82b312a9 236 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
cfd39a32 237 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
82b312a9
MT
238 echo "Processing $${file}..."; \
239 sed -i $${file} \
6c4cc7ea
MT
240 -e 's@/lib\(64\)\?\(32\)\?/ld@$(TOOLS_DIR)&@g' \
241 -e 's@/usr@$(TOOLS_DIR)@g'; \
764a3f1f
AF
242 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
243 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
6c4cc7ea 244 echo '#define STANDARD_STARTFILE_PREFIX_1 "$(TOOLS_DIR)/lib/"' >> $${file}; \
82b312a9
MT
245 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
246 done
82b312a9 247endif
dd714b8a 248
991d11d7 249ifeq "$(PASS)" "L"
764a3f1f
AF
250 # libstdc++ pass
251 cd $(DIR_SRC)/gcc-build && \
252 $(EXTRA_ENV) \
253 $(DIR_APP)/libstdc++-v3/configure \
254 $(EXTRA_CONFIG)
79ccd55d 255 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
764a3f1f 256 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
b2af45b2
AF
257else
258ifeq "$(PASS)" "A"
259 # libatomic pass
260 cd $(DIR_SRC)/gcc-build && \
261 $(EXTRA_ENV) \
262 $(DIR_APP)/libatomic/configure \
263 $(EXTRA_CONFIG)
264 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
265 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
764a3f1f 266else
82b312a9
MT
267 # The actual build.
268 cd $(DIR_SRC)/gcc-build && \
269 $(EXTRA_ENV) \
270 $(DIR_APP)/configure \
271 $(EXTRA_CONFIG)
3c2b8c6c 272 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE) $(MAKETUNING)
f97be0a6 273 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
764a3f1f 274endif
b2af45b2 275endif
82b312a9 276
991d11d7
MT
277ifeq "$(TOOLCHAIN)" "1"
278 ifeq "$(PASS)" "1"
6c4cc7ea 279 ln -svf libgcc.a $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
991d11d7
MT
280 endif
281
282 ifeq "$(PASS)" "2"
6c4cc7ea 283 ln -svf gcc $(TOOLS_DIR)/bin/cc
8f2ac12a 284 # remove gdb python files from libdir
6c4cc7ea 285 rm -rf $(TOOLS_DIR)/lib/*-gdb.py
991d11d7
MT
286 endif
287
288 ifeq "$(PASS)" "L"
289 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
6c4cc7ea 290 sed -e "s/^#include_next/#include/" -i $(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
991d11d7
MT
291 endif
292
293else # NON-TOOLCHAIN
294 ln -svf ../usr/bin/cpp /lib
295 ln -svf gcc /usr/bin/cc
296 # remove gdb python files from libdir
297 rm -rf /usr/lib/*-gdb.py
cd1a2927 298endif
991d11d7 299
cd1a2927
MT
300 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
301 @$(POSTBUILD)