Skip to content

Windows build - binutils.build.bash : The build with MinGW fails trying to compile pex-unix.c in place of pex-win32.c #80

@ghost

Description

This is the last problem I encountered with the build on Windows of the AVR toolchain for Windows.

Thanks to the minor adjustments I presented in the issues #77 and #79 I am able to execute without error the scripts tools.bash, binutils.build.bash, gcc.build.bash, avr-libc.build.bash and gdb.build.bash. The result in objdir is an AVR toolchain working in the Cygwin context. This means that the DLL cygwin1.dll must be in the same dir as the exe file or somewhere in the path. MinGW is not required by any of these scripts.

When the script package-avr-gcc.bash is executed on Windows, before to create the package (see #78), it builds everything with MinGW. The goal is to get executable files not depending on Cygwin. But this script fails during the execution of binutils.build.bash with this message:

mingw32-gcc -m32 -c -DHAVE_CONFIG_H -w -O2 -g0 -DWIN32 -D__USE_MINGW_ACCESS  -I. -I../../binutils/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  -D_GNU_SOURCE ../../binutils/libiberty/pex-unix.c -o pex-unix.o
../../binutils/libiberty/pex-unix.c: In function 'save_and_install_fd':
../../binutils/libiberty/pex-unix.c:408:26: error: 'F_GETFD' undeclared (first use in this function)
  408 |   flags = fcntl (old_fd, F_GETFD);
      |                          ^~~~~~~
../../binutils/libiberty/pex-unix.c:408:26: note: each undeclared identifier is reported only once for each function it appears in
../../binutils/libiberty/pex-unix.c:421:20: error: 'FD_CLOEXEC' undeclared (first use in this function)
  421 |       if ((flags & FD_CLOEXEC) == 0 && fcntl (old_fd, F_SETFD, FD_CLOEXEC) < 0)
      |                    ^~~~~~~~~~
../../binutils/libiberty/pex-unix.c:421:55: error: 'F_SETFD' undeclared (first use in this function)
  421 |       if ((flags & FD_CLOEXEC) == 0 && fcntl (old_fd, F_SETFD, FD_CLOEXEC) < 0)
      |                                                       ^~~~~~~
../../binutils/libiberty/pex-unix.c:434:31: error: 'F_DUPFD' undeclared (first use in this function)
  434 |       new_fd = fcntl (old_fd, F_DUPFD, 3);
      |                               ^~~~~~~
../../binutils/libiberty/pex-unix.c: In function 'restore_fd':
../../binutils/libiberty/pex-unix.c:468:19: error: 'FD_CLOEXEC' undeclared (first use in this function)
  468 |       if (flags & FD_CLOEXEC)
      |                   ^~~~~~~~~~
../../binutils/libiberty/pex-unix.c:470:29: error: 'F_SETFD' undeclared (first use in this function)
  470 |       return fcntl (old_fd, F_SETFD, flags);
      |                             ^~~~~~~
../../binutils/libiberty/pex-unix.c: In function 'pex_unix_fdopenw':
../../binutils/libiberty/pex-unix.c:771:18: error: 'F_SETFD' undeclared (first use in this function)
  771 |   if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0)
      |                  ^~~~~~~
../../binutils/libiberty/pex-unix.c:771:27: error: 'FD_CLOEXEC' undeclared (first use in this function)
  771 |   if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0)
      |                           ^~~~~~~~~~
make[2]: *** [Makefile:1112: pex-unix.o] Error 1
make[2]: Leaving directory '/c/toolchain-avr-master/binutils-build/libiberty'
make[1]: *** [Makefile:8037: all-libiberty] Error 2
make[1]: Leaving directory '/c/toolchain-avr-master/binutils-build'
make: *** [Makefile:849: all] Error 2

Looks like we try to compile the file libiberty/pex-unix.c designed for the Unix context in the win32 context.
In fact libiberty/pex-win32.c should be compiled in place of libiberty/pex-unix.c.

An analysis of this problem is presented on StackOverflow. I'm trying to translate these explanations in a solution but currently without success.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions