windows - 为什么 binutils-gdb 无法从 MSYS2 构建?

标签 windows gdb autotools msys2 binutils

我正在尝试在 Windows 10 PC 上从 msys2 环境中构建 binutils-gdb。

git://sourceware.org/git/binutils-gdb.git

大部分代码编译正常,但 libiberty 构建失败,pex-win32.c 中出现错误:

./pex-win32.c:121:10: warning: implicit declaration of function ‘_open’; did you mean ‘open’? [-Wimplicit-function-declaration]
./pex-win32.c:121:23: error: ‘_O_RDONLY’ undeclared (first use in this function); did you mean ‘O_RDONLY’?

(注意:以上是前几个编译错误的示例)。

我怀疑我需要将一个选项传递给 ./configure 以更正此问题但不确定它是什么。我目前正在运行 ./configure,没有任何选项。

默认情况下,构建、主机和目标系统类型都设置为 x86_64-w64-mingw32。

configure:2678: checking build system type
configure:2692: result: x86_64-w64-mingw32

如果我在 pex-win32.c 上运行预处理器,我可以看到它包含以下打开声明:

# 201 "/usr/include/sys/_default_fcntl.h" 2 3 4

extern int open (const char *, int, ...);

但是 pex-win32.c 不使用 open,它使用 _open(pex-win32.c 文件中带下划线的其他符号也存在类似问题,但标题中没有)。

return _open (name, _O_RDONLY | (binary ? _O_BINARY : _O_TEXT));

在 _default_fcntl.h header 的更下方,我看到包含在 #ifdef _COMPILING_NEWLIB 中的正确声明:

/* Provide _<systemcall> prototypes for functions provided by some versions
of newlib.  */
#ifdef _COMPILING_NEWLIB
extern int _open (const char *, int, ...);

但是,如果我将 CFLAGS+="-D_COMPILING_NEWLIB"传递给 make,则会产生其他构建错误,我认为这不是答案。

关于如何让 binutils-gdb 从 msys2 环境构建的任何想法?

谢谢!

更新

我尝试重现构建 msys2 gdb 包。

这失败了:

==> ERROR: A failure occurred in build().
    Aborting...

完整输出:

MSYS /
$cd /d/git

MSYS /d/git
$echo $MSYSTEM
MSYS

MSYS /d/git
$git clone https://github.com/Alexpux/MSYS2-packages.git
Cloning into 'MSYS2-packages'...
remote: Counting objects: 19033, done.
remote: Compressing objects: 100% (93/93), done.
remote: Total 19033 (delta 31), reused 81 (delta 25), pack-reused 18911
Receiving objects: 100% (19033/19033), 16.14 MiB | 9.82 MiB/s, done.
Resolving deltas: 100% (9917/9917), done.

MSYS /d/git
$cd MSYS2-packages/gdb

MSYS /d/git/MSYS2-packages/gdb
$makepkg -sCLf --skippgpcheck
==> Making package: gdb 7.12.1-1 (Mon, Jul 30, 2018  4:12:59 PM)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Downloading gdb-7.12.1.tar.xz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 18.3M  100 18.3M    0     0  8187k      0  0:00:02  0:00:02 --:--:-- 8187k
  -> Downloading gdb-7.12.1.tar.xz.sig...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    72  100    72    0     0    295      0 --:--:-- --:--:-- --:--:--   295
  -> Found gdbinit
  -> Found 0001-Teach-gdb-how-to-unwind-cygwin-_sigbe-and-sigdelayed.patch
  -> Found 0002-7.8-windows-nat-cygwin.patch
  -> Found 0003-Better-handling-for-realpath-failures-in-windows_mak.patch
  -> Found 0004-7.8-symtab-cygwin.patch
  -> Found 0005-Remove-a-spurious-target_terminal_ours-from-windows_.patch
  -> Found 0006-PR-build-21187-Static-linking-of-libstdc-and-libgcc-.patch
  -> Found 0010-Support-settings-thread-name-MS-Windows.patch
  -> Found gdb-7.11.1-msysize.patch
==> WARNING: Skipping verification of source file PGP signatures.
==> Validating source files with sha256sums...
    gdb-7.12.1.tar.xz ... Passed
    gdb-7.12.1.tar.xz.sig ... Skipped
    gdbinit ... Passed
    0001-Teach-gdb-how-to-unwind-cygwin-_sigbe-and-sigdelayed.patch ... Passed
    0002-7.8-windows-nat-cygwin.patch ... Passed
    0003-Better-handling-for-realpath-failures-in-windows_mak.patch ... Passed
    0004-7.8-symtab-cygwin.patch ... Passed
    0005-Remove-a-spurious-target_terminal_ours-from-windows_.patch ... Passed
    0006-PR-build-21187-Static-linking-of-libstdc-and-libgcc-.patch ... Passed
    0010-Support-settings-thread-name-MS-Windows.patch ... Passed
    gdb-7.11.1-msysize.patch ... Passed
