https://sourceware.org/bugzilla/show_bug.cgi?id=33507
Bug ID: 33507
Summary: Binutils installs libtool wrapper on MinGW-w64 with
LTO enabled
Product: binutils
Version: 2.45
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: c at cyano dot cn
Target Milestone: ---
Created attachment 16398
--> https://sourceware.org/bugzilla/attachment.cgi?id=16398&action=edit
Libtool wrapper for as.exe built with LTO, no '%%%MAGIC EXE variable%%%' found
I'm cross-compiling binutils on Linux for MinGW-w64 x86-64. Binutils installs
libtool wrapper, to destdir with LTO enabled.
Output of `ls -al $PREFIX/bin`:
```
-rwxr-xr-x 1 root root 28160 Oct 1 00:14 addr2line.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 ar.exe
-rwxr-xr-x 1 root root 28160 Oct 1 00:14 as.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 c++filt.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 dlltool.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 dllwrap.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 elfedit.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 gprof.exe
-rwxr-xr-x 2 root root 28160 Oct 1 00:14 ld.bfd.exe
-rwxr-xr-x 2 root root 28160 Oct 1 00:14 ld.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 nm.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 objcopy.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 objdump.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 ranlib.exe
-rwxr-xr-x 1 root root 28160 Oct 1 00:14 readelf.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 size.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 strings.exe
-rwxr-xr-x 1 root root 28160 Oct 1 00:14 strip.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 windmc.exe
-rwxr-xr-x 1 root root 27648 Oct 1 00:14 windres.exe
```
File sizes are ~27 KiB, all of them are libtool wrappers, not actual programs
(should be ~1 MiB).
The related lines of `make install V=1` output:
```
/bin/bash ./libtool --mode=install /usr/bin/install -c as-new.exe
/bin/as.exe
libtool: install: /usr/bin/install -c as-new.exe /bin/as.exe
```
Without LTO:
```
/bin/bash ./libtool --mode=install /usr/bin/install -c as-new.exe
/bin/as.exe
libtool: install: /usr/bin/install -c .libs/as-new.exe /bin/as.exe
```
I added `set -x` to `libtool`, and found the difference:
```
+ func_ltwrapper_executable_p as-new.exe
+ func_ltwrapper_exec_suffix=
+ case $1 in
+ /usr/bin/grep '%%%MAGIC EXE variable%%%' as-new.exe
+ func_stripname '' .exe as-new.exe
+ func_stripname_result=as-new.exe
+ func_stripname_result=as-new.exe
+ func_stripname_result=as-new
```
Without LTO:
```
+ func_ltwrapper_executable_p as-new.exe
+ func_ltwrapper_exec_suffix=
+ case $1 in
+ /usr/bin/grep '%%%MAGIC EXE variable%%%' as-new.exe
+ func_ltwrapper_scriptname as-new.exe
+ func_ltwrapper_scriptname_result=
+ func_ltwrapper_executable_p as-new.exe
+ func_ltwrapper_exec_suffix=
```
I believe this is the root cause: `grep '%%%MAGIC EXE variable%%%' as-new.exe`
failed, because LTO removed the unused variable.
== Additional info ==
Binutils configured with:
```
../configure --prefix= --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
--build=x86_64-linux-gnu --enable-shared --enable-static
--disable-install-libbfd --disable-multilib --enable-nls CPPFLAGS=-DNDEBUG
-D_WIN32_WINNT=0x0600 CFLAGS="-pipe -O2 -flto" CXXFLAGS="-pipe -O2 -flto"
LDFLAGS="-s -O2 -flto" AR=x86_64-w64-mingw32-gcc-ar
RANLIB=x86_64-w64-mingw32-gcc-ranlib
```
GCC configuration:
```
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/local/lib/gcc/x86_64-w64-mingw32/15/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/usr/local --libexecdir=/usr/local/lib
--with-gcc-major-version-only --target=x86_64-w64-mingw32
--build=x86_64-linux-gnu --disable-shared --enable-static --disable-bootstrap
--enable-checking=release --enable-host-pie --enable-languages=c,c++,fortran
--disable-libgomp --disable-libmpx --disable-multilib --disable-nls
--enable-threads=posix --with-arch=x86-64-v2 --without-libcc1
--with-tune=generic CPPFLAGS=-DNDEBUG CFLAGS='-O2 -pipe' CXXFLAGS='-O2 -pipe'
LDFLAGS=-s 'CPPFLAGS_FOR_TARGET=-DNDEBUG -D_WIN32_WINNT=0x0600'
'CFLAGS_FOR_TARGET=-pipe -O2' 'CXXFLAGS_FOR_TARGET=-pipe -O2'
LDFLAGS_FOR_TARGET=-s
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.2.0 (GCC)
```
--
You are receiving this mail because:
You are on the CC list for the bug.