mono / mono

Mono open source ECMA CLI, C# and .NET implementation.
https://www.mono-project.com
Other
10.99k stars 3.81k forks source link

Why does mkbundle not know for x86 ( 32 bit ) to cl.exe ( x86 ) and clang.exe ( x86 ) and mkbundle forgets to add zlib.lib if you use -z #6702

Open ghost opened 6 years ago

ghost commented 6 years ago

Steps to Reproduce

  1. Open x86 native Command Prompt from Visual Studio 2017.5 Community ( 15.5 ) mkbundle call only wrong x64 bit clang.exe and x64 cl.exe
  2. It compiles failed because mkbundle doesn't work for process with x86-clang and x86-cl
  3. Output is "failed"

Please fix mkbundle if mono works under architecture x86 ( not using x64 ) If I use x86 native Command prompt and it calls only clang.exe from x64 and cl.exe from x64.

I hate to edit manuell with gedit ( windows ) and clang.exe from x86 to prompt and and cl.exe from x86 prompt.

PS: Why do you forget to add "zlib.lib" in mkbundle.exe if you use "-z" Did you forget? Please check mkbundle.cs where is -z -> zlib.lib in cl.exe?

Using Mono: Mono from today github Mono x86, 5.11.0 without boehm ( I have compiled with Cygwin x64 )

Using OS: Only WIndows [ x ]

Thanks!

ghost commented 6 years ago

WHY DO YOU NOT ANSWER ME? DO YOU WANT LIE ME? I WAIT LONGER YOUR SOLUTION.

marek-safar commented 6 years ago

Could you share with us what arguments you are passing to mkbundle

ghost commented 6 years ago

Why do you mark "needs more info"?

Please check x86 Native Tools Command Prompt for Visual Studio 2015 Community. And change working directory if built executable ( net assembly ) example C:\mono_x86\lib\mono\4.5\mkbundle --static --keeptemp --deps -v -z Myapp.exe -o MyBundleApp.exe

After mkbundle's generator makes all embedding dlls and exe into temp.s and shows wrong architecture clang.exe from x64 like example

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\ClangC2\14.10.25903\bin**HostX64**\clang.exe" -c -x assembler -o temp.s.obj temp.s

That is wrong because mkbundle cannot generate to x86 bit executables.

I wish that mkbundle should know correct architecture "x86" not "x64"

And you have to forget to add in library zlib.lib if you use -z

mkbundle's output shows after generating temp.s than cl.exe throws error because cl was from x64 it is same wrong and forget to add zlib.lib if you use -z argument of mkbundle.

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\bin**HostX64\x64**\cl.exe" /MD /I "include\mono-2.0" /I "." "temp.c" "temp.s.obj" /link /SUBSYSTEM:windows /ENTRY:mainCRTStartup /NODEFAULTLIB libmono-static-sgen.lib kernel32.lib version.lib ws2_32.lib mswsock.lib psapi.lib shell32.lib oleaut32.lib ole32.lib winmm.lib user32.lib advapi32.lib ucrt.lib vcruntime.lib msvcrt.lib oldnames.lib /LIBPATH:"lib" /LIBPATH:"." /OUT:"MyBundleApp.exe"

You see where is zlib.lib if you use -z argument of mkbundle.

Thanks! It is not "need more info" - It is just "wrong compilation from x64" and "forget to add library"

I prove you my command prompt:

