mingw64 的 gcc 不使用 mingw 套件的汇编器
gcc from mingw64 doesn't use assembler from mingw suite
我尝试在cygwin下使用MinGW v6.4.0进行编译。它失败了,因为 i686-w64-mingw32-gcc
使用 as
作为汇编编译器而不是 i686-w64-mingw32-as
.
根据详细输出:
$ i686-w64-mingw32-gcc -Wall -O2 -D_WINDOWS -DWIN32S_COMPAT -DFDJ1 -DAUTO_WINSOCK -DUSE_CAPI -DCOVERITY -DPERSOPORT -DCYGTERMPORT -DIMAGEPORT -DRECONNECTPORT -DHYPERLINKPORT -DZMODEMPORT -DSTARTBUTTON -DLAUNCHERPORT -DSAVEDUMPPORT -DKEYMAPPINGPORT -DWINCRYPTPORT -DTUTTYPORT -DPORTKNOCKINGPORT -DPUTTYXPORT -DWTSPORT -DPRINTCLIPPORT -DRUTTYPORT -DDISABLEALTGRPORT -DADBPORT -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP -I.././ -I../../ -I../charset/ -I../windows/ -I../unix/ -I../mac/ -I../macosx -I../../base64 -I../../bcrypt -I../../md5 -I../../regex -I../../url -I../../wincrypt -I../../rutty -D_WIN32_IE=0x0500 -DWINVER=0x0501 -D_WIN32_WINDOWS=0x0410 -D_WIN32_WINNT=0x0501 -v -c ../be_misc.c
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32-gcc
Target: i686-w64-mingw32
Configured with: /cygdrive/i/szsz/tmpp/cygwin64/mingw64-i686/mingw64-i686-gcc-6.4.0-1.x86_64/src/gcc-6.4.0/configure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/mingw64-i686/mingw64-i686-gcc-6.4.0-1.x86_64/src/gcc-6.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/mingw64-i686-gcc --htmldir=/usr/share/doc/mingw64-i686-gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=i686-w64-mingw32 --without-libiconv-prefix --without-libintl-prefix --with-sysroot=/usr/i686-w64-mingw32/sys-root --with-build-sysroot=/usr/i686-w64-mingw32/sys-root --disable-multilib --disable-win32-registry --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-fully-dynamic-string --enable-graphite --enable-libgomp --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-version-specific-runtime-libs --with-dwarf2 --with-gnu-ld --with-gnu-as --with-tune=generic --with-cloog-include=/usr/include/cloog-isl --with-system-zlib --enable-threads=posix --libexecdir=/usr/lib
Thread model: posix
gcc version 6.4.0 (GCC)
COLLECT_GCC_OPTIONS='-Wall' '-O2' '-D' '_WINDOWS' '-D' 'WIN32S_COMPAT' '-D' 'FDJ1' '-D' 'AUTO_WINSOCK' '-D' 'USE_CAPI' '-D' 'COVERITY' '-D' 'PERSOPORT' '-D' 'CYGTERMPORT' '-D' 'IMAGEPORT' '-D' 'RECONNECTPORT' '-D' 'HYPERLINKPORT' '-D' 'ZMODEMPORT' '-D' 'STARTBUTTON' '-D' 'LAUNCHERPORT' '-D' 'SAVEDUMPPORT' '-D' 'KEYMAPPINGPORT' '-D' 'WINCRYPTPORT' '-D' 'TUTTYPORT' '-D' 'PORTKNOCKINGPORT' '-D' 'PUTTYXPORT' '-D' 'WTSPORT' '-D' 'PRINTCLIPPORT' '-D' 'RUTTYPORT' '-D' 'DISABLEALTGRPORT' '-D' 'ADBPORT' '-D' '_NO_OLDNAMES' '-D' 'NO_MULTIMON' '-D' 'NO_HTMLHELP' '-I' '.././' '-I' '../../' '-I' '../charset/' '-I' '../windows/' '-I' '../unix/' '-I' '../mac/' '-I' '../macosx' '-I' '../../base64' '-I' '../../bcrypt' '-I' '../../md5' '-I' '../../regex' '-I' '../../url' '-I' '../../wincrypt' '-I' '../../rutty' '-D' '_WIN32_IE=0x0500' '-D' 'WINVER=0x0501' '-D' '_WIN32_WINDOWS=0x0410' '-D' '_WIN32_WINNT=0x0501' '-v' '-c' '-mtune=generic' '-march=pentiumpro'
/bin/../lib/gcc/i686-w64-mingw32/6.4.0/cc1.exe -quiet -v -I .././ -I ../../ -I ../charset/ -I ../windows/ -I ../unix/ -I ../mac/ -I ../macosx -I ../../base64 -I ../../bcrypt -I ../../md5 -I ../../regex -I ../../url -I ../../wincrypt -I ../../rutty -iprefix /bin/../lib/gcc/i686-w64-mingw32/6.4.0/ -D_REENTRANT -D _WINDOWS -D WIN32S_COMPAT -D FDJ1 -D AUTO_WINSOCK -D USE_CAPI -D COVERITY -D PERSOPORT -D CYGTERMPORT -D IMAGEPORT -D RECONNECTPORT -D HYPERLINKPORT -D ZMODEMPORT -D STARTBUTTON -D LAUNCHERPORT -D SAVEDUMPPORT -D KEYMAPPINGPORT -D WINCRYPTPORT -D TUTTYPORT -D PORTKNOCKINGPORT -D PUTTYXPORT -D WTSPORT -D PRINTCLIPPORT -D RUTTYPORT -D DISABLEALTGRPORT -D ADBPORT -D _NO_OLDNAMES -D NO_MULTIMON -D NO_HTMLHELP -D _WIN32_IE=0x0500 -D WINVER=0x0501 -D _WIN32_WINDOWS=0x0410 -D _WIN32_WINNT=0x0501 ../be_misc.c -quiet -dumpbase be_misc.c -mtune=generic -march=pentiumpro -auxbase be_misc -O2 -Wall -version -o C:\Users\kot\AppData\Local\Temp/ccTGGBtt.s
GNU C11 (GCC) version 6.4.0 (i686-w64-mingw32)
compiled by GNU C version 6.4.0, GMP version 6.1.2, MPFR version 3.1.5-p10, MPC version 1.0.3, isl version 0.14 or 0.13
...
COLLECT_GCC_OPTIONS='-Wall' '-O2' '-D' '_WINDOWS' '-D' 'WIN32S_COMPAT' '-D' 'FDJ1' '-D' 'AUTO_WINSOCK' '-D' 'USE_CAPI' '-D' 'COVERITY' '-D' 'PERSOPORT' '-D' 'CYGTERMPORT' '-D' 'IMAGEPORT' '-D' 'RECONNECTPORT' '-D' 'HYPERLINKPORT' '-D' 'ZMODEMPORT' '-D' 'STARTBUTTON' '-D' 'LAUNCHERPORT' '-D' 'SAVEDUMPPORT' '-D' 'KEYMAPPINGPORT' '-D' 'WINCRYPTPORT' '-D' 'TUTTYPORT' '-D' 'PORTKNOCKINGPORT' '-D' 'PUTTYXPORT' '-D' 'WTSPORT' '-D' 'PRINTCLIPPORT' '-D' 'RUTTYPORT' '-D' 'DISABLEALTGRPORT' '-D' 'ADBPORT' '-D' '_NO_OLDNAMES' '-D' 'NO_MULTIMON' '-D' 'NO_HTMLHELP' '-I' '.././' '-I' '../../' '-I' '../charset/' '-I' '../windows/' '-I' '../unix/' '-I' '../mac/' '-I' '../macosx' '-I' '../../base64' '-I' '../../bcrypt' '-I' '../../md5' '-I' '../../regex' '-I' '../../url' '-I' '../../wincrypt' '-I' '../../rutty' '-D' '_WIN32_IE=0x0500' '-D' 'WINVER=0x0501' '-D' '_WIN32_WINDOWS=0x0410' '-D' '_WIN32_WINNT=0x0501' '-v' '-c' '-mtune=generic' '-march=pentiumpro'
as -v -I .././ -I ../../ -I ../charset/ -I ../windows/ -I ../unix/ -I ../mac/ -I ../macosx -I ../../base64 -I ../../bcrypt -I ../../md5 -I ../../regex -I ../../url -I ../../wincrypt -I ../../rutty -o be_misc.o C:\Users\kot\AppData\Local\Temp/ccTGGBtt.s
GNU assembler version 2.29.1 (x86_64-pc-cygwin) using BFD version (GNU Binutils) 2.29.1.20171006
C:\Users\kot\AppData\Local\Temp/ccTGGBtt.s: Assembler messages:
汇编消息并不重要。失败是因为 x86_64 汇编程序用于编译 x86 代码。
在日志消息中我可以看到 gcc 是使用 --with-gnu-as
标志编译的。在构建过程中使用标准 as
命令。
所以,问题是:如何在构建过程中指定正确的汇编器 (i686-w64-mingw32-gcc
)?
另外还有一个问题:这个 bug 是来自 cygwin 还是 mingw 应该报告?
我试图通过环境变量 AS
指定汇编程序命令,但它不起作用。
我找到类似的 questions/discussions:
但他们没有给出任何可以接受的答案。我不想重建 mingw 套件。
目前,我看到以下解决方法:创建一些临时目录并在其中添加指向 i686-w64-mingw32-gcc
的符号链接 as
。然后我可以将选项 -Bprefix
传递给 gcc 以指定它寻找二进制文件的位置。
更新:
$ i686-w64-mingw32-gcc --version --verbose
输出:
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/bin/../lib/gcc/i686-w64-mingw32/6.4.0/lto-wrapper.exe
i686-w64-mingw32-gcc (GCC) 6.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Target: i686-w64-mingw32
Configured with: /cygdrive/i/szsz/tmpp/cygwin64/mingw64-i686/mingw64-i686-gcc-6.4.0-1.x86_64/src/gcc-6.4.0/configure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/mingw64-i686/mingw64-i686-gcc-6.4.0-1.x86_64/src/gcc-6.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/mingw64-i686-gcc --htmldir=/usr/share/doc/mingw64-i686-gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=i686-w64-mingw32 --without-libiconv-prefix --without-libintl-prefix --with-sysroot=/usr/i686-w64-mingw32/sys-root --with-build-sysroot=/usr/i686-w64-mingw32/sys-root --disable-multilib --disable-win32-registry --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-fully-dynamic-string --enable-graphite --enable-libgomp --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-version-specific-runtime-libs --with-dwarf2 --with-gnu-ld --with-gnu-as --with-tune=generic --with-cloog-include=/usr/include/cloog-isl --with-system-zlib --enable-threads=posix --libexecdir=/usr/lib
Thread model: posix
gcc version 6.4.0 (GCC)
COLLECT_GCC_OPTIONS='--version' '-v' '-mtune=generic' '-march=pentiumpro'
/bin/../lib/gcc/i686-w64-mingw32/6.4.0/cc1.exe -quiet -v -iprefix /bin/../lib/gcc/i686-w64-mingw32/6.4.0/ -D_REENTRANT help-dummy -quiet -dumpbase help-dummy -mtune=generic -march=pentiumpro -auxbase help-dummy -version --version -o C:\Users\kot\AppData\Local\Temp/ccC3uqbG.s
GNU C11 (GCC) version 6.4.0 (i686-w64-mingw32)
compiled by GNU C version 6.4.0, GMP version 6.1.2, MPFR version 3.1.5-p10, MPC version 1.0.3, isl version 0.14 or 0.13
warning: MPFR header version 3.1.5-p10 differs from library version 3.1.6-p1.
warning: MPC header version 1.0.3 differs from library version 1.1.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='--version' '-v' '-mtune=generic' '-march=pentiumpro'
as -v --version -o C:\Users\kot\AppData\Local\Temp/ccpT4jBG.o C:\Users\kot\AppData\Local\Temp/ccC3uqbG.s
GNU assembler version 2.29.1 (x86_64-pc-cygwin) using BFD version (GNU Binutils) 2.29.1.20171006
GNU assembler (GNU Binutils) 2.29.1.20171006
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-pc-cygwin'.
COMPILER_PATH=/bin/../lib/gcc/i686-w64-mingw32/6.4.0/:/bin/../lib/gcc/
LIBRARY_PATH=/bin/../lib/gcc/i686-w64-mingw32/6.4.0/:/bin/../lib/gcc/:/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/:/usr/i686-w64-mingw32/sys-root/mingw/lib/
COLLECT_GCC_OPTIONS='--version' '-v' '-mtune=generic' '-march=pentiumpro'
/bin/../lib/gcc/i686-w64-mingw32/6.4.0/collect2.exe -plugin /bin/../lib/gcc/i686-w64-mingw32/6.4.0/cyglto_plugin-0.dll -plugin-opt=/bin/../lib/gcc/i686-w64-mingw32/6.4.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\kot\AppData\Local\Temp/cc1gm609.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=/usr/i686-w64-mingw32/sys-root -m i386pe -Bdynamic --version /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/crt2.o /bin/../lib/gcc/i686-w64-mingw32/6.4.0/crtbegin.o -L/bin/../lib/gcc/i686-w64-mingw32/6.4.0 -L/bin/../lib/gcc -L/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib C:\Users\kot\AppData\Local\Temp/ccpT4jBG.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/default-manifest.o /bin/../lib/gcc/i686-w64-mingw32/6.4.0/crtend.o
collect2 version 6.4.0
/bin/i686-w64-mingw32-ld -plugin /bin/../lib/gcc/i686-w64-mingw32/6.4.0/cyglto_plugin-0.dll -plugin-opt=/bin/../lib/gcc/i686-w64-mingw32/6.4.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\kot\AppData\Local\Temp/cc1gm609.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=/usr/i686-w64-mingw32/sys-root -m i386pe -Bdynamic --version /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/crt2.o /bin/../lib/gcc/i686-w64-mingw32/6.4.0/crtbegin.o -L/bin/../lib/gcc/i686-w64-mingw32/6.4.0 -L/bin/../lib/gcc -L/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib C:\Users\kot\AppData\Local\Temp/ccpT4jBG.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/default-manifest.o /bin/../lib/gcc/i686-w64-mingw32/6.4.0/crtend.o
GNU ld (GNU Binutils) 2.29.1.20171006
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
COLLECT_GCC_OPTIONS='--version' '-v' '-mtune=generic' '-march=pentiumpro'
$ i686-w64-mingw32-as --version -v
输出:
GNU assembler (GNU Binutils) 2.29.1.20171006
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `i686-w64-mingw32'.
$ x86_64-w64-mingw32-as --version -v
输出:
GNU assembler (GNU Binutils) 2.29.1.20171006
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-w64-mingw32'.
来自 mingw64-i686-gcc-core 6.4.0-1 的输出
$ i686-w64-mingw32-gcc --version --verbose |& grep COMPILER_PATH
COMPILER_PATH=/usr/lib/gcc/i686-w64-mingw32/6.4.0/:/usr/lib/gcc/i686-w64-mingw32/6.4.0/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-mingw32/6.4.0/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-mingw32/6.4.0/../../../../i686-w64-mingw32/bin/
最后一个目录是 /usr/i686-w64-mingw32/bin
正确的 binutils 所在的目录。
$ cygcheck -l mingw64-i686-binutils | grep "/bin/"
/usr/bin/i686-w64-mingw32-addr2line.exe
/usr/bin/i686-w64-mingw32-ar.exe
/usr/bin/i686-w64-mingw32-as.exe
/usr/bin/i686-w64-mingw32-c++filt.exe
/usr/bin/i686-w64-mingw32-dlltool.exe
/usr/bin/i686-w64-mingw32-dllwrap.exe
/usr/bin/i686-w64-mingw32-elfedit.exe
/usr/bin/i686-w64-mingw32-gprof.exe
/usr/bin/i686-w64-mingw32-ld.bfd.exe
/usr/bin/i686-w64-mingw32-ld.exe
/usr/bin/i686-w64-mingw32-nm.exe
/usr/bin/i686-w64-mingw32-objcopy.exe
/usr/bin/i686-w64-mingw32-objdump.exe
/usr/bin/i686-w64-mingw32-ranlib.exe
/usr/bin/i686-w64-mingw32-readelf.exe
/usr/bin/i686-w64-mingw32-size.exe
/usr/bin/i686-w64-mingw32-strings.exe
/usr/bin/i686-w64-mingw32-strip.exe
/usr/bin/i686-w64-mingw32-windmc.exe
/usr/bin/i686-w64-mingw32-windres.exe
/usr/i686-w64-mingw32/bin/ar.exe
/usr/i686-w64-mingw32/bin/as.exe
/usr/i686-w64-mingw32/bin/dlltool.exe
/usr/i686-w64-mingw32/bin/ld.bfd.exe
/usr/i686-w64-mingw32/bin/ld.exe
/usr/i686-w64-mingw32/bin/nm.exe
/usr/i686-w64-mingw32/bin/objcopy.exe
/usr/i686-w64-mingw32/bin/objdump.exe
/usr/i686-w64-mingw32/bin/ranlib.exe
/usr/i686-w64-mingw32/bin/readelf.exe
/usr/i686-w64-mingw32/bin/strip.exe
我尝试在cygwin下使用MinGW v6.4.0进行编译。它失败了,因为 i686-w64-mingw32-gcc
使用 as
作为汇编编译器而不是 i686-w64-mingw32-as
.
根据详细输出:
$ i686-w64-mingw32-gcc -Wall -O2 -D_WINDOWS -DWIN32S_COMPAT -DFDJ1 -DAUTO_WINSOCK -DUSE_CAPI -DCOVERITY -DPERSOPORT -DCYGTERMPORT -DIMAGEPORT -DRECONNECTPORT -DHYPERLINKPORT -DZMODEMPORT -DSTARTBUTTON -DLAUNCHERPORT -DSAVEDUMPPORT -DKEYMAPPINGPORT -DWINCRYPTPORT -DTUTTYPORT -DPORTKNOCKINGPORT -DPUTTYXPORT -DWTSPORT -DPRINTCLIPPORT -DRUTTYPORT -DDISABLEALTGRPORT -DADBPORT -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP -I.././ -I../../ -I../charset/ -I../windows/ -I../unix/ -I../mac/ -I../macosx -I../../base64 -I../../bcrypt -I../../md5 -I../../regex -I../../url -I../../wincrypt -I../../rutty -D_WIN32_IE=0x0500 -DWINVER=0x0501 -D_WIN32_WINDOWS=0x0410 -D_WIN32_WINNT=0x0501 -v -c ../be_misc.c
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32-gcc
Target: i686-w64-mingw32
Configured with: /cygdrive/i/szsz/tmpp/cygwin64/mingw64-i686/mingw64-i686-gcc-6.4.0-1.x86_64/src/gcc-6.4.0/configure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/mingw64-i686/mingw64-i686-gcc-6.4.0-1.x86_64/src/gcc-6.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/mingw64-i686-gcc --htmldir=/usr/share/doc/mingw64-i686-gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=i686-w64-mingw32 --without-libiconv-prefix --without-libintl-prefix --with-sysroot=/usr/i686-w64-mingw32/sys-root --with-build-sysroot=/usr/i686-w64-mingw32/sys-root --disable-multilib --disable-win32-registry --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-fully-dynamic-string --enable-graphite --enable-libgomp --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-version-specific-runtime-libs --with-dwarf2 --with-gnu-ld --with-gnu-as --with-tune=generic --with-cloog-include=/usr/include/cloog-isl --with-system-zlib --enable-threads=posix --libexecdir=/usr/lib
Thread model: posix
gcc version 6.4.0 (GCC)
COLLECT_GCC_OPTIONS='-Wall' '-O2' '-D' '_WINDOWS' '-D' 'WIN32S_COMPAT' '-D' 'FDJ1' '-D' 'AUTO_WINSOCK' '-D' 'USE_CAPI' '-D' 'COVERITY' '-D' 'PERSOPORT' '-D' 'CYGTERMPORT' '-D' 'IMAGEPORT' '-D' 'RECONNECTPORT' '-D' 'HYPERLINKPORT' '-D' 'ZMODEMPORT' '-D' 'STARTBUTTON' '-D' 'LAUNCHERPORT' '-D' 'SAVEDUMPPORT' '-D' 'KEYMAPPINGPORT' '-D' 'WINCRYPTPORT' '-D' 'TUTTYPORT' '-D' 'PORTKNOCKINGPORT' '-D' 'PUTTYXPORT' '-D' 'WTSPORT' '-D' 'PRINTCLIPPORT' '-D' 'RUTTYPORT' '-D' 'DISABLEALTGRPORT' '-D' 'ADBPORT' '-D' '_NO_OLDNAMES' '-D' 'NO_MULTIMON' '-D' 'NO_HTMLHELP' '-I' '.././' '-I' '../../' '-I' '../charset/' '-I' '../windows/' '-I' '../unix/' '-I' '../mac/' '-I' '../macosx' '-I' '../../base64' '-I' '../../bcrypt' '-I' '../../md5' '-I' '../../regex' '-I' '../../url' '-I' '../../wincrypt' '-I' '../../rutty' '-D' '_WIN32_IE=0x0500' '-D' 'WINVER=0x0501' '-D' '_WIN32_WINDOWS=0x0410' '-D' '_WIN32_WINNT=0x0501' '-v' '-c' '-mtune=generic' '-march=pentiumpro'
/bin/../lib/gcc/i686-w64-mingw32/6.4.0/cc1.exe -quiet -v -I .././ -I ../../ -I ../charset/ -I ../windows/ -I ../unix/ -I ../mac/ -I ../macosx -I ../../base64 -I ../../bcrypt -I ../../md5 -I ../../regex -I ../../url -I ../../wincrypt -I ../../rutty -iprefix /bin/../lib/gcc/i686-w64-mingw32/6.4.0/ -D_REENTRANT -D _WINDOWS -D WIN32S_COMPAT -D FDJ1 -D AUTO_WINSOCK -D USE_CAPI -D COVERITY -D PERSOPORT -D CYGTERMPORT -D IMAGEPORT -D RECONNECTPORT -D HYPERLINKPORT -D ZMODEMPORT -D STARTBUTTON -D LAUNCHERPORT -D SAVEDUMPPORT -D KEYMAPPINGPORT -D WINCRYPTPORT -D TUTTYPORT -D PORTKNOCKINGPORT -D PUTTYXPORT -D WTSPORT -D PRINTCLIPPORT -D RUTTYPORT -D DISABLEALTGRPORT -D ADBPORT -D _NO_OLDNAMES -D NO_MULTIMON -D NO_HTMLHELP -D _WIN32_IE=0x0500 -D WINVER=0x0501 -D _WIN32_WINDOWS=0x0410 -D _WIN32_WINNT=0x0501 ../be_misc.c -quiet -dumpbase be_misc.c -mtune=generic -march=pentiumpro -auxbase be_misc -O2 -Wall -version -o C:\Users\kot\AppData\Local\Temp/ccTGGBtt.s
GNU C11 (GCC) version 6.4.0 (i686-w64-mingw32)
compiled by GNU C version 6.4.0, GMP version 6.1.2, MPFR version 3.1.5-p10, MPC version 1.0.3, isl version 0.14 or 0.13
...
COLLECT_GCC_OPTIONS='-Wall' '-O2' '-D' '_WINDOWS' '-D' 'WIN32S_COMPAT' '-D' 'FDJ1' '-D' 'AUTO_WINSOCK' '-D' 'USE_CAPI' '-D' 'COVERITY' '-D' 'PERSOPORT' '-D' 'CYGTERMPORT' '-D' 'IMAGEPORT' '-D' 'RECONNECTPORT' '-D' 'HYPERLINKPORT' '-D' 'ZMODEMPORT' '-D' 'STARTBUTTON' '-D' 'LAUNCHERPORT' '-D' 'SAVEDUMPPORT' '-D' 'KEYMAPPINGPORT' '-D' 'WINCRYPTPORT' '-D' 'TUTTYPORT' '-D' 'PORTKNOCKINGPORT' '-D' 'PUTTYXPORT' '-D' 'WTSPORT' '-D' 'PRINTCLIPPORT' '-D' 'RUTTYPORT' '-D' 'DISABLEALTGRPORT' '-D' 'ADBPORT' '-D' '_NO_OLDNAMES' '-D' 'NO_MULTIMON' '-D' 'NO_HTMLHELP' '-I' '.././' '-I' '../../' '-I' '../charset/' '-I' '../windows/' '-I' '../unix/' '-I' '../mac/' '-I' '../macosx' '-I' '../../base64' '-I' '../../bcrypt' '-I' '../../md5' '-I' '../../regex' '-I' '../../url' '-I' '../../wincrypt' '-I' '../../rutty' '-D' '_WIN32_IE=0x0500' '-D' 'WINVER=0x0501' '-D' '_WIN32_WINDOWS=0x0410' '-D' '_WIN32_WINNT=0x0501' '-v' '-c' '-mtune=generic' '-march=pentiumpro'
as -v -I .././ -I ../../ -I ../charset/ -I ../windows/ -I ../unix/ -I ../mac/ -I ../macosx -I ../../base64 -I ../../bcrypt -I ../../md5 -I ../../regex -I ../../url -I ../../wincrypt -I ../../rutty -o be_misc.o C:\Users\kot\AppData\Local\Temp/ccTGGBtt.s
GNU assembler version 2.29.1 (x86_64-pc-cygwin) using BFD version (GNU Binutils) 2.29.1.20171006
C:\Users\kot\AppData\Local\Temp/ccTGGBtt.s: Assembler messages:
汇编消息并不重要。失败是因为 x86_64 汇编程序用于编译 x86 代码。
在日志消息中我可以看到 gcc 是使用 --with-gnu-as
标志编译的。在构建过程中使用标准 as
命令。
所以,问题是:如何在构建过程中指定正确的汇编器 (i686-w64-mingw32-gcc
)?
另外还有一个问题:这个 bug 是来自 cygwin 还是 mingw 应该报告?
我试图通过环境变量 AS
指定汇编程序命令,但它不起作用。
我找到类似的 questions/discussions:
但他们没有给出任何可以接受的答案。我不想重建 mingw 套件。
目前,我看到以下解决方法:创建一些临时目录并在其中添加指向 i686-w64-mingw32-gcc
的符号链接 as
。然后我可以将选项 -Bprefix
传递给 gcc 以指定它寻找二进制文件的位置。
更新:
$ i686-w64-mingw32-gcc --version --verbose
输出:
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/bin/../lib/gcc/i686-w64-mingw32/6.4.0/lto-wrapper.exe
i686-w64-mingw32-gcc (GCC) 6.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Target: i686-w64-mingw32
Configured with: /cygdrive/i/szsz/tmpp/cygwin64/mingw64-i686/mingw64-i686-gcc-6.4.0-1.x86_64/src/gcc-6.4.0/configure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/mingw64-i686/mingw64-i686-gcc-6.4.0-1.x86_64/src/gcc-6.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/mingw64-i686-gcc --htmldir=/usr/share/doc/mingw64-i686-gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=i686-w64-mingw32 --without-libiconv-prefix --without-libintl-prefix --with-sysroot=/usr/i686-w64-mingw32/sys-root --with-build-sysroot=/usr/i686-w64-mingw32/sys-root --disable-multilib --disable-win32-registry --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-fully-dynamic-string --enable-graphite --enable-libgomp --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-version-specific-runtime-libs --with-dwarf2 --with-gnu-ld --with-gnu-as --with-tune=generic --with-cloog-include=/usr/include/cloog-isl --with-system-zlib --enable-threads=posix --libexecdir=/usr/lib
Thread model: posix
gcc version 6.4.0 (GCC)
COLLECT_GCC_OPTIONS='--version' '-v' '-mtune=generic' '-march=pentiumpro'
/bin/../lib/gcc/i686-w64-mingw32/6.4.0/cc1.exe -quiet -v -iprefix /bin/../lib/gcc/i686-w64-mingw32/6.4.0/ -D_REENTRANT help-dummy -quiet -dumpbase help-dummy -mtune=generic -march=pentiumpro -auxbase help-dummy -version --version -o C:\Users\kot\AppData\Local\Temp/ccC3uqbG.s
GNU C11 (GCC) version 6.4.0 (i686-w64-mingw32)
compiled by GNU C version 6.4.0, GMP version 6.1.2, MPFR version 3.1.5-p10, MPC version 1.0.3, isl version 0.14 or 0.13
warning: MPFR header version 3.1.5-p10 differs from library version 3.1.6-p1.
warning: MPC header version 1.0.3 differs from library version 1.1.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='--version' '-v' '-mtune=generic' '-march=pentiumpro'
as -v --version -o C:\Users\kot\AppData\Local\Temp/ccpT4jBG.o C:\Users\kot\AppData\Local\Temp/ccC3uqbG.s
GNU assembler version 2.29.1 (x86_64-pc-cygwin) using BFD version (GNU Binutils) 2.29.1.20171006
GNU assembler (GNU Binutils) 2.29.1.20171006
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-pc-cygwin'.
COMPILER_PATH=/bin/../lib/gcc/i686-w64-mingw32/6.4.0/:/bin/../lib/gcc/
LIBRARY_PATH=/bin/../lib/gcc/i686-w64-mingw32/6.4.0/:/bin/../lib/gcc/:/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/:/usr/i686-w64-mingw32/sys-root/mingw/lib/
COLLECT_GCC_OPTIONS='--version' '-v' '-mtune=generic' '-march=pentiumpro'
/bin/../lib/gcc/i686-w64-mingw32/6.4.0/collect2.exe -plugin /bin/../lib/gcc/i686-w64-mingw32/6.4.0/cyglto_plugin-0.dll -plugin-opt=/bin/../lib/gcc/i686-w64-mingw32/6.4.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\kot\AppData\Local\Temp/cc1gm609.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=/usr/i686-w64-mingw32/sys-root -m i386pe -Bdynamic --version /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/crt2.o /bin/../lib/gcc/i686-w64-mingw32/6.4.0/crtbegin.o -L/bin/../lib/gcc/i686-w64-mingw32/6.4.0 -L/bin/../lib/gcc -L/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib C:\Users\kot\AppData\Local\Temp/ccpT4jBG.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/default-manifest.o /bin/../lib/gcc/i686-w64-mingw32/6.4.0/crtend.o
collect2 version 6.4.0
/bin/i686-w64-mingw32-ld -plugin /bin/../lib/gcc/i686-w64-mingw32/6.4.0/cyglto_plugin-0.dll -plugin-opt=/bin/../lib/gcc/i686-w64-mingw32/6.4.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\kot\AppData\Local\Temp/cc1gm609.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=/usr/i686-w64-mingw32/sys-root -m i386pe -Bdynamic --version /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/crt2.o /bin/../lib/gcc/i686-w64-mingw32/6.4.0/crtbegin.o -L/bin/../lib/gcc/i686-w64-mingw32/6.4.0 -L/bin/../lib/gcc -L/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib C:\Users\kot\AppData\Local\Temp/ccpT4jBG.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/default-manifest.o /bin/../lib/gcc/i686-w64-mingw32/6.4.0/crtend.o
GNU ld (GNU Binutils) 2.29.1.20171006
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
COLLECT_GCC_OPTIONS='--version' '-v' '-mtune=generic' '-march=pentiumpro'
$ i686-w64-mingw32-as --version -v
输出:
GNU assembler (GNU Binutils) 2.29.1.20171006
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `i686-w64-mingw32'.
$ x86_64-w64-mingw32-as --version -v
输出:
GNU assembler (GNU Binutils) 2.29.1.20171006
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-w64-mingw32'.
来自 mingw64-i686-gcc-core 6.4.0-1 的输出
$ i686-w64-mingw32-gcc --version --verbose |& grep COMPILER_PATH
COMPILER_PATH=/usr/lib/gcc/i686-w64-mingw32/6.4.0/:/usr/lib/gcc/i686-w64-mingw32/6.4.0/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-mingw32/6.4.0/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-mingw32/6.4.0/../../../../i686-w64-mingw32/bin/
最后一个目录是 /usr/i686-w64-mingw32/bin
正确的 binutils 所在的目录。
$ cygcheck -l mingw64-i686-binutils | grep "/bin/"
/usr/bin/i686-w64-mingw32-addr2line.exe
/usr/bin/i686-w64-mingw32-ar.exe
/usr/bin/i686-w64-mingw32-as.exe
/usr/bin/i686-w64-mingw32-c++filt.exe
/usr/bin/i686-w64-mingw32-dlltool.exe
/usr/bin/i686-w64-mingw32-dllwrap.exe
/usr/bin/i686-w64-mingw32-elfedit.exe
/usr/bin/i686-w64-mingw32-gprof.exe
/usr/bin/i686-w64-mingw32-ld.bfd.exe
/usr/bin/i686-w64-mingw32-ld.exe
/usr/bin/i686-w64-mingw32-nm.exe
/usr/bin/i686-w64-mingw32-objcopy.exe
/usr/bin/i686-w64-mingw32-objdump.exe
/usr/bin/i686-w64-mingw32-ranlib.exe
/usr/bin/i686-w64-mingw32-readelf.exe
/usr/bin/i686-w64-mingw32-size.exe
/usr/bin/i686-w64-mingw32-strings.exe
/usr/bin/i686-w64-mingw32-strip.exe
/usr/bin/i686-w64-mingw32-windmc.exe
/usr/bin/i686-w64-mingw32-windres.exe
/usr/i686-w64-mingw32/bin/ar.exe
/usr/i686-w64-mingw32/bin/as.exe
/usr/i686-w64-mingw32/bin/dlltool.exe
/usr/i686-w64-mingw32/bin/ld.bfd.exe
/usr/i686-w64-mingw32/bin/ld.exe
/usr/i686-w64-mingw32/bin/nm.exe
/usr/i686-w64-mingw32/bin/objcopy.exe
/usr/i686-w64-mingw32/bin/objdump.exe
/usr/i686-w64-mingw32/bin/ranlib.exe
/usr/i686-w64-mingw32/bin/readelf.exe
/usr/i686-w64-mingw32/bin/strip.exe