bugmake - Bugs: bug #61399, multiple definition of `_isatty';...

 
 

bug #61399: multiple definition of `_isatty'; src/w32/compat/posixfcn.o:posixfcn.c

Submitter:  Liviu Ionescu <ilg>
Submitted:  Fri 29 Oct 2021 04:06:33 PM UTC
   
 
Severity:  2 - Minor Item Group:  Build/Install
Status:  Not A Bug Privacy:  Public
Assigned to:  eliz Open/Closed:  Closed
Component Version:  4.3 Operating System:  MS Windows
Fixed Release:  None Triage Status:  Verified
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 30 Oct 2021 12:12:48 PM UTC, comment #6: 

Thanks, closing.

Eli Zaretskii <eliz>
Group Member
Sat 30 Oct 2021 12:09:10 PM UTC, comment #5: 

Sure, the ticket can be closed. (I tried to do it, but probably I don't have the right access rights).

As a conclusion, what we should get from it, is that with GCC 11, to keep the linker happy, the build scripts should use:

'-Wl,--allow-multiple-definition'


I also think that adding some details on how to cross-build make.exe with mingw-gcc on Linux might be useful.

If I can do something to help with this, please let me know (ilg@livius.net).

Liviu Ionescu <ilg>
Sat 30 Oct 2021 10:38:18 AM UTC, comment #4: 

Thanks.  I guess this bug report can now be closed?

Eli Zaretskii <eliz>
Group Member
Sat 30 Oct 2021 09:41:03 AM UTC, comment #3: 

You are right, I am not using the build_w32.bat script because I am running the build on Linux.

I checked the sources of the latest mingw-w64, and there is no implementation of isatty(), there are only lots of references in the .def files, so you were right again.

Since you mentioned that the provided implementation of isatty() is needed, I removed my patch; after re-examining the the error message, I could not identify multiple conflicting implementations of isatty(), so I concluded that the same definition is presented to the linker via multiple paths; I added -Wl,--allow-multiple-definition and the linker no longer complained.

As for the build, I used GCC 11.2 with mingw-w64 9.0.0 / UCRT; in a common Linux cross-build scenario:

git clone https://git.savannah.gnu.org/git/make.git
cd make
git checkout -qf f8f9d371ff58a7195ca4abc9413f435c2bf2b998
bootstrap
bash configure --prefix=.../win32-x64/install/windows-build-tools --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --without-guile --without-libintl-prefix --without-libiconv-prefix ac_cv_dos_paths=yes
make -j
make install-strip


The output of the verbose link command is:

x86_64-w64-mingw32-gcc  -C -Wall -Wextra -Werror -Wwrite-strings -Wshadow -Wdeclaration-after-statement -Wbad-function-cast -Wformat-security -Wtype-limits -Wunused-but-set-parameter -Wlogical-op -Wpointer-arith -Wignored-qualifiers -Wformat-signedness -Wduplicated-cond -ffunction-sections -fdata-sections -pipe -m64 -O2 -w -mthreads -std=gnu99  -O2 -v -Wl,--gc-sections -mthreads -std=gnu99 -Wl,--allow-multiple-definition -o make.exe src/ar.o src/arscan.o src/commands.o src/default.o src/dir.o src/expand.o src/file.o src/function.o src/getopt.o src/getopt1.o src/guile.o src/hash.o src/implicit.o src/job.o src/load.o src/loadapi.o src/main.o src/misc.o src/output.o src/read.o src/remake.o src/rule.o src/signame.o src/strcache.o src/variable.o src/version.o src/vpath.o src/w32/pathstuff.o src/w32/w32os.o src/w32/compat/dirent.o src/w32/compat/posixfcn.o src/w32/subproc/misc.o src/w32/subproc/sub_proc.o src/w32/subproc/w32err.o   src/remote-stub.o   lib/libgnu.a  
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/opt/xbb/usr/libexec/gcc/x86_64-w64-mingw32/11.2.0/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: /root/Work/xbb-3.3-ubuntu-12.04-x86_64/sources/gcc-11.2.0/configure --prefix=/opt/xbb/usr --build=x86_64-linux-gnu --target=x86_64-w64-mingw32 --with-sysroot=/opt/xbb --with-pkgversion='xPack Build Box x86_64 Mingw-w64 GCC' --enable-languages=c,c++,fortran,objc,obj-c++ --enable-shared --enable-static --enable-threads=posix --enable-fully-dynamic-string --enable-libstdcxx-time=yes --enable-cloog-backend=isl --enable-lto --enable-libgomp --enable-checking=release --disable-dw2-exceptions --disable-multilib --disable-rpath ac_cv_header_sys_mman_h=no
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (xPack Build Box x86_64 Mingw-w64 GCC)
COMPILER_PATH=/opt/xbb/usr/libexec/gcc/x86_64-w64-mingw32/11.2.0/:/opt/xbb/usr/libexec/gcc/x86_64-w64-mingw32/11.2.0/:/opt/xbb/usr/libexec/gcc/x86_64-w64-mingw32/:/opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/:/opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/:/opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=/opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/:/opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/:/opt/xbb/mingw/lib/../lib/:/opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/:/opt/xbb/mingw/lib/
COLLECT_GCC_OPTIONS='-C' '-Wall' '-Wextra' '-Werror' '-Wwrite-strings' '-Wshadow' '-Wdeclaration-after-statement' '-Wbad-function-cast' '-Wformat-security' '-Wtype-limits' '-Wunused-but-set-parameter' '-Wlogical-op' '-Wpointer-arith' '-Wignored-qualifiers' '-Wformat-signedness' '-Wduplicated-cond' '-ffunction-sections' '-fdata-sections' '-pipe' '-m64' '-O2' '-w' '-mthreads' '-std=gnu99' '-O2' '-v' '-mthreads' '-std=gnu99' '-o' 'make.exe' '-mtune=generic' '-march=x86-64' '-dumpdir' 'make.'
 /opt/xbb/usr/libexec/gcc/x86_64-w64-mingw32/11.2.0/collect2 -plugin /opt/xbb/usr/libexec/gcc/x86_64-w64-mingw32/11.2.0/liblto_plugin.so -plugin-opt=/opt/xbb/usr/libexec/gcc/x86_64-w64-mingw32/11.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccqRBk8N.res -plugin-opt=-pass-through=-lmingwthrd -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=-lkernel32 -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=-lmingwthrd -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=-lkernel32 --sysroot=/opt/xbb -m i386pep -Bdynamic -o make.exe /opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o /opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/crtbegin.o -L/opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0 -L/opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib -L/opt/xbb/mingw/lib/../lib -L/opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib -L/opt/xbb/mingw/lib --gc-sections --allow-multiple-definition src/ar.o src/arscan.o src/commands.o src/default.o src/dir.o src/expand.o src/file.o src/function.o src/getopt.o src/getopt1.o src/guile.o src/hash.o src/implicit.o src/job.o src/load.o src/loadapi.o src/main.o src/misc.o src/output.o src/read.o src/remake.o src/rule.o src/signame.o src/strcache.o src/variable.o src/version.o src/vpath.o src/w32/pathstuff.o src/w32/w32os.o src/w32/compat/dirent.o src/w32/compat/posixfcn.o src/w32/subproc/misc.o src/w32/subproc/sub_proc.o src/w32/subproc/w32err.o src/remote-stub.o lib/libgnu.a -lmingwthrd -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingwthrd -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 /opt/xbb/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/crtend.o
COLLECT_GCC_OPTIONS='-C' '-Wall' '-Wextra' '-Werror' '-Wwrite-strings' '-Wshadow' '-Wdeclaration-after-statement' '-Wbad-function-cast' '-Wformat-security' '-Wtype-limits' '-Wunused-but-set-parameter' '-Wlogical-op' '-Wpointer-arith' '-Wignored-qualifiers' '-Wformat-signedness' '-Wduplicated-cond' '-ffunction-sections' '-fdata-sections' '-pipe' '-m64' '-O2' '-w' '-mthreads' '-std=gnu99' '-O2' '-v' '-mthreads' '-std=gnu99' '-o' 'make.exe' '-mtune=generic' '-march=x86-64' '-dumpdir' 'make.'

---

If understand that this procedure is not yet officially supported, but it seems ok.

Of course, if you spot any problems with it, I would appreciate any advice on how to improve it.

Liviu Ionescu <ilg>
Sat 30 Oct 2021 08:53:06 AM UTC, comment #2: 

Hi Eli,

Thank you for your comment. I'll review it carefully and retry the build, as you described.

Liviu Ionescu <ilg>
Sat 30 Oct 2021 08:29:41 AM UTC, comment #1: 

Thanks, but the data you presented doesn't tell enough to devise the solution (if one is needed, see below).  The most important piece of information that is missing is: where in MinGW64 is 'isatty' defined, and how did that definition end up being pulled by the linker into the binary?

Also, it sounds like you didn't use the build_w32.bat batch file to build Make, because the link command doesn't look like the link command specified by that script, and libgnu.a isn't supposed to be  part of the link comm and.  Did you per chance use the Posix configure script and Makefile.in to build Make?  If so, that method is not currently supported for building a MinGW port of make, only the build_w32.bat script is supported.

Finally, Make provides 'isatty' not because it's missing in the Windows runtime, but because the existing implementation is buggy, see the comment in posixfcn.c about that.  IOW, we want to replace the existing implementation.

Eli Zaretskii <eliz>
Group Member
Fri 29 Oct 2021 04:06:33 PM UTC, original submission:  

I tried to compile the top master commit (f8f9d371f) with the latest mingw 9.0 & gcc 11.3 and, while linking make.exe, I got:

x86_64-w64-mingw32-gcc  -C -Wall -Wextra -Werror -Wwrite-strings -Wshadow -Wdeclaration-after-statement -Wbad-function-cast -Wformat-security -Wtype-limits -Wunused-but-set-parameter -Wlogical-op -Wpointer-arith -Wignored-qualifiers -Wformat-signedness -Wduplicated-cond -ffunction-sections -fdata-sections -pipe -m64 -O2 -w  -O2 -v -Wl,--gc-sections -o make.exe src/ar.o src/arscan.o src/commands.o src/default.o src/dir.o src/expand.o src/file.o src/function.o src/getopt.o src/getopt1.o src/guile.o src/hash.o src/implicit.o src/job.o src/load.o src/loadapi.o src/main.o src/misc.o src/output.o src/read.o src/remake.o src/rule.o src/signame.o src/strcache.o src/variable.o src/version.o src/vpath.o src/w32/pathstuff.o src/w32/w32os.o src/w32/compat/dirent.o src/w32/compat/posixfcn.o src/w32/subproc/misc.o src/w32/subproc/sub_proc.o src/w32/subproc/w32err.o   src/remote-stub.o   lib/libgnu.a  
: multiple definition of `_isatty'; src/w32/compat/posixfcn.o:posixfcn.c:(.text$_isatty+0x0): first defined here
collect2: error: ld returned 1 exit status
make[1]: * [Makefile:1365: make.exe] Error 1
make[1]: Leaving directory '/Host/Users/ilg/Work/windows-build-tools-4.3.0-1/win32-x64/build/make-f8f9d371ff58a7195ca4abc9413f435c2bf2b998'
make: * [Makefile:1514: all-recursive] Error 1


It looks like the mingw-w64 9.0 already includes support for _isatty(), and the local implementation is no longer needed.


My quick and dirty workaround was to locally patch the sources to get rid of the duplicate definitions:

sed -i.bak \
    -e 's|^isatty (int fd)$|__isatty (int fd)|' \
    -e 's|^ttyname (int fd)$|__ttyname (int fd)|' \
    src/w32/compat/posixfcn.c

However, I think that a better solution should be considered, like for example configure to check if these functions are available and set some configuration macros to automate this.


Liviu Ionescu <ilg>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by eliz (Posted a comment)
  • -email is unavailable- added by ilg (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-10-30 eliz StatusNone Not A Bug
    2021-10-30 eliz Severity3 - Normal 2 - Minor
        Assigned toNone eliz
        Open/ClosedOpen Closed
        Triage StatusNone Verified

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code