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

x86 build does not produce valid Win32 (XP) application #5287

Closed
ArgoreOfficial opened this issue Jul 1, 2024 · 4 comments
Closed

x86 build does not produce valid Win32 (XP) application #5287

ArgoreOfficial opened this issue Jul 1, 2024 · 4 comments
Labels

Comments

@ArgoreOfficial
Copy link

Xmake Version

2.9.3

Operating System Version and Architecture

Windows 10, XP Pro

Describe Bug

building a basic "Hello World" program using -a x86 does not create a valid 32-bit application
runs fine on my x64 machine, but will not launch in a Windows XP Pro virtual machine

I have tried both MSVC and clang, neither create a valid application

Expected Behavior

targetting x86/32bit should create a valid 32-bit application

Project Configuration

xmake.lua

target( "test" )
    set_kind( "binary" )
    add_files( "./main.cpp" )

main.cpp

#include <stdio.h>

int main()
{
    printf("Hello World XP\n");
    
    while(true){} // so the console doesn't disappear

    return 0;
}

build command
xmake f -p windows -a x86
xmake

Additional Information and Error Logs

checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x86\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
[ 50%]: compiling.release main.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX64\\x86\\cl.exe" -c -nologo /EHsc -Fobuild\.objs\test\windows\x86\release\main.cpp.obj main.cpp
checking for C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x86\cl.exe ... ok
checking for flags (cl_sourceDependencies) ... ok
> cl.exe "/sourceDependencies" "C:\Users\argore\AppData\Local\Temp\.xmake\240701\_2D1B1657C7084E008FCEAD95777D8D80.json" "-nologo"
[ 75%]: linking.release test.exe
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX64\\x86\\link.exe" -nologo -dynamicbase -nxcompat -machine:x86 -out:build\windows\x86\release\test.exe build\.objs\test\windows\x86\release\main.cpp.obj
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x86\cl.exe
checking for the c compiler (cc) ... cl.exe

build cache stats:
cache directory: build\.build_cache
cache hit rate: 0%
cache hit: 0
cache hit total time: 0.000s
cache miss: 0
cache miss total time: 0.000s
new cached files: 0
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0
compile total time: 0.000s

[100%]: build ok, spent 0.375s
@star-hengxing
Copy link
Contributor

https://learn.microsoft.com/en-us/cpp/build/configuring-programs-for-windows-xp?view=msvc-170

TL,DR: Windows XP programs require <= MSVC V141 toolset.

Other ways:

add_requires("yy-thunks")
add_packages("yy-thunks")

add_rules("@yy-thunks/xp")

@ArgoreOfficial
Copy link
Author

ohh I see
compiling using the i86-w64-mingw32 toolchain manually worked

is there a way to select which MSVC toolset version to use?

@star-hengxing
Copy link
Contributor

$ xmake f --vs_toolset=<version>

or

set_toolchains("msvc", {vs_toolset = ""})

@ArgoreOfficial
Copy link
Author

ended up going with mingw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants