libtool installs the wrapper executable in MSVC with -O2 -GL options

Yang Kun <[email protected]> Sat, 10 May 2025 21:42:17 +0800
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <BYAPR12MB264766A8A53DF7A215926488CA95A@BYAPR12MB2647.namprd12.prod.outlook.com>
Greetings,

I'm trying to build libiconv with some additional optimization options 
enabled.
Initially, I just specify these options in CFLAGS, and then it failed 
with some
an error.

libtool: link: dumpbin.exe -symbols -headers .libs/localcharset.obj 
.libs/relocatable-stub.obj   |  | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ 
]\([^ ]*\)/\1,DATA/' | /usr/bin/sed -e '/^[AITW][ ]/s/.*[ ]//' | sort | 
uniq > .libs/charset.exp
../libtool: eval: line 1911: syntax error near unexpected token `|'

I found that some variables were empty in libtool (generated by 
config.status)
due to I specify these options.

# Transform the output of nm in a proper C declaration.
global_symbol_to_cdecl=""

# Transform the output of nm into a list of symbols to manually relocate.
global_symbol_to_import=""

Then, I leave the CFLAGS empty and set CL environment variable before 
make runs
to workaround. However, when I runs the iconv.exe in bin/, It complains
iconv.exe not found in lt-iconv.c. I read the installation log and found 
that
libtool installs iconv.exe rather than .libs/iconv.exe.

I've made a minimal steps to reproduce this issue. Please notice that the
libtool is generated by config.status, not system ones. Unfortunately, I 
don't
know how to generate it manually. If you cannot reproduce it, I'm happy to
provide the full steps to build libiconv.

export CL="-nologo -utf-8 -O2 -GL" VSLANG=1033
echo "int main(void) {}" > test.c
./libtool --mode=link compile cl.exe test.c -o test.exe
./libtool --mode=install /usr/bin/install -c test.exe /tmp/test.exe

Here is the output.

./libtool --mode=link compile cl.exe test.c -o test.exe
./libtool --mode=install /usr/bin/install -c test.exe /tmp/test.exe
libtool: link: compile cl.exe test.c -o .libs/test.exe
libtool: link: lt_outputfile=".libs/test.exe"
libtool: link:  lt_tool_outputfile=".libs/test.exe"
libtool: link:  case .libs/test.exe in *.exe|*.EXE) ;; *) 
lt_outputfile=.libs/test.exe.exe lt_tool_outputfile=.libs/test.exe.exe 
;; esac
libtool: link:  if test : != "mt" && test -f ".libs/test.exe.manifest"; 
then mt -manifest ".libs/test.exe.manifest" 
-outputresource:".libs/test.exe" || exit 1; rm -f 
".libs/test.exe.manifest"; fi
lt-test.c
libtool: install: /usr/bin/install -c test.exe /tmp/test.exe


I would appreciate it if you could reply.

Best Regards,
Yang Kun