Support 32-bit Windows, Compilation Error: unknown target CPU 'pentium4'
Describe the bug
I tried using zig as the cgo compiler, and it has a good cross-compilation feature. However, when I compile the cogentcore project using this method, the following compilation error occurs :
C:\Users\PC\Desktop\aa>core.exe build
go build -ldflags -s -w -X cogentcore.org/core/system.CoreVersion=v0.3.3 -o C:\Users\PC\Desktop\aa\Aa.exe
# runtime/cgo
error: unknown target CPU 'pentium4'
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, clearwaterforest, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, x86-64, x86-64-v2, x86-64-v3, x86-64-v4
cogentcore build failed: build: error building for platform windows/amd64: failed to run "go build -ldflags -s -w -X cogentcore.org/core/system.CoreVersion=v0.3.3 -o C:\Users\PC\Desktop\aa\Aa.exe: exit status 1"
How to reproduce
- Set
go env -w GOARCH=386
go env -w CC="zig cc -target x86-windows"
go env -w CGO_ENABLED=1
- Execute the build command
- Observe the error output
Additional Information: Go version: 1.23 Zig version: 0.13.0 Operating System: Windows 10
Example code
No response
Relevant output
No response
Platform
Windows
Thank you for reporting this. Can you try running go build instead of core build and see if that works? It would be helpful to know whether the issue is with our build tool, which adds extra linker flags for optimization.
I tried it and it still can't compile normally. There are many error messages, but the errors all include "lld-link: error: undefined symbol: _wgpu...", which may be related to webgpu
Thank you for the information. It looks like we currently only have the WebGPU object files for 64-bit Windows; can you try it for that first to make sure that the general zig approach works? Do you need support for 32-bit Windows? (We support 32-bit Android since it is still more common there).
I tried to compile the 64-bit version by default, but go build still reported an error, saying "…………lld-link: error: duplicate symbol: _chkstk_ms". If you have time, you can test it yourself, which should be clearer than what I described.
I do need support for 32-bit Windows, if possible, please add support for it.
Okay, we will test it on our test Windows device soon and try to fix. We will also look into adding 32-bit Windows support; it definitely should be possible.
Hello, Development Team. Does the latest version still not support 32-bit Windows? Could we escalate the priority?
@gtnttot i guess you have the wgpu compiled for windows 32 bit.
i do not have that one, but in general you might use following steps to build the demo successfully:
- you must use the
zig 0.14from nightly builds or themasterbranch, the... _chkstk_mserror is still inv0.13 go install cogentcore.org/core/cmd/core@maincore setupgo env -w CGO_ENABLED=1(by default this option is turned off on WIndows 10)go env -w CC="C:\zig0.14\zig cc"go env -w CXX="C:\zig0.14\zig c++"go env -w CGO_LDFLAGS="-O2 -g -lunwind"(this is important, on Windows 10 64 bit we must add-lunwind)go run cogentcore.org/core/examples/demo@main
Environment:
- Go: go1.23.5 windows/amd64
- Zig: 0.14.0-dev.2851+b074fb7dd
- Windows 10 (22H2) 64 bit
@gtnttot you should have the Go and git executables somehow added to the PATH env var, the Zig runs well from custom dir like C:\zig0.14.
@kkoreilly fun fact, the demo runs well in following env:
- Go: go1.23.5 windows/amd64
- Zig: 0.14.0-dev.2851+b074fb7dd
- Windows 10 (22H2) 64 bit
but it freezes forever if you try to open the Inspector.
@AnyCPU Thank you for providing those instructions!
@gtnttot Yes, we will add 32-bit Windows support as soon as possible. Thank you for the reminder.
you should have the Go and git executables somehow added to the PATH env var
core setup is supposed to do that, but we have some registry formatting issue as I mentioned in #1384. I will look into that now.
@kkoreilly i have noticed no issue with core setup, maybe because i have a lot of tools already installed, i just had to manually enable CGO. i work not so much on windows, i guess it is ok because of Go's defaults on windows.
@AnyCPU I merged #1459, so core setup should successfully install all of the proper executables for Git and gcc and add them to the PATH now. I will also document the need to set CGO_ENABLED=1 soon.
I will close this issue once we implement 32-bit Windows support. Thank you for your patience.