==> Removing existing $srcdir/ directory...
==> Extracting sources...
  -> Extracting gdb-7.12.1.tar.xz with bsdtar
==> Starting prepare()...
patching file gdb/amd64-windows-tdep.c
patching file gdb/i386-cygwin-tdep.c
patching file gdb/windows-tdep.c
patching file gdb/windows-tdep.h
patching file gdb/windows-nat.c
patching file gdb/windows-nat.c
patching file gdb/symtab.c
patching file gdb/windows-nat.c
patching file gdb/ChangeLog
patching file gdb/NEWS
Hunk #1 succeeded at 142 with fuzz 2 (offset 141 lines).
patching file gdb/windows-nat.c
Hunk #1 succeeded at 173 (offset 1 line).
Hunk #2 succeeded at 454 (offset 1 line).
Hunk #3 succeeded at 1063 (offset 20 lines).
Hunk #4 succeeded at 1091 (offset 19 lines).
Hunk #5 succeeded at 1173 (offset 19 lines).
Hunk #6 succeeded at 1224 (offset 19 lines).
Hunk #7 succeeded at 1580 (offset 19 lines).
Hunk #8 succeeded at 2591 (offset 17 lines).
Hunk #9 succeeded at 2623 (offset 17 lines).
patching file bfd/acinclude.m4
Hunk #1 succeeded at 21 (offset -2 lines).
patching file bfd/config.bfd
Hunk #1 succeeded at 729 with fuzz 2 (offset 50 lines).
Hunk #2 succeeded at 782 with fuzz 2 (offset 51 lines).
patching file bfd/configure
Hunk #1 succeeded at 5996 (offset 6 lines).
Hunk #2 succeeded at 6338 (offset 6 lines).
Hunk #3 succeeded at 6918 (offset 6 lines).
Hunk #4 succeeded at 8502 (offset 6 lines).
Hunk #5 succeeded at 8584 (offset 6 lines).
Hunk #6 succeeded at 9046 (offset 6 lines).
Hunk #7 succeeded at 9161 (offset 6 lines).
Hunk #8 succeeded at 9592 (offset 6 lines).
Hunk #9 succeeded at 10493 (offset 6 lines).
Hunk #10 succeeded at 10524 (offset 6 lines).
Hunk #11 succeeded at 11166 (offset 6 lines).
Hunk #12 succeeded at 13767 (offset 97 lines).
Hunk #13 succeeded at 13943 (offset -1015 lines).
Hunk #14 succeeded at 14098 (offset -1015 lines).
patching file bfd/configure.ac
Hunk #1 succeeded at 267 (offset -316 lines).
patching file config/dfp.m4
patching file config/elf.m4
Hunk #1 succeeded at 15 with fuzz 2 (offset 2 lines).
patching file config/lthostflags.m4
patching file config/mmap.m4
patching file config/picflag.m4
Hunk #1 succeeded at 25 (offset 6 lines).
patching file config/tcl.m4
patching file config.guess
Hunk #1 succeeded at 888 (offset 22 lines).
patching file config.rpath
patching file configure
Hunk #1 succeeded at 3036 (offset 17 lines).
Hunk #2 succeeded at 3556 (offset 116 lines).
Hunk #3 succeeded at 3569 (offset 118 lines).
Hunk #4 succeeded at 3843 (offset 136 lines).
Hunk #5 succeeded at 3987 (offset 145 lines).
Hunk #6 succeeded at 6138 with fuzz 2 (offset -119 lines).
Hunk #7 succeeded at 6156 (offset -118 lines).
Hunk #8 succeeded at 6167 (offset -118 lines).
Hunk #9 succeeded at 6177 (offset -118 lines).
Hunk #10 succeeded at 7048 (offset -36 lines).
Hunk #11 succeeded at 7556 (offset -29 lines).
patching file configure.ac
Hunk #1 succeeded at 409 (offset 33 lines).
Hunk #2 succeeded at 892 (offset 127 lines).
Hunk #3 succeeded at 905 (offset 126 lines).
Hunk #4 succeeded at 1179 (offset 144 lines).
Hunk #5 succeeded at 1323 (offset 153 lines).
Hunk #6 succeeded at 1817 (offset 112 lines).
Hunk #7 succeeded at 1828 (offset 112 lines).
Hunk #8 succeeded at 1838 (offset 112 lines).
Hunk #9 succeeded at 2652 (offset 190 lines).
Hunk #10 succeeded at 3155 (offset 198 lines).
patching file gdb/config/i386/msys.mh
patching file gdb/config/i386/msys64.mh
patching file gdb/configure
Hunk #1 succeeded at 8002 (offset 901 lines).
Hunk #2 succeeded at 14418 (offset 1285 lines).
Hunk #3 succeeded at 15095 (offset 1062 lines).
Hunk #4 succeeded at 15138 (offset 1062 lines).
Hunk #5 succeeded at 15267 (offset 1062 lines).
patching file gdb/configure.ac
Hunk #1 succeeded at 610 (offset -8 lines).
Hunk #2 succeeded at 1960 (offset -132 lines).
Hunk #3 succeeded at 2032 (offset -139 lines).
patching file gdb/configure.host
Hunk #1 succeeded at 116 with fuzz 2 (offset 1 line).
Hunk #2 succeeded at 184 (offset -4 lines).
patching file gdb/configure.tgt
Hunk #1 succeeded at 239 (offset 1 line).
Hunk #2 succeeded at 677 with fuzz 2 (offset 2 lines).
Hunk #3 succeeded at 722 (offset 2 lines).
patching file gdb/gdbserver/configure.srv
Hunk #1 succeeded at 111 (offset 13 lines).
Hunk #2 succeeded at 377 (offset 48 lines).
patching file gdb/gnulib/import/Makefile.am
Hunk #1 succeeded at 427 (offset 44 lines).
patching file gdb/gnulib/import/Makefile.in
Hunk #1 succeeded at 1972 (offset 284 lines).
patching file gdb/testsuite/gdb.base/bigcore.exp
Hunk #1 succeeded at 33 with fuzz 1 (offset -1 lines).
patching file gdb/testsuite/gdb.base/fileio.exp
Hunk #1 succeeded at 253 (offset 7 lines).
patching file gdb/testsuite/gdb.base/maint.exp
Hunk #1 succeeded at 138 (offset -8 lines).
Hunk #2 succeeded at 443 (offset -5 lines).
patching file gdb/testsuite/gdb.base/shreloc.exp
Hunk #2 succeeded at 248 (offset 1 line).
patching file gdb/testsuite/gdb.base/solib-weak.exp
patching file gdb/testsuite/gdb.dwarf2/dw2-dos-drive.exp
patching file gdb/testsuite/gdb.server/wrapper.exp
patching file gdb/testsuite/lib/gdb.exp
Hunk #1 succeeded at 1802 (offset 6 lines).
Hunk #2 succeeded at 3420 (offset 76 lines).
Hunk #3 succeeded at 3429 (offset 76 lines).
Hunk #4 succeeded at 3454 with fuzz 1 (offset 74 lines).
Hunk #5 succeeded at 3502 (offset 74 lines).
Hunk #6 succeeded at 3621 (offset 74 lines).
Hunk #7 succeeded at 3630 (offset 74 lines).
Hunk #8 succeeded at 3662 (offset 77 lines).
Hunk #9 succeeded at 4070 (offset 79 lines).
Hunk #10 succeeded at 5059 (offset 93 lines).
Hunk #11 succeeded at 5095 (offset 93 lines).
patching file gdb/windows-nat.c
Hunk #1 succeeded at 674 with fuzz 2 (offset -8 lines).
patching file libdecnumber/configure
Hunk #1 succeeded at 4655 (offset 36 lines).
patching file libiberty/configure
Hunk #1 succeeded at 5109 (offset 212 lines).
Hunk #2 succeeded at 6175 (offset 363 lines).
patching file libiberty/configure.ac
Hunk #1 succeeded at 549 (offset 10 lines).
patching file libtool.m4
patching file ltmain.sh
patching file ltoptions.m4
patching file opcodes/configure
Hunk #1 succeeded at 5718 (offset 1 line).
Hunk #2 succeeded at 6060 (offset 1 line).
Hunk #3 succeeded at 6640 (offset 1 line).
Hunk #4 succeeded at 8225 (offset 1 line).
Hunk #5 succeeded at 8307 (offset 1 line).
Hunk #6 succeeded at 8769 (offset 1 line).
Hunk #7 succeeded at 8884 (offset 1 line).
Hunk #8 succeeded at 9315 (offset 1 line).
Hunk #9 succeeded at 10216 (offset 1 line).
Hunk #10 succeeded at 10247 (offset 1 line).
Hunk #11 succeeded at 10889 (offset 1 line).
Hunk #12 succeeded at 12343 (offset 46 lines).
Hunk #13 succeeded at 12513 (offset 46 lines).
patching file opcodes/configure.ac
Hunk #1 succeeded at 175 (offset -6 lines).
patching file readline/configure
patching file readline/configure.in
patching file readline/support/config.guess
patching file readline/support/config.rpath
patching file readline/support/config.sub
patching file readline/support/shlib-install
patching file readline/support/shobj-conf
patching file sim/arm/configure
Hunk #1 succeeded at 6229 (offset 99 lines).
Hunk #2 succeeded at 6571 (offset 99 lines).
Hunk #3 succeeded at 7193 (offset 99 lines).
Hunk #4 succeeded at 9906 (offset 567 lines).
Hunk #5 succeeded at 10450 (offset 567 lines).
Hunk #6 succeeded at 10565 (offset 567 lines).
Hunk #7 succeeded at 10996 (offset 567 lines).
Hunk #8 succeeded at 11897 (offset 567 lines).
Hunk #9 succeeded at 11928 (offset 567 lines).
Hunk #10 succeeded at 12570 (offset 567 lines).
==> Starting build()...
configure: loading site script /etc/config.site
checking build system type... x86_64-pc-msys
checking host system type... x86_64-pc-msys
checking target system type... x86_64-pc-msys
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... no, using cp -p
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... gawk
checking to see if cat works as expected... yes
checking for x86_64-pc-msys-gcc... x86_64-pc-msys-gcc
==> ERROR: A failure occurred in build().
    Aborting...

