bug-gnu-libiconv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gnu-libiconv] The configure script is using wrong parameter -Wl for


From: Fx Ne
Subject: [bug-gnu-libiconv] The configure script is using wrong parameter -Wl for msvc complier
Date: Fri, 21 Jun 2024 00:49:10 +0800

Using -Wl will cause error and stop the complier.
For msvc the WL is for detailed error info , not for enter options.

log
-----------------------------------------------------------------------------------

builddir="`pwd`"; cd libcharset && make all && make install-lib libdir="$builddir/lib" includedir="$builddir/lib"
make[1]: Entering directory '/f/Software/Application/lib/libiconv-1.17/libcharset'
cd lib && make all
make[2]: Entering directory '/f/Software/Application/lib/libiconv-1.17/libcharset/lib'
/bin/sh ../libtool --mode=link cl.exe  -g  -o libcharset.la -rpath F:\Software\Application\lib\libiconv/lib -version-info 1:0:0 -no-undefined localcharset.lo relocatable-stub.lo
libtool: link: rm -fr  .libs/charset.exp
libtool: link: dumpbin -symbols -headers  .libs/localcharset.obj .libs/relocatable-stub.obj    | gawk '     {last_section=section; section=$ 3};     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};     /^ *Symbol name *: /{split($ 0,sn,":"); si=substr(sn[2],2)};     /^ *Type *: code/{print "T",si,substr(si,length(prfx))};     /^ *Type *: data/{print "I",si,substr(si,length(prfx))};     $ 0!~/External *\|/{next};     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};     {if(hide[section]) next};     {f="D"}; $ 0~/\(\).*\|/{f="T"};     {split($ 0,a,/\||\r/); split(a[2],s)};     s[1]~/^[@?]/{print f,s[1],s[1]; next};     s[1]~prfx {split(s[1],t,"@"); print f,t[1],substr(t[1],length(prfx))}     ' prfx=^ | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/' | /usr/bin/sed -e '/^[AITW][ ]/s/.*[ ]//' | sort | uniq > .libs/charset.exp
libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[  ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([     ].*\)*$/DEF/p' -e q .libs/charset.exp`" ; then cp ".libs/charset.exp" ".libs/charset-1.dll.def"; echo ".libs\\charset-1.dll.def" > ".libs/charset-1.dll.exp"; else /usr/bin/sed -e 's/^/-link -EXPORT:/' < .libs/charset.exp > .libs/charset-1.dll.exp; fi
libtool: link:  cl.exe -o .libs\\charset-1.dll  .libs/localcharset.obj .libs/relocatable-stub.obj    -g    "@.libs\\charset-1.dll.exp" -Wl,-DLL,-IMPLIB:".libs\\charset.dll.lib"
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30152 版
版权所有(C) Microsoft Corporation。保留所有权利。

cl: 命令行 warning D9035 :“o”选项已否决,并将在将来的版本中移除
//-o parameter will be removed in future version.
cl -link -EXPORT:?_OptionsStorage@?1??__local_stdio_printf_options@@9@9,DATA
   -link -EXPORT:libcharset_set_relocation_prefix
   -link -EXPORT:locale_charset
cl: 命令行 error D8021 :无效的数值参数“/Wl,-DLL,-IMPLIB:.libs\charset.dll.lib”
//invalid parameter
make[2]: *** [Makefile:55: libcharset.la] Error 2
make[2]: Leaving directory '/f/Software/Application/lib/libiconv-1.17/libcharset/lib'
make[1]: *** [Makefile:34: all] Error 2
make[1]: Leaving directory '/f/Software/Application/lib/libiconv-1.17/libcharset'
make: *** [Makefile:41: lib/localcharset.h] Error 2
-----------------------------------------------------------------------------------
I modified the libtool on libcharset\lib\
And it continue compile then stop at

libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[  ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([     ].*\)*$/DEF/p' -e q .libs/charset.exp`" ; then cp ".libs/charset.exp" ".libs/charset-1.dll.def"; echo ".libs\\charset-1.dll.def" > ".libs/charset-1.dll.exp"; else /usr/bin/sed -e 's/^/-link -EXPORT:/' < .libs/charset.exp > .libs/charset-1.dll.exp; fi
libtool: link:  cl.exe -o .libs\\charset-1.dll  .libs/localcharset.obj .libs/relocatable-stub.obj    -g    "@.libs\\charset-1.dll.exp" -DLL,-IMPLIB:".libs\\charset.dll.lib"
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30152 版
版权所有(C) Microsoft Corporation。保留所有权利。

cl: 命令行 warning D9035 :“o”选项已否决,并将在将来的版本中移除
cl -link -EXPORT:?_OptionsStorage@?1??__local_stdio_printf_options@@9@9,DATA
   -link -EXPORT:libcharset_set_relocation_prefix
   -link -EXPORT:locale_charset

cl: 命令行 warning D9002 :忽略未知选项“-g”
Microsoft (R) Incremental Linker Version 14.29.30152.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:localcharset.exe
/out:.libs\charset-1.dll
-EXPORT:?_OptionsStorage@?1??__local_stdio_printf_options@@9@9,DATA
-EXPORT:libcharset_set_relocation_prefix
-EXPORT:locale_charset
.libs/localcharset.obj
.libs/relocatable-stub.obj
  正在创建库 .libs\charset-1.lib 和对象 .libs\charset-1.exp
LINK : fatal error LNK1561: 必须定义入口点
//must to define the entry point
make: *** [Makefile:55: libcharset.la] Error 2

Run complier again with modified parameter, it returned no error but can't open a file
cl.exe .libs/localcharset.obj .libs/relocatable-stub.obj  /WL /link /out:test.dll "@.libs\\charset-1.dll.exp" /DLL /IMPLIB:".libs\\charset.dll.lib"
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30152 版
版权所有(C) Microsoft Corporation。保留所有权利。

Microsoft (R) Incremental Linker Version 14.29.30152.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:localcharset.exe
/out:test.dll
@.libs\\charset-1.dll.exp
/DLL
/IMPLIB:.libs\\charset.dll.lib
.libs/localcharset.obj
.libs/relocatable-stub.obj
LINK : fatal error LNK1181: 无法打开输入文件“@.libs\\charset-1.dll.exp”

It look like caused the command in below is invalid
dumpbin -symbols -headers  .libs/localcharset.obj .libs/relocatable-stub.obj    | gawk '     {last_section=section; section=$ 3};     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};     /^ *Symbol name *: /{split($ 0,sn,":"); si=substr(sn[2],2)};     /^ *Type *: code/{print "T",si,substr(si,length(prfx))};     /^ *Type *: data/{print "I",si,substr(si,length(prfx))};     $ 0!~/External *\|/{next};     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};     {if(hide[section]) next};     {f="D"}; $ 0~/\(\).*\|/{f="T"};     {split($ 0,a,/\||\r/); split(a[2],s)};     s[1]~/^[@?]/{print f,s[1],s[1]; next};     s[1]~prfx {split(s[1],t,"@"); print f,t[1],substr(t[1],length(prfx))}     ' prfx=^ | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/' | /usr/bin/sed -e '/^[AITW][ ]/s/.*[ ]//' | sort | uniq > .libs/charset.explibtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[  ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([     ].*\)*$/DEF/p' -e q .libs/charset.exp`" ; then cp ".libs/charset.exp" ".libs/charset-1.dll.def"; echo ".libs\\charset-1.dll.def" > ".libs/charset-1.dll.exp"; else /usr/bin/sed -e 's/^/-link -EXPORT:/' < .libs/charset.exp > .libs/charset-1.dll.exp; filibtool: link:  cl.exe -o .libs\\charset-1.dll  .libs/localcharset.obj .libs/relocatable-stub.obj    -g    "@.libs\\charset-1.dll.exp" -DLL,-IMPLIB:".libs\\charset.dll.lib"

I'm using GNU Awk 5.1.1, API: 3.1 (GNU MPFR 4.1.0-p13, GNU MP 6.2.1)
on msys

I saved the output of dumpbin
https://pastebin.com/1xqXF86b

I find there are character escape problem.
On msys shell it shows "-bash: syntax error near unexpected token `then'"
But after using vc init script it entered to cmd.
The error become "'/{next}' is not recognized as an internal or external command,
operable program or batch file

I'm not sure where the problem is , but in "make" command the gawk never through error.
Maybe this is caused by my copy paste?
And the content of dumpbin it created is such few 3 lines
charset.exp
?_OptionsStorage@?1??__local_stdio_printf_options@@9@9,DATA
libcharset_set_relocation_prefix
locale_charset

cl.exe .libs/localcharset.obj .libs/relocatable-stub.obj  /WL /link /out:test.dll /DLL
It pass

previous problem is caused by a "@" in path
"@.libs\\charset-1.dll.exp"

using cl.exe .libs/localcharset.obj .libs/relocatable-stub.obj  /WL /link /out:test.dll ".libs\\charset-1.dll.exp" /DLL /IMPLIB:".libs\\charset.dll.lib"
will return the charset-1.dll.exp is corrupt. Can't read from 0x96

content of charset-1.dll.exp is 
-link -EXPORT:?_OptionsStorage@?1??__local_stdio_printf_options@@9@9,DATA
-link -EXPORT:libcharset_set_relocation_prefix
-link -EXPORT:locale_charset

Well my head is not clear. I'm going to sleep.

Conclusion: A symbol "@" in cl.exe parameter caused fatal error and the exp file looks wrong. 
I'm not sure what this exp is. 
Maybe my modify is wrong. I know nothing about how to use export file with cl.exe
You can see without the exp file the cl works fine.
What is the mean of that command? Is it linked two obj(binary) file together using an export table?
--------------------------------------------------------------------------------------
I think better add a msvc checker and use it as condition to set correct parameter.
It's easy, run cl.exe and filter the text "microsoft"
Or check the variable VCToolsVersion

When using msvc, you can just use cl.exe /I include_dir $input.lib $input.c  /link $linkopts /libpath:$libs /out:$name.dll
Anything past the /link is the options for linker.
The /link will automatically use link.exe with settings $linkopts
/link /DLL will create dll file. 
cl.exe /LD will automatically add the /DLL option for linker

The -o for msvc should updated to /out:$name
//There must not be 'space' after the ":" symbol.
e.g. /out:123.output is fine, but /out: 123.output is wrong.
I think add a script to check the version of cl.exe and use new parameter should be safe.


reference
https://learn.microsoft.com/en-us/cpp/build/reference/wl-enable-one-line-diagnostics?view=msvc-160
//Appends additional information to an error or warning message.

https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-alphabetically?view=msvc-160
//All Parameters for MSVC

https://learn.microsoft.com/en-us/cpp/build/reference/linker-options?view=msvc-160
//Linker options

reply via email to

[Prev in Thread] Current Thread [Next in Thread]