vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.8k stars 2.16k forks source link

Can't build correct 32 bit binary on 64 bit windows #7407

Closed iwzoo closed 3 years ago

iwzoo commented 3 years ago

V version: V 0.1.30 adaffd0 OS: Microsoft Windows [Version 10.0.19042.685] msvc 2017 (15.9.28)

What did you do? v -cflags "-m32" build hello.v

What did you expect to see? PE header magic value "010B (PE32)"

What did you see instead? Got PE magic header value "020B (PE32 + PE64)"

iwzoo commented 3 years ago

After making some changes on v_win.c (based on commit 19bfd5f), it works now with -m32 properly .

6406c6406
< VV_LOCAL_SYMBOL Option_v__builder__MsvcResult v__builder__find_msvc(v__pref__Preferences* pref);
---
> VV_LOCAL_SYMBOL Option_v__builder__MsvcResult v__builder__find_msvc();
47759c47759
<       Option_v__builder__MsvcResult _t1846 = v__builder__find_msvc(pref);
---
>       Option_v__builder__MsvcResult _t1846 = v__builder__find_msvc();
48199c48199
<               Option_v__builder__MsvcResult _t1897 = v__builder__find_msvc(v->pref);
---
>               Option_v__builder__MsvcResult _t1897 = v__builder__find_msvc();
49511c49511
< VV_LOCAL_SYMBOL Option_v__builder__MsvcResult v__builder__find_msvc(v__pref__Preferences* pref) {
---
> VV_LOCAL_SYMBOL Option_v__builder__MsvcResult v__builder__find_msvc() {
49516c49516
<               string host_arch = (string_eq(processor_architecture, _SLIT("x86")) ? (_SLIT("X86")) : (pref->m64?(_SLIT("X64")):(_SLIT("X86"))));
---
>               string host_arch = (string_eq(processor_architecture, _SLIT("x86")) ? (_SLIT("X86")) : (_SLIT("X64")));
JalonSolov commented 3 years ago

Reopening, because this looks like something that should be fixed.

Ekopalypse commented 3 years ago

Seems this has been fixed.

D:\temp\v>dumpbin /headers v.exe | findstr /C:"machine"
            8664 machine (x64)

D:\temp\v>v -cflags "-m32" self
V self compiling (-cflags -m32 -o v2)...
V built successfully!

D:\temp\v>dumpbin /headers v.exe | findstr /C:"machine"
             14C machine (x86)
                   32 bit word machine

D:\temp\v>v  self
V self compiling ...
V built successfully!

D:\temp\v>dumpbin /headers v.exe | findstr /C:"machine"
            8664 machine (x64)