macOSにてgccのクロスコンパイラのビルドが失敗する
UEFIを試してみるため,MacBookProにgccのmingw-w64版のビルドをしようとしたところ,make install-gcc
時に,以下のエラーが発生した。
ld: warning: ignoring file ../libiberty/libiberty.a, file was built for archive which is not the architecture being linked (x86_64): ../libiberty/libiberty.a Undefined symbols for architecture x86_64: "__sch_istable", referenced from: _main in fixincl.o _initialize in fixincl.o _process in fixincl.o _char_macro_def_fix in fixfixes.o _char_macro_use_fix in fixfixes.o _format_fix in fixfixes.o _wrap_fix in fixfixes.o ... "__sch_toupper", referenced from: _wrap_fix in fixfixes.o _gnu_type_fix in fixfixes.o "_fdopen_unlocked", referenced from: _process in fixincl.o _load_file in fixincl.o _create_file in fixincl.o _proc2_fopen in procopen.o "_freopen_unlocked", referenced from: _main in fixincl.o _initialize in fixincl.o "_xcalloc", referenced from: _run_compiles in fixincl.o _run_shell in server.o "_xmalloc", referenced from: _process in fixincl.o _wrap_fix in fixfixes.o _run_shell in server.o "_xmalloc_set_program_name", referenced from: _initialize in fixincl.o "_xrealloc", referenced from: _run_shell in server.o _load_file_data in fixlib.o "_xregcomp", referenced from: _compile_re in fixlib.o _mn_get_regexps in fixlib.o "_xregerror", referenced from: _compile_re in fixlib.o _mn_get_regexps in fixlib.o "_xregexec", referenced from: _process in fixincl.o _machine_name_test in fixtests.o _char_macro_def_fix in fixfixes.o _char_macro_use_fix in fixfixes.o _format_fix in fixfixes.o _machine_name_fix in fixfixes.o _wrap_fix in fixfixes.o ... "_xstrdup", referenced from: _run_shell in server.o "_xstrerror", referenced from: _initialize in fixincl.o _process in fixincl.o _load_file in fixincl.o _create_file in fixincl.o _chain_open in procopen.o _load_file_data in fixlib.o ld: symbol(s) not found for architecture x86_64
その後調べると,homebrewでインストールしたbinutilsがエラーを引き起こしているようだった。
なので,思い切ってbrew uninstall binutils
でアンインストールして,以下のコマンドでconfigureしてみた。
../gcc-9.1.0/configure --prefix=**** --target=x86_64-w64-mingw32 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/Cellar/libmpc/1.1.0 AR="/usr/bin/ar" RANLIB="/usr/bin/ranlib"
そしてmake all-gcc -j4
とmake install-gcc
でコンパイル&インストールができた。