@@ -114,7 +114,6 @@ for target_arch in ${TARGET_ARCH_STR//,/ }; do
114114 ;;
115115 esac
116116
117- export BOOT_CFLAGS=' -O2 -g0 -pipe'
118117 export CFLAGS=" -O${OPT} -ffunction-sections -fdata-sections -fmerge-all-constants -fomit-frame-pointer -fPIC"
119118 export CXXFLAGS=" $CFLAGS -fno-semantic-interposition"
120119 export LDFLAGS=" -Wl,--gc-sections"
@@ -140,27 +139,32 @@ for target_arch in ${TARGET_ARCH_STR//,/ }; do
140139 cd " $HOME " /pkgs/linux-${LINUX_VERSION}
141140 make ARCH=" $CARCH " INSTALL_HDR_PATH=$PREFIX /$TARGET headers_install
142141
143- cd " $HOME " /pkgs
144- mkdir gcc-${GCC_VERSION} -build-${TARGETARCH} -O${OPT} -stage1
145- cd gcc-${GCC_VERSION} -build-${TARGETARCH} -O${OPT} -stage1
146- " $HOME " /pkgs/gcc-${GCC_VERSION} /configure \
147- --target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT --with-newlib --without-headers \
148- --disable-nls --disable-shared --disable-multilib --disable-decimal-float --disable-threads \
149- --disable-libatomic --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv \
150- --disable-libstdcxx --enable-languages=c,c++ ${GCC_NODOCS}
151- make -j" $( nproc) " all-gcc ${GCC_NODOCS}
152- make -j" $( nproc) " all-target-libgcc ${GCC_NODOCS}
153- make install-gcc
154- make install-target-libgcc
142+ if [[ " $TARGETARCH " != " $ARCH " ]]; then
143+ cd " $HOME " /pkgs
144+ mkdir gcc-${GCC_VERSION} -build-${TARGETARCH} -O${OPT} -stage1
145+ cd gcc-${GCC_VERSION} -build-${TARGETARCH} -O${OPT} -stage1
146+ " $HOME " /pkgs/gcc-${GCC_VERSION} /configure \
147+ --target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT --with-newlib --without-headers \
148+ --disable-nls --disable-shared --disable-multilib --disable-decimal-float --disable-threads \
149+ --disable-libatomic --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv \
150+ --disable-libstdcxx --enable-languages=c,c++ ${GCC_NODOCS}
151+ make -j" $( nproc) " all-gcc ${GCC_NODOCS}
152+ make -j" $( nproc) " all-target-libgcc ${GCC_NODOCS}
153+ make install-gcc
154+ make install-target-libgcc
155+ MUSL_CC=" ${TARGET} -gcc"
156+ else
157+ MUSL_CC=" gcc"
158+ fi
155159
156160 cd " $HOME " /pkgs
157161 rm -rf musl-${MUSL_VERSION}
158162 tar xf ${MUSL_TARBALL}
159163 cd musl-${MUSL_VERSION}
160164 fetch.sh https://gitlab.alpinelinux.org/alpine/aports/-/raw/3.22-stable/main/musl/__stack_chk_fail_local.c
161- ${TARGET} -gcc $CFLAGS -c __stack_chk_fail_local.c -o __stack_chk_fail_local.o
165+ ${MUSL_CC} $CFLAGS -c __stack_chk_fail_local.c -o __stack_chk_fail_local.o
162166 ${TARGET} -ar r libssp_nonshared.a __stack_chk_fail_local.o
163- ./configure --prefix=$PREFIX /$TARGET --target=$TARGET CC=$TARGET -gcc
167+ ./configure --prefix=$PREFIX /$TARGET --target=$TARGET CC=$MUSL_CC
164168 make install-headers
165169 make -j" $( nproc) "
166170 make install
@@ -182,7 +186,7 @@ for target_arch in ${TARGET_ARCH_STR//,/ }; do
182186 --with-gmp=/usr --with-mpfr=/usr --with-mpc=/usr \
183187 --disable-shared --enable-tls --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers \
184188 --enable-threads --enable-__cxa_atexit --enable-languages=c,c++ --enable-link-serialization=2 --enable-linker-build-id \
185- --enable-libssp --disable-libsanitizer --with-system-zlib -- enable-checking=release --disable-cet --disable-fixed-point \
189+ --enable-libssp --disable-libsanitizer --enable-checking=release --disable-cet --disable-fixed-point \
186190 --enable-libstdcxx-time=yes --enable-default-pie --enable-default-ssp --with-linker-hash-style=gnu ${GCC_NODOCS}
187191 make -j" $( nproc) " ${GCC_NODOCS}
188192 make install
0 commit comments