MSYS /d/git/MSYS2-packages/gdb
$which gcc
/usr/bin/gcc

MSYS /d/git/MSYS2-packages/gdb
$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-msys/7.3.0/lto-wrapper.exe
Target: x86_64-pc-msys
Configured with: /msys_scripts/gcc/src/gcc-7.3.0/configure --build=x86_64-pc-msys --prefix=/usr --libexecdir=/usr/lib --enable-bootstrap --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --disable-multilib --enable-__cxa_atexit --with-dwarf2 --enable-languages=c,c++,fortran,lto --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp --enable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=release --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 7.3.0 (GCC)

MSYS /d/git/MSYS2-packages/gdb
$

更新

从环境中删除它,您可以构建 gdb 包:

MSYS_PATH_TYPE=inherit

最佳答案

您的构建环境不正确。

MSYS2 有 3 个 shell(和工具链)

  • MSYS2:使用 msys-2.0.dll 进行 posix 仿真(类似于 cygwin1.dll)。
  • MINGW32:32 位 Windows 原生
  • MINGW64:64 位 Windows 原生

libiberty/configure 根据这个逻辑选择要使用的 pex 版本:

# Figure out which version of pexecute to use.
case "${host}" in
     *-*-mingw* | *-*-winnt*)   pexecute=pex-win32  ;;
     *-*-msdosdjgpp*)       pexecute=pex-djgpp  ;;
     *-*-msdos*)        pexecute=pex-msdos  ;;
     *)             pexecute=pex-unix   ;;
esac

如果您使用的是 msys shell(posix 仿真),您的 configure --build 应该是 x86_64-pc-msys,上面的逻辑应该选择 pex-unix.c。

此外,如果您想使用 msys shell 构建 posix 模拟 gdb,那么您可能应该使用这些补丁:https://github.com/Alexpux/MSYS2-packages/tree/master/gdb .

关于windows - 为什么 binutils-gdb 无法从 MSYS2 构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51585102/

相关文章:

c++ - 如何检查 _bstr_t 是否包含(类似于 str.find)字符串

windows - 使用RAWINPUT区分左右shift键

c - 为什么 GDB 启动一个新的 shell 以及如何禁用此行为?

autotools - 如何在 autotools 项目上设置默认 CPPFLAGS

c++ - Autoconf 没有正确定义变量

c++ - windows xp本地时间夏令时问题

python - 为什么 python windows 安装程序使用旧版本的 pip 进行分发?

c - 如何使用 GDB(或其他程序)获得堆栈的总体概述?

memory - GDB 中的 x86 标签和 LEA

c++ - Qt Automake 单独的include、ui、资源文件夹