1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/gcc/gcc.conf
3 # Copyright (C) 2004 - 2022 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2.
10 # --- T2-COPYRIGHT-NOTE-END ---
14 if [ $stagelevel -le 1 ]; then
15 var_append confopt " " "--program-prefix=${arch_target}-"
16 toolsroot="${sysroot}/TOOLCHAIN/tools.cross"
17 export LDFLAGS="-Wl,-rpath,${toolsroot}/lib"
19 var_append patchfiles " " "$confdir/gxx_include.diff"
21 if atstage toolchain; then
22 bindir="/$prefix/crosscc"
23 var_append confopt " " "--with-sysroot=$sysroot"
24 var_append confopt " " "--disable-shared"
25 var_append confopt " " "--disable-libatomic --disable-libstdc++-v3 --disable-libsanitizer"
26 var_append confopt " " "--disable-libssp --disable-libgomp --disable-cet"
27 var_append confopt " " "--disable-target-libiberty --disable-vtable-verify"
28 var_append confopt " " "--disable-libitm --disable-libcilkrts"
29 var_append confopt " " "--disable-libquadmath --disable-decimal-float"
30 elif [ $stagelevel = 1 ]; then
31 if [ "$SDECFG_LIBC" = "glibc" ]; then
32 CC="cc" CXX="c++" CPP="cpp" OBJDUMP="objdump"
33 AS="as" STRIP="strip" OBJCOPY="objcopy"
34 LD="ld" AR="ar" RANLIB="ranlib" NM="nm"
36 var_remove_regex confopt ' ' '--prefix=.*'
37 var_remove_regex confopt ' ' '--bindir=.*'
38 var_remove_regex confopt ' ' '--libdir=.*'
39 var_remove_regex confopt ' ' '--includedir=.*'
40 var_insert confopt ' ' "--libexecdir=$toolsroot/$prefix/libexec"
41 var_insert confopt ' ' "--libdir=$toolsroot/$prefix/lib"
42 var_insert confopt ' ' "--bindir=$toolsroot/$prefix/crosscc"
43 var_insert confopt ' ' "--prefix=$toolsroot/$prefix"
45 var_remove_regex confopt ' ' '--datadir=.*'
46 var_remove_regex confopt ' ' '--infodir=.*'
47 var_remove_regex confopt ' ' '--mandir=.*'
48 var_remove_regex confopt ' ' '--sbindir=.*'
49 var_remove_regex confopt ' ' '--localstatedir=.*'
50 var_remove_regex confopt ' ' '--sysconfdir=.*'
52 var_remove_regex confopt ' ' '--host=.*'
53 var_append confopt ' ' "--host=\$arch_build"
55 var_remove_regex makeopt ' ' 'prefix=.*'
56 var_remove_regex makeinstopt ' ' 'prefix=.*'
57 var_remove_regex makeinstopt ' ' 'DESTDIR=.*'
58 var_remove_regex makeinstopt ' ' 'docdir=.*'
60 # override to install headers into the actual sysroot
61 var_append confopt ' ' "--with-gxx-include-dir=$root$includedir/c++/$ver"
62 var_append confopt ' ' "--with-toolexeclibdir=$root$libdir"
64 configscript="../libstdc++-v3/configure"
68 # we need to help configure pick up our native libraries in the toolchain dir
69 var_append extraconfopt ' ' '--with-mpfr=$toolsroot --with-mpfr-lib=$toolsroot/lib'
70 var_append extraconfopt ' ' '--with-ppl=$toolsroot --with-cloog=$toolsroot --with-gmp=$toolsroot'
71 pkginstalled isl && var_append extraconfopt ' ' '--with-isl=$toolsroot'
75 if ! atstage toolchain; then
76 [ $stagelevel = 2 ] &&
77 confopt="${confopt/--with-sysroot/--with-libtool-sysroot}"
79 # shared, or not shared?
80 if [ "$diet_dynamic_static" == "static" ]; then
81 var_append confopt " " "--disable-shared"
83 var_append confopt " " "--enable-shared"
86 var_append languages ',' "go,objc,fortran"
87 if which gnat >/dev/null; then
88 # Note: Ada support is implemented in Ada, so GNAT has to be
89 # present on the build system to be able to build it.
90 var_append languages ',' "ada"
92 var_append confopt " " "--with-gnu-as --with-gnu-ld --enable-threads=posix"
95 # not relied on by T2, but for the actual system user to get the same
97 avr32|blackfin|ia64) ;;
99 for x in $GCC_WRAPPER_INSERT $GCC_WRAPPER_APPEND; do
101 -march=*) var_append confopt " " "${x/-m/--with-}" ;;
102 -mcpu=*) var_append confopt " " "${x/-m/--with-}" ;;
103 -mtune=*) var_append confopt " " "${x/-m/--with-}" ;;
108 # at least the fortran parts get unresolved errors when we remove -Werror???
109 var_remove GCC_WRAPPER_REMOVE " " "-Werror"
110 # emmintrin.h: error: cast discards 'const' qualifier from pointer target type [-Werror=cast-qual]
111 var_append GCC_WRAPPER_REMOVE ' ' '*/libgo/*?-Werror:'
113 # create and set up cmd_wrapper for xgcc
114 function setup_xgcc_wrapper() {
117 cat <<-EOF > xgcc-wrapper
119 # place the xgcc in the path
120 export PATH="$PWD:\$PATH"
121 [ "\$GCC_WRAPPER_DEBUG" = 1 ] && export CMD_WRAPPER_DEBUG=1
123 if [ "\${mycmd%gcj}" != "\$mycmd" ]; then
124 export CMD_WRAPPER_OTHERS="\$GCJ_WRAPPER_OTHERS"
125 export CMD_WRAPPER_INSERT="\$GCJ_WRAPPER_INSERT"
126 export CMD_WRAPPER_REMOVE="\$GCJ_WRAPPER_REMOVE"
127 export CMD_WRAPPER_APPEND="\$GCJ_WRAPPER_APPEND"
128 export CMD_WRAPPER_FILTER="\$GCJ_WRAPPER_FILTER"
129 elif [ "\${mycmd%gfortran}" != "\$mycmd" ]; then
130 export CMD_WRAPPER_OTHERS="\$F95_WRAPPER_OTHERS"
131 export CMD_WRAPPER_INSERT="\$F95_WRAPPER_INSERT"
132 export CMD_WRAPPER_REMOVE="\$F95_WRAPPER_REMOVE"
133 export CMD_WRAPPER_APPEND="\$F95_WRAPPER_APPEND"
134 export CMD_WRAPPER_FILTER="\$F95_WRAPPER_FILTER"
135 elif [ "\${mycmd%g++}" != "\$mycmd" ]; then
136 export CMD_WRAPPER_OTHERS="\$CXX_WRAPPER_OTHERS:\$GCC_WRAPPER_OTHERS"
137 export CMD_WRAPPER_INSERT="\$CXX_WRAPPER_INSERT \$GCC_WRAPPER_INSERT"
138 export CMD_WRAPPER_REMOVE="\$CXX_WRAPPER_REMOVE \$GCC_WRAPPER_REMOVE"
139 export CMD_WRAPPER_APPEND="\$CXX_WRAPPER_APPEND \$GCC_WRAPPER_APPEND"
140 export CMD_WRAPPER_FILTER="\$CXX_WRAPPER_FILTER|\$GCC_WRAPPER_FILTER"
142 export CMD_WRAPPER_OTHERS="\$CC_WRAPPER_OTHERS:\$GCC_WRAPPER_OTHERS"
143 export CMD_WRAPPER_INSERT="\$CC_WRAPPER_INSERT \$GCC_WRAPPER_INSERT"
144 export CMD_WRAPPER_REMOVE="\$CC_WRAPPER_REMOVE \$GCC_WRAPPER_REMOVE"
145 export CMD_WRAPPER_APPEND="\$CC_WRAPPER_APPEND \$GCC_WRAPPER_APPEND"
146 export CMD_WRAPPER_FILTER="\$CC_WRAPPER_FILTER|\$GCC_WRAPPER_FILTER"
148 exec cmd_wrapper "\$@"
151 chmod 0755 xgcc-wrapper
152 export STAGE_CC_WRAPPER=$PWD/xgcc-wrapper
157 # historically we did not had to explicitly specifiy the target for "Canadian
158 # crossbuild", since gcc-4.3 we have to:
159 var_append confopt ' ' "--target=${arch_target}"
161 # See http://gcc.gnu.org/gcc-3.2/c++-abi.html
162 # and http://www.codesourcery.com/cxx-abi/.
163 var_append confopt ' ' "--enable-__cxa_atexit"
165 # we might build a SVN or prereleases, disable checking
166 var_append confopt ' ' '--disable-checking'
168 # we build a cross compiler in stage0 and later use known good GCCs, no bstrap
169 var_append confopt ' ' '--disable-bootstrap'
171 # not really useful and just blows up the binary package
172 var_append confopt ' ' '--disable-libstdcxx-pch'
174 # add the multi-lib config
175 if [ "$SDECFG_MULTILIB" = 1 ]; then
176 # JLR, this sometimes causes trouble
177 # it is on by default, so do not enable it here
178 # see GCC Bug 43328 - multilib bootstrap broken.
179 # var_append confopt ' ' "--enable-multilib"
180 if [ -n "$SDECFG_MULTILIBLIST" ]; then
181 var_append confopt ' ' "--with-multilib-list=$SDECFG_MULTILIBLIST"
184 var_append confopt ' ' "--disable-multilib"
187 if [ "$SDECFG_LTO" == 1 ]; then
188 var_append SYSGCC_WRAPPER_INSERT " " "*/gcc/*.c*?-flto=${SDECFG_PARALLEL_MAX:-auto}"
189 var_append GCC_WRAPPER_INSERT " " "*/gcc/*.c*?-flto=${SDECFG_PARALLEL_MAX:-auto}"
192 # only left for uclibc libatomic
196 configscript="../../$x/configure"
197 eval_config_command $confopt
199 eval $MAKE $makeinstopt
201 configscript=../configure
205 if atstage cross; then
206 # canadian cross also needs to know the build root to find headers, e.g. for fixincludes
207 var_append confopt ' ' '--with-build-sysroot=$root'
209 if [ "$SDECFG_KERNEL" = mingw ]; then
210 configscript="../libstdc++-v3/configure"
215 # create and set up the xgcc cmd_wrapper
218 # install binutils bfd lto plugin
219 mkdir -pv $root$libdir/bfd-plugins/
220 ln -sfv ../../libexec/gcc/$arch_target/$desc_V/liblto_plugin.so \
221 $root$libdir/bfd-plugins/
225 # force a tools rebuild
226 rm -fv $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/.lastupdate
228 # only minimal adaptions for stage0
229 if atstage toolchain; then
231 ln -svf ${arch_target}-gcc \
232 $root/$prefix/crosscc/${arch_target}-$x
235 ln -svf ${arch_target}-gcc $root/$prefix/crosscc/${arch_target}-cc
236 rm -vf "$root/$prefix/crosscc/{gcc,gcj}"
240 # Create various symlinks for cc, c++, cpp and f77.
241 ln -sfv gcc $root/$prefix/bin/cc
242 ln -sfv ../$prefix/bin/cpp $root/lib/cpp
243 ln -sfv gcc $root/$prefix/bin/kcc
244 if [ -f $root/$prefix/bin/gfortran ]; then
245 ln -sfv gfortran $root/$prefix/bin/f77
249 if [ "$SDECFG_LIBC" != "glibc" ]; then
250 var_append confopt " " "--disable-libsanitizer"
251 var_remove languages ',' "go"
254 # 32-bit default 64-bit biarch configuration
255 if [ "$SDECFG_POWERPC64_32" = 1 -o "$SDECFG_SPARC64_32BIT" = 1 ]; then
256 [ $arch = "powerpc64" ] && var_append confopt " " "--with-cpu=default32"
257 var_append patchfiles " " "$confdir/m32-default.diff"
259 var_remove languages ',' "fortran" # why?
260 var_remove languages ',' "go"
262 function gcc_default_m32() {
263 eval $MAKE $makeopt all-host
264 var_append GCC_WRAPPER_INSERT " " "-m32?:-m64"
267 # simulate -m64 default thru our wrapper for the target multilibs
268 hook_add premake 7 "gcc_default_m32"
271 hook_add premake 5 "gcc_premake"
272 hook_add postmake 5 "gcc_postmake"
274 var_insert confopt ' ' '--enable-languages=$languages'