C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release>C:\mono_x86\lib\mono\4.5\mkbundle --static --keeptemp --deps -v GtkTest_x86.exe -o BundledApp.exe -z
OS is: Windows
Sources: 1 Auto-dependencies: True
Attempting to load assembly: GtkTest_x86.exe
Assembly GtkTest_x86.exe loaded successfully.
Attempting to load assembly from: .\I18N.West.dll
Attempting to load assembly from: .\I18N.dll
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\gtk-sharp
Attempting to load assembly from: .\glib-sharp
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System.Core
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\Mono.Security
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System
Attempting to load assembly from: .\System.Configuration
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System.Xml
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System
Attempting to load assembly from: .\System.Configuration
Attempting to load assembly from: .\System
Attempting to load assembly from: .\System.Security
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System
Attempting to load assembly from: .\Mono.Security
Attempting to load assembly from: .\System.Xml
Attempting to load assembly from: .\System.Numerics
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System.Xml
Attempting to load assembly from: .\Mono.Posix
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\gio-sharp
Attempting to load assembly from: .\glib-sharp
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System
Attempting to load assembly from: .\gdk-sharp
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\glib-sharp
Attempting to load assembly from: .\gio-sharp
Attempting to load assembly from: .\cairo-sharp
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\pango-sharp
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\glib-sharp
Attempting to load assembly from: .\cairo-sharp
Attempting to load assembly from: .\atk-sharp
Attempting to load assembly from: .\glib-sharp
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\cairo-sharp
Attempting to load assembly from: .\pango-sharp
Attempting to load assembly from: .\OpenGL.Net.GTK3
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System
Attempting to load assembly from: .\gtk-sharp
Attempting to load assembly from: .\glib-sharp
Attempting to load assembly from: .\OpenGL.Net
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\System.Xml
Attempting to load assembly from: .\System
Attempting to load assembly from: .\System.Core
Attempting to load assembly from: .\cairo-sharp
Attempting to load assembly from: .\gdk-sharp
Attempting to load assembly from: .\OpenGL.Net
Attempting to load assembly from: .\gdk-sharp
Attempting to load assembly from: .\System
Attempting to load assembly from: .\mscorlib
Attempting to load assembly from: .\I18N
Attempting to load assembly from: .\mscorlib
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\GtkTest_x86.exe
   compression ratio: 46,23%
 config from: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\GtkTest_x86.exe.config
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\mscorlib.dll
   compression ratio: 35,09%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\gtk-sharp.dll
   compression ratio: 27,62%
 config from: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\gtk-sharp.dll.config
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\glib-sharp.dll
   compression ratio: 40,08%
 config from: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\glib-sharp.dll.config
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\System.Core.dll
   compression ratio: 34,16%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\System.dll
   compression ratio: 36,80%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\Mono.Security.dll
   compression ratio: 41,27%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\System.Configuration.dll
   compression ratio: 40,68%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\System.Xml.dll
   compression ratio: 33,58%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\System.Security.dll
   compression ratio: 36,86%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\System.Numerics.dll
   compression ratio: 36,50%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\Mono.Posix.dll
   compression ratio: 40,64%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\gio-sharp.dll
   compression ratio: 27,72%
 config from: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\gio-sharp.dll.config
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\gdk-sharp.dll
   compression ratio: 31,33%
 config from: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\gdk-sharp.dll.config
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\cairo-sharp.dll
   compression ratio: 38,63%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\pango-sharp.dll
   compression ratio: 35,88%
 config from: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\pango-sharp.dll.config
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\atk-sharp.dll
   compression ratio: 30,80%
 config from: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\atk-sharp.dll.config
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\OpenGL.Net.GTK3.dll
   compression ratio: 45,38%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\OpenGL.Net.dll
   compression ratio: 23,72%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\I18N.West.dll
   compression ratio: 29,74%
   embedding: C:\Users\SSB\Documents\Visual Studio 2017\Projects\GtkTest\GtkTest_x86\bin\Release\I18N.dll
   compression ratio: 31,69%
AS =  (default)
VCINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\
VisualStudioVersion = 15.0
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\ClangC2\14.10.25903\bin\HostX64\clang.exe" -c -x assembler -o temp.s.obj temp.s
Compiling:
VCCRT = MD (default)
CC =  (default)
VCINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\
MONOPREFIX =  (default)
LIBMONO =  (default)
INCLUDE = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt;
MONOPREFIX =  (default)
VCSUBSYSTEM = windows (default)
LIBMONO =  (default)
LIB = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\ATLMFC\lib\x86;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib\x86;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x86;C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x86;C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86;
MONOPREFIX =  (default)
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\bin\HostX64\x64\cl.exe" /MD /I "include\mono-2.0" /I "." "temp.c" "temp.s.obj" /link /SUBSYSTEM:windows /ENTRY:mainCRTStartup /NODEFAULTLIB libmono-static-sgen.lib kernel32.lib version.lib ws2_32.lib mswsock.lib psapi.lib shell32.lib oleaut32.lib ole32.lib winmm.lib user32.lib advapi32.lib ucrt.lib vcruntime.lib msvcrt.lib oldnames.lib /LIBPATH:"lib" /LIBPATH:"." /OUT:"BundledApp.exe"
Microsoft (R) C/C++ Optimizing Compiler Version 19.12.25835 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

