A versão de trabalho com o --target
correto
export GCC_VERSION=7.3.0
apk add --no-cache make build-base mpfr-dev mpc1-dev isl-dev
wget https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz
tar -xzf gcc-${GCC_VERSION}.tar.gz
cd gcc-${GCC_VERSION}
./configure \
--prefix=/usr/local \
--build=$(uname -m)-alpine-linux-musl \
--host=$(uname -m)-alpine-linux-musl \
--target=$(uname -m)-alpine-linux-musl \
--enable-checking=release \
--disable-fixed-point \
--disable-libmpx \
--disable-libmudflap \
--disable-libsanitizer \
--disable-libssp \
--disable-libstdcxx-pch \
--disable-multilib \
--disable-nls \
--disable-symvers \
--disable-werror
make -j $(nproc)
make install
Teste do compilador C:
echo '#include <stdio.h>
int main() {
printf("Hello, C world!\n");
return 0;
}' | gcc -x c - && ./a.out
Compilador do Teste C ++:
echo '#include <iostream>
int main () {
std::cout << "Hello, C++ world!\n";
return 0;
}' | g++ -x c++ - && ./a.out