如何在 M1 MacBook pro 上构建 GCC 13?

如何在 M1 MacBook pro 上构建 GCC 13?

我想在我的 M1 MacBook Pro 上构建 gcc-13。下列的官方文件,我使用 git 下载源代码,configure然后make

对于,我参考了Homebrew gcc-12上configure的方式configure关联。具体是

../configure \
--prefix=/Users/xubaoyu/gcc/build \
--disable-nls \
--enable-checking=release \
--with-gcc-major-version-only \
--enable-languages=c,c++ \
--program-suffix=-13 \
--with-system-zlib \
--build=aarch64-apple-darwin22 \
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk

简单地说make -j 10

然后出现错误:

*** Configuration aarch64-apple-darwin22 not supported
make[2]: *** [configure-stage1-gcc] Error 1
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2

我认为我在构建参数上使用了错误的值,因此我通过以下方式检查 gcc12 gcc-12 -v

Using built-in specs.
COLLECT_GCC=gcc-12
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/12.2.0/bin/../libexec/gcc/aarch64-apple-darwin22/12/lto-wrapper
Target: aarch64-apple-darwin22
Configured with: ../configure --prefix=/opt/homebrew/opt/gcc --libdir=/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-12 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 12.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --with-system-zlib --build=aarch64-apple-darwin22 --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Homebrew GCC 12.2.0)

它与我使用的目标相同。

然后我重试make configure-stage1-gcc