temp.c
Microsoft (R) Incremental Linker Version 14.12.25835.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:temp.exe
/SUBSYSTEM:windows
/ENTRY:mainCRTStartup
/NODEFAULTLIB
libmono-static-sgen.lib
kernel32.lib
version.lib
ws2_32.lib
mswsock.lib
psapi.lib
shell32.lib
oleaut32.lib
ole32.lib
winmm.lib
user32.lib
advapi32.lib
ucrt.lib
vcruntime.lib
msvcrt.lib
oldnames.lib
/LIBPATH:lib
/LIBPATH:.
/OUT:BundledApp.exe
temp.obj
temp.s.obj
LINK : error LNK2001: unresolved external symbol mainCRTStartup
temp.obj : error LNK2019: unresolved external symbol __imp_malloc referenced in function mono_mkbundle_init
temp.obj : error LNK2019: unresolved external symbol __imp_exit referenced in function mono_mkbundle_init
temp.obj : error LNK2019: unresolved external symbol __imp_getenv referenced in function count_mono_options_args
temp.obj : error LNK2019: unresolved external symbol __imp___acrt_iob_func referenced in function mono_mkbundle_init
temp.obj : error LNK2019: unresolved external symbol __imp___stdio_common_vfprintf referenced in function _vfprintf_l
temp.obj : error LNK2019: unresolved external symbol mono_register_bundled_assemblies referenced in function mono_mkbundle_init
temp.obj : error LNK2019: unresolved external symbol mono_register_config_for_assembly referenced in function install_dll_config_files
temp.obj : error LNK2019: unresolved external symbol mono_set_dirs referenced in function main
temp.obj : error LNK2019: unresolved external symbol memcpy referenced in function mono_mkbundle_init
temp.obj : error LNK2019: unresolved external symbol memset referenced in function my_inflate
temp.obj : error LNK2019: unresolved external symbol strchr referenced in function count_mono_options_args
temp.obj : error LNK2019: unresolved external symbol __imp_strdup referenced in function count_mono_options_args
temp.obj : error LNK2019: unresolved external symbol inflate referenced in function my_inflate
temp.obj : error LNK2019: unresolved external symbol inflateEnd referenced in function my_inflate
temp.obj : error LNK2019: unresolved external symbol inflateInit2_ referenced in function my_inflate
temp.obj : error LNK2019: unresolved external symbol mono_main referenced in function main
lib\libmono-static-sgen.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\kernel32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\version.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\ws2_32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\mswsock.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\psapi.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\shell32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\oleaut32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\ole32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\winmm.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\user32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86\advapi32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x86\ucrt.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib\x86\vcruntime.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib\x86\msvcrt.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
BundledApp.exe : fatal error LNK1120: 17 unresolved externals
ERROR: [Fail] 2

And I use x86 Native Tools Command Prompt for VS 2017 Community. mkbundle_completed_start_01

Why it sees wrong because x64 of compilation but mkbundle doesn't execute to x86 compilation. For x64 Native Tools Command Prompt for VS 2017 Community works with mkbundle fine = no problem.

Example if I have compiled myapp.exe with x64 bit and mkbundle knows for x64 Native = 100 % works fine. but for x86 nothing. Why does it happen? It need like I need edit temp.s with gedit and clang from x86 and cl from x86 with zlib.lib. It is really hard work if who has weak computer than somebody can't change if temp.s is large text - That is why it is ugly. Please fix correct architecture for x86. and do not forget to add zlib.lib if you use -z argument of mkbundle.

I hope you have to fix for next release.