Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VC++ broken in devel: module machine type 'X86' conflicts with target machine type 'x64' #11306

Closed
treeform opened this issue May 22, 2019 · 8 comments

Comments

Projects
None yet
5 participants
@treeform
Copy link
Contributor

commented May 22, 2019

My command line:

nim cpp --cc:vcc helloworld.nim

My file:

echo "Hello World"

I tested:

  • 0.19.0 - works
  • 0.19.2 - works
  • 0.19.4 - works
  • 0.19.6 - works
  • 0.19.9 (devel) - broken!

Broken output:

Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

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

/out:C:\Users\me\Dropbox\p\istrolid2\helloworld.exe
C:\Users\me\nimcache\helloworld_d\stdlib_io.cpp.obj
C:\Users\me\nimcache\helloworld_d\stdlib_system.cpp.obj
C:\Users\me\nimcache\helloworld_d\helloworld.cpp.obj
LIBCMT.lib(std_type_info_static.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

Working output:

"C:\WINDOWS\system32\cmd.exe" /C ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall" amd64 && SET"
cl.exe /nologo /DEBUG /Zi /F33554432 /FeC:\Users\me\Dropbox\p\istrolid2\helloworld.exe C:\Users\me\nimcache\helloworld_d\helloworld.cpp.obj C:\Users\me\nimcache\helloworld_d\stdlib_system.cpp.obj

Is vcvarsall with amd64 is not being called any more?

Hey, @nc-x and @demotomohiro you guys looked at this previously, could you help me out?

@treeform

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

Sorry for pining wrong people, turns out it was this: https://github.com/nim-lang/Nim/pull/11003/files

Revering it fixes the issue. @cooldome can you help me out? I don't know what any of those arguments do.

@demotomohiro

This comment has been minimized.

Copy link
Contributor

commented May 22, 2019

I tested following test code with devel Nim and vcc backend.
.c and .cpp files are built with --platform:amd64 /nologo options.
When nim call vcc linker, vccexe.exe is called without --platform:amd64 /nologo option and looks like linker for X86 CPU is called.

test.nim:

echo "foo"

Build log:

f:\temp>f:\project\nim-lang\Nim\bin\nim.exe c -r --cc:vcc --listcmd test.nim
Hint: used config file 'f:\project\nim-lang\Nim\config\nim.cfg' [Conf]
Hint: used config file 'C:\Users\root\AppData\Roaming\nim\nim.cfg' [Conf]
Hint: used config file 'f:\temp\nim.cfg' [Conf]
Hint: used config file 'f:\project\nim-lang\Nim\config\config.nims' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: test [Processing]
vccexe.exe /c /nologo --platform:amd64  /If:\project\nim-lang\Nim\lib /If:\temp /Fof:\temp\nimcache\test\debug\stdlib_io.c.o
bj f:\temp\nimcache\test\debug\stdlib_io.c
vccexe.exe /c /nologo --platform:amd64  /If:\project\nim-lang\Nim\lib /If:\temp /Fof:\temp\nimcache\test\debug\stdlib_system
.c.obj f:\temp\nimcache\test\debug\stdlib_system.c
vccexe.exe /c /nologo --platform:amd64  /If:\project\nim-lang\Nim\lib /If:\temp /Fof:\temp\nimcache\test\debug\test.c.obj f:
\temp\nimcache\test\debug\test.c
Hint: vccexe.exe      /Fef:\temp\test.exe  f:\temp\nimcache\test\debug\stdlib_io.c.obj f:\temp\nimcache\test\debug\stdlib_sy
stem.c.obj f:\temp\nimcache\test\debug\test.c.obj  [Exec]
Microsoft(R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

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

/out:f:\temp\test.exe
f:\temp\nimcache\test\debug\stdlib_io.c.obj
f:\temp\nimcache\test\debug\stdlib_system.c.obj
f:\temp\nimcache\test\debug\test.c.obj
stdlib_io.c.obj : error LNK2019: 未解決の外部シンボル _setmode が関数 stdlib_ioInit000 で参照されました。
OLDNAMES.lib(setmode.obj) : error LNK2001: 外部シンボル "_setmode" は未解決です。
stdlib_io.c.obj : error LNK2019: 未解決の外部シンボル __acrt_iob_func が関数 echoBinSafe で参照されました。
stdlib_system.c.obj : error LNK2001: 外部シンボル "__acrt_iob_func" は未解決です。
stdlib_io.c.obj : error LNK2019: 未解決の外部シンボル fflush が関数 echoBinSafe で参照されました。
stdlib_io.c.obj : error LNK2019: 未解決の外部シンボル _fileno が関数 stdlib_ioInit000 で参照されました。
OLDNAMES.lib(fileno.obj) : error LNK2001: 外部シンボル "_fileno" は未解決です。
stdlib_io.c.obj : error LNK2019: 未解決の外部シンボル fwrite が関数 echoBinSafe で参照されました。
stdlib_system.c.obj : error LNK2001: 外部シンボル "fwrite" は未解決です。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル memcpy が関数 nimCopyMem で参照されました。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル memset が関数 nimSetMem_zxfKBYntu9cBapkhrCOk1fgmemory で参照されま
した。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル strlen が関数 nimCStrLen で参照されました。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル longjmp が関数 raiseExceptionAux_na8C8pUZ9cLQWVwk35l5vfw で参照さ
れました。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル __imp_VirtualAlloc が関数 osAllocPages_HMOhWrY1QMa49a2BcJwSDZQsyst
em で参照されました。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル __imp_VirtualFree が関数 osDeallocPages_dRMEutPSAkbR9b9blNmTzvoQsy
stem で参照されました

stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル exit が関数 raiseOutOfMem_mMRdr4sgmnykA9aWeM9aDZlw_2 で参照されま
した。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル __stdio_common_vfprintf が関数 _vfprintf_l で参照されました。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル signal が関数 registerSignalHandler_amVlU9ajqZ06ujoesRBHcDg_3 で参
照されました。
stdlib_system.c.obj : error LNK2001: 外部シンボル "__GSHandlerCheck" は未解決です。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル __security_check_cookie が関数 markStackAndRegisters_U6T7JWtDLrWht
mhXSoy9a6g で参
照されました。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル _setjmp が関数 markStackAndRegisters_U6T7JWtDLrWhtmhXSoy9a6g で参
照されました。
LIBCMT.lib(setjmp.obj) : error LNK2001: 外部シンボル "_setjmp" は未解決です。
stdlib_system.c.obj : error LNK2019: 未解決の外部シンボル __security_cookie が関数 markStackAndRegisters_U6T7JWtDLrWhtmhXSoy
9a6g で参照されました

stdlib_system.c.obj : error LNK2001: 外部シンボル "_fltused" は未解決です。
LINK : error LNK2001: 外部シンボル "mainCRTStartup" は未解決です。
LIBCMT.lib(setjmp.obj) : error LNK2001: 外部シンボル "___intrinsic_setjmp" は未解決です。
OLDNAMES.lib(setmode.obj) : error LNK2001: 外部シンボル "__setmode" は未解決です。
OLDNAMES.lib(fileno.obj) : error LNK2001: 外部シンボル "__fileno" は未解決です。
C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib : warning LNK4272: ライブラリのコンピューターの種類 'X86
' がターゲットのコンピューター
の種類' x64' と競合しています
f:\temp\test.exe : fatal error LNK1120: 23 件の未解決の外部参照
Error: execution of an external program failed: 'vccexe.exe      /Fef:\temp\test.exe  f:\temp\nimcache\test\debug\stdlib_io.
c.obj f:\temp\nimcache\test\debug\stdlib_system.c.obj f:\temp\nimcache\test\debug\test.c.obj '

f:\temp>f:\project\nim-lang\Nim\bin\nim.exe cpp -r --cc:vcc --listcmd test.nim
Hint: used config file 'f:\project\nim-lang\Nim\config\nim.cfg' [Conf]
Hint: used config file 'C:\Users\root\AppData\Roaming\nim\nim.cfg' [Conf]
Hint: used config file 'f:\temp\nim.cfg' [Conf]
Hint: used config file 'f:\project\nim-lang\Nim\config\config.nims' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: test [Processing]
vccexe.exe /c /nologo --platform:amd64 /EHsc  /If:\project\nim-lang\Nim\lib /If:\temp /Fof:\temp\nimcache\test\debug\stdlib_
io.cpp.obj f:\temp\nimcache\test\debug\stdlib_io.cpp
vccexe.exe /c /nologo --platform:amd64 /EHsc  /If:\project\nim-lang\Nim\lib /If:\temp /Fof:\temp\nimcache\test\debug\stdlib_
system.cpp.obj f:\temp\nimcache\test\debug\stdlib_system.cpp
vccexe.exe /c /nologo --platform:amd64 /EHsc  /If:\project\nim-lang\Nim\lib /If:\temp /Fof:\temp\nimcache\test\debug\test.cp
p.obj f:\temp\nimcache\test\debug\test.cpp
Hint: vccexe.exe      /Fef:\temp\test.exe  f:\temp\nimcache\test\debug\stdlib_io.cpp.obj f:\temp\nimcache\test\debug\stdlib_
system.cpp.obj f:\temp\nimcache\test\debug\test.cpp.obj  [Exec]
Microsoft(R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

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

/out:f:\temp\test.exe
f:\temp\nimcache\test\debug\stdlib_io.cpp.obj
f:\temp\nimcache\test\debug\stdlib_system.cpp.obj
f:\temp\nimcache\test\debug\test.cpp.obj
LIBCMT.lib(std_type_info_static.obj) : fatal error LNK1112: モジュールのコンピューターの種類 'X86' は対象コンピューターの種
類 'x64' と競合しています。
Error: execution of an external program failed: 'vccexe.exe      /Fef:\temp\test.exe  f:\temp\nimcache\test\debug\stdlib_io.
cpp.obj f:\temp\nimcache\test\debug\stdlib_system.cpp.obj f:\temp\nimcache\test\debug\test.cpp.obj '

Creating following nim.cfg fix these errors.
nim.cfg:

amd64.windows.vcc.options.linker = "--platform:amd64 /nologo"
amd64.windows.vcc.cpp.options.linker = "--platform:amd64 /nologo"
vcc.options.linker %= "${amd64.windows.vcc.options.linker}"
vcc.cpp.options.linker %= "${amd64.windows.vcc.cpp.options.linker}"

*.vcc.options.linker and *.vcc.cpp.options.linker are need to be set in nim.cfg.

@treeform

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

Thank you for figuring it out!

@cooldome

This comment has been minimized.

Copy link
Member

commented May 23, 2019

I will have a look. Please avoid using %= operator in the fix, it makes overrides in user config files problematic.

@cooldome

This comment has been minimized.

Copy link
Member

commented May 23, 2019

@Araq,
Not sure it the right time to discuss this. We might just need a quick fix. But is it intentional that xx.options.always are not used to set linker options in setCC proc extccomp.nim?

@demotomohiro

This comment has been minimized.

Copy link
Contributor

commented May 23, 2019

I will have a look. Please avoid using %= operator in the fix, it makes overrides in user config files problematic.

Adding following code to nim/config/nim.cfg worked for me.
I tested it with/without --cpu:i386 option.
But there are many %= operators.

#Local variable to set common options. Not referenced by Nim compiler.
vcc.linker.common = "/nologo /F33554432" # set the stack size to 32 MiB
@if not release:
  vcc.linker.common %= "${vcc.linker.common} /DEBUG /Zi"
@end

i386.windows.vcc.options.linker %= "--platform:x86 ${vcc.linker.common}"
i386.windows.vcc.cpp.options.linker %= "${i386.windows.vcc.options.linker}"
amd64.windows.vcc.options.linker %= "--platform:amd64 ${vcc.linker.common}"
amd64.windows.vcc.cpp.options.linker %= "${amd64.windows.vcc.options.linker}"
arm.windows.vcc.options.always %= "--platform:arm ${vcc.linker.common}"
arm.windows.vcc.cpp.options.always %= "${arm.windows.vcc.options.always}"
@if i386:
  vcc.options.linker %= "${i386.windows.vcc.options.linker}"
  vcc.cpp.options.linker %= "${i386.windows.vcc.cpp.options.linker}"
@elif amd64:
  vcc.options.linker %= "${amd64.windows.vcc.options.linker}"
  vcc.cpp.options.linker %= "${amd64.windows.vcc.cpp.options.linker}"
@elif arm:
  vcc.options.linker %= "${arm.windows.vcc.options.always}"
  vcc.cpp.options.linker %= "${arm.windows.vcc.cpp.options.always}"
@end

I set vcc.options.linker in nim/config/nim.cfg with %= operator but I can override it in user cfg file with both = and %= operators.
If there were vcc.options.linker %= "${amd64.windows.vcc.options.linker}" in nim/config/nim.cfg, I can change amd64.windows.vcc.options.linker in user cfg but that doesn't change vcc.options.linker.
Is that the problem you are talking?

@demotomohiro

This comment has been minimized.

Copy link
Contributor

commented May 23, 2019

@cooldome
You added a following line in PR #11003, but the value of vcc.options.linker.always doesn't appear in command line and it seems .options.linker.always is not used in extccomp.nim.

vcc.options.linker.always = "/F33554432" # set the stack size to 32 MiB
@Araq

This comment has been minimized.

Copy link
Member

commented May 23, 2019

Not sure it the right time to discuss this. We might just need a quick fix. But is it intentional that xx.options.always are not used to set linker options in setCC proc extccomp.nim?

I don't really know but "always" options for the compiler are not options for the linking step.

@Araq Araq closed this in d67a9f0 May 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.