/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
Making all in tests
Making all in .
make[4]: Nothing to be done for `all-am'.
Making all in devel
make[4]: Nothing to be done for `all'.
Making all in mpn
make[4]: Nothing to be done for `all'.
Making all in mpz
make[4]: Nothing to be done for `all'.
Making all in mpq
make[4]: Nothing to be done for `all'.
Making all in mpf
make[4]: Nothing to be done for `all'.
Making all in rand
make[4]: Nothing to be done for `all'.
Making all in misc
make[4]: Nothing to be done for `all'.
Making all in cxx
make[4]: Nothing to be done for `all'.
Making all in mpn
make[3]: Nothing to be done for `all'.
Making all in mpz
make[3]: Nothing to be done for `all'.
Making all in mpq
make[3]: Nothing to be done for `all'.
Making all in mpf
make[3]: Nothing to be done for `all'.
Making all in printf
make[3]: Nothing to be done for `all'.
Making all in scanf
make[3]: Nothing to be done for `all'.
Making all in rand
make[3]: Nothing to be done for `all'.
Making all in cxx
make[3]: Nothing to be done for `all'.
Making all in demos
Making all in calc
/Library/Developer/CommandLineTools/usr/bin/make  all-am
make[5]: Nothing to be done for `all-am'.
Making all in expr
make[4]: Nothing to be done for `all'.
make[4]: Nothing to be done for `all-am'.
Making all in tune
make[3]: Nothing to be done for `all'.
Making all in doc
make[3]: Nothing to be done for `all'.
make[3]: Nothing to be done for `all-am'.
Making all in doc
make[2]: Nothing to be done for `all'.
Making all in src
/Library/Developer/CommandLineTools/usr/bin/make  all-am
make[3]: Nothing to be done for `all-am'.
Making all in tests
make[2]: Nothing to be done for `all'.
Making all in tune
make[2]: Nothing to be done for `all'.
Making all in tools/bench
make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all-am'.
/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
Making all in src
make[3]: Nothing to be done for `all'.
Making all in tests
make[3]: Nothing to be done for `all'.
Making all in doc
make[3]: Nothing to be done for `all'.
Making all in tools
Making all in bench
make[4]: Nothing to be done for `all'.
Making all in mpcheck
make[4]: Nothing to be done for `all'.
make[4]: Nothing to be done for `all-am'.
make[3]: Nothing to be done for `all-am'.
/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
Making all in .
make[3]: Nothing to be done for `all-am'.
Making all in doc
make[3]: Nothing to be done for `all'.
Configuring stage 1 in ./gcc
configure: loading cache ./config.cache
checking build system type... aarch64-apple-darwin22
checking host system type... aarch64-apple-darwin22
checking target system type... aarch64-apple-darwin22
checking LIBRARY_PATH variable... ok
checking GCC_EXEC_PREFIX variable... ok
checking whether to place generated files in the source directory... no
checking whether a default linker was specified... no
checking whether a default dsymutil was specified... no
checking whether a default assembler was specified... no
checking for aarch64-apple-darwin22-gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -std=c++11 accepts -g... yes
checking for aarch64-apple-darwin22-gnatbind... no
checking for gnatbind... no
checking for aarch64-apple-darwin22-gnatmake... no
checking for gnatmake... no
checking whether compiler driver understands Ada and is recent enough... rm: conftest.dSYM: is a directory
no
checking for aarch64-apple-darwin22-gdc... no
checking whether the D compiler works... no
checking how to run the C++ preprocessor... g++ -std=c++11 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking how to run the C preprocessor... gcc -E
checking for inline... inline
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking size of ino_t... 8
checking size of dev_t... 4
checking size of void *... 8
checking size of short... 2
checking size of int... 4
checking size of long... 8
checking for long long... yes
checking size of long long... 8
checking for int8_t... yes
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for unsigned long long int... yes
checking for long long int... yes
checking for intmax_t... yes
checking for intptr_t... yes
checking for uint8_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for uintmax_t... yes
checking for uintptr_t... yes
checking for int64_t underlying type... long long
checking for std::swap in <utility>... yes
checking whether g++ -std=c++11 is affected by placement new aliasing bug... no
checking whether g++ -std=c++11 supports -W... yes
checking whether g++ -std=c++11 supports -Wall... yes
checking whether g++ -std=c++11 supports -Wnarrowing... yes
checking whether g++ -std=c++11 supports -Wwrite-strings... yes
checking whether g++ -std=c++11 supports -Wcast-qual... yes
checking whether g++ -std=c++11 supports -Wformat... yes
checking whether gcc supports -Wstrict-prototypes... yes
checking whether gcc supports -Wmissing-prototypes... yes
checking whether g++ -std=c++11 supports -Wmissing-format-attribute... yes
checking whether g++ -std=c++11 supports -Wconditionally-supported... yes
checking whether g++ -std=c++11 supports -Woverloaded-virtual... yes
checking whether gcc supports -Wold-style-definition... yes
checking whether gcc supports -Wc++-compat... yes
checking whether g++ -std=c++11 supports -pedantic -Wlong-long -Wvariadic-macros -Woverlength-strings... yes
checking whether gcc supports -fno-exceptions... yes
checking whether gcc supports -fno-rtti... yes
checking whether gcc supports -fasynchronous-unwind-tables... yes
checking valgrind.h usability... no
checking valgrind.h presence... no
checking for valgrind.h... no
checking for VALGRIND_DISCARD in <valgrind/memcheck.h>... no
checking for VALGRIND_DISCARD in <memcheck.h>... no
checking for multiarch configuration... auto
configure: WARNING: fixed-point is not supported for this target, ignored
checking whether make sets $(MAKE)... yes
checking for gawk... awk
checking whether ln -s works... yes
checking whether ln works... yes
checking for aarch64-apple-darwin22-ranlib... ranlib
checking for a BSD compatible install... /usr/bin/install -c
checking for cmp's capabilities... gnucompare
checking for mktemp... yes
checking for makeinfo... makeinfo
checking for modern makeinfo... yes
checking for recent Pod::Man... yes
checking for flex... flex
checking for bison... bison
checking for python3... python3
checking for modern python3... yes
checking for nm... nm
checking for ar... ar
checking for sphinx-build... texinfo
checking for ANSI C header files... (cached) yes
checking whether time.h and sys/time.h may both be included... yes
checking whether string.h and strings.h may both be included... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking whether termios.h defines TIOCGWINSZ... yes
checking for limits.h... yes
checking for stddef.h... yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for time.h... yes
checking for iconv.h... yes
checking for fcntl.h... yes
checking for ftw.h... yes
checking for unistd.h... (cached) yes
checking for sys/auxv.h... no
checking for sys/file.h... yes
checking for sys/time.h... yes
checking for sys/mman.h... yes
checking for sys/resource.h... yes
checking for sys/param.h... yes
checking for sys/times.h... yes
checking for sys/stat.h... (cached) yes
checking for sys/locking.h... no
checking for direct.h... no
checking for malloc.h... no
checking for langinfo.h... yes
checking for ldfcn.h... no
checking for locale.h... yes
checking for wchar.h... yes
checking for thread.h... no
checking for pthread.h... yes
checking for CHAR_BIT... yes
checking whether byte ordering is bigendian... no
checking how to run the C++ preprocessor... g++ -std=c++11 -E
checking for unordered_map... yes
checking for tr1/unordered_map... yes
checking for ext/hash_map... yes
checking dependency style of g++ -std=c++11... gcc3
checking for collect2 libraries... none required
checking for library containing exc_resume... no
checking for library containing kstat_open... no
checking for library containing gethostbyname... none required
checking for library containing socket... none required
checking for library containing ldexp... none required
checking for library containing dlopen... none required
checking for inttypes.h... yes
checking for zstd.h... no
checking for library containing ZSTD_compress... no
checking for times... yes
checking for clock... yes
checking for kill... yes
checking for getrlimit... yes
checking for setrlimit... yes
checking for atoq... no
checking for popen... yes
checking for sysconf... yes
checking for strsignal... yes
checking for getrusage... yes
checking for nl_langinfo... yes
checking for gettimeofday... yes
checking for mbstowcs... yes
checking for wcswidth... yes
checking for mmap... yes
checking for posix_fallocate... no
checking for setlocale... yes
checking for clearerr_unlocked... yes
checking for feof_unlocked... yes
checking for ferror_unlocked... yes
checking for fflush_unlocked... no
checking for fgetc_unlocked... no
checking for fgets_unlocked... no
checking for fileno_unlocked... yes
checking for fprintf_unlocked... no
checking for fputc_unlocked... no
checking for fputs_unlocked... no
checking for fread_unlocked... no
checking for fwrite_unlocked... no
checking for getchar_unlocked... yes
checking for getc_unlocked... yes
checking for putchar_unlocked... yes
checking for putc_unlocked... yes
checking for madvise... yes
checking for mallinfo... no
checking for mallinfo2... no
checking for fstatat... yes
checking for getauxval... no
checking whether mbstowcs works... yes
checking for ssize_t... yes
checking for caddr_t... yes
checking for sighander_t... no
checking for sys/mman.h... (cached) yes
checking for mmap... (cached) yes
checking whether read-only mmap of a plain file works... yes
checking whether mmap from /dev/zero works... no
checking for MAP_ANON(YMOUS)... yes
checking whether mmap with MAP_ANON(YMOUS) works... yes
checking for pid_t... yes
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for ld used by GCC... ld
checking if the linker (ld) is GNU ld... no
checking for shared library run path origin... done
checking for iconv... yes
checking how to link with libiconv... -liconv
checking for iconv declaration...
         extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for LC_MESSAGES... yes
checking for nl_langinfo and CODESET... yes
checking whether basename is declared... no
checking whether strstr is declared... yes
checking whether getenv is declared... yes
checking whether atol is declared... yes
checking whether atoll is declared... yes
checking whether asprintf is declared... yes
checking whether sbrk is declared... yes
checking whether abort is declared... yes
checking whether atof is declared... yes
checking whether getcwd is declared... yes
checking whether getwd is declared... yes
checking whether madvise is declared... yes
checking whether stpcpy is declared... yes
checking whether strnlen is declared... yes
checking whether strsignal is declared... yes
checking whether strverscmp is declared... no
checking whether strtol is declared... yes
checking whether strtoul is declared... yes
checking whether strtoll is declared... yes
checking whether strtoull is declared... yes
checking whether setenv is declared... yes
checking whether unsetenv is declared... yes
checking whether errno is declared... yes
checking whether snprintf is declared... yes
checking whether vsnprintf is declared... yes
checking whether vasprintf is declared... yes
checking whether malloc is declared... yes
checking whether realloc is declared... yes
checking whether calloc is declared... yes
checking whether free is declared... yes
checking whether getopt is declared... yes
checking whether clock is declared... yes
checking whether getpagesize is declared... yes
checking whether ffs is declared... yes
checking whether clearerr_unlocked is declared... yes
checking whether feof_unlocked is declared... yes
checking whether ferror_unlocked is declared... yes
checking whether fflush_unlocked is declared... no
checking whether fgetc_unlocked is declared... no
checking whether fgets_unlocked is declared... no
checking whether fileno_unlocked is declared... yes
checking whether fprintf_unlocked is declared... no
checking whether fputc_unlocked is declared... no
checking whether fputs_unlocked is declared... no
checking whether fread_unlocked is declared... no
checking whether fwrite_unlocked is declared... no
checking whether getchar_unlocked is declared... yes
checking whether getc_unlocked is declared... yes
checking whether putchar_unlocked is declared... yes
checking whether putc_unlocked is declared... yes
checking whether getrlimit is declared... yes
checking whether setrlimit is declared... yes
checking whether getrusage is declared... yes
checking whether mallinfo is declared... no
checking whether mallinfo2 is declared... no
checking whether ldgetname is declared... no
checking whether times is declared... yes
checking whether sigaltstack is declared... yes
checking for struct tms... yes
checking for clock_t... yes
checking for F_SETLKW... yes
checking for O_CLOEXEC... yes
checking for fcntl.h... (cached) yes
checking whether O_NONBLOCK is declared... yes
checking for AF_UNIX... yes
checking for AF_INET6... yes
checking for _LK_LOCK... no
checking if mkdir takes one argument... no
*** Configuration aarch64-apple-darwin22 not supported
make: *** [configure-stage1-gcc] Error 1

这个过程中出了什么问题以及如何解决?提前致谢!

答案1

友好的家伙在海湾合作委员会邮件列表解决了这个问题!

乔纳森·韦克利<[email protected]>

我认为 Homebrew 使用了 GCC 的修补版本,因为上游 GCC 中尚未提供对 M1 支持的更改。因此,用于 Homebrew 构建的相同配置不一定适用于未修补的上游源。

伊恩·桑多<[email protected]>

正如 Jonathan 所说,M1(Arm64 / aarch64)对 macOS 的支持尚未上行。原型/实验分支在这里:https://github.com/iains/gcc-darwin-arm64 我会不时地重新调整这项工作(应该在下周左右进行更新)。注意你可能会遇到https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107568使用 macOS13 SDK - 解决方法是:make BOOT_CFLAGS="-O2 -g -Wno-error=deprecated-declarations"(-jXX 和您使用的任何其他标志保持不变)

使用Iain的repo和NOTE,我可以在M1 MacBook上顺利构建gcc-13。

相关内容