Skip to content

Fill in missing build flags for core/sys/windows package #5066

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ekliot
Copy link

@ekliot ekliot commented Apr 22, 2025

These files are triggering compilation errors on my Linux machine, which are fixed with these build flags.

Thanks for reviewing.

EDIT: For context, the errors I'm trying to solve, specifically building obj for js_wasm32:

$ odin build src -build-mode:obj -target:js_wasm32 ...
/path/to/odin/core/sys/windows/ole32.odin(3:1) Error: File name, '_', cannot be as a library name as it is not a valid identifier
	foreign import "system:Ole32.lib"
	^

/path/to/odin/core/sys/windows/ole32.odin(42:9) Error: Undeclared name: Ole32
	foreign Ole32 {
	        ^~~~^

ekliot added 2 commits April 22, 2025 01:02
add #+build windows
add #+build windows
@ekliot
Copy link
Author

ekliot commented Apr 22, 2025

Hmm, I see builds are failing on D3D examples, since they import dxgi which imports win32 types... let me do some more investigation, my build failures occur specifically when compiling js_wasm32 on Linux.
I'll narrow down which dependencies the wasm build uses which might be erroneously importing core:sys/windows when building on linux.

Here's all the dist packages that the build depends upon:

``` $ odin build src -build-mode:obj -target:js_wasm32 ... -export-dependencies:json -export-dependencies-file:dep.json $ cat dep.json | grep ".odin" | ... | sort | uniq base/runtime core/bufio core/bytes core/c core/compress core/compress/zlib core/encoding/ansi core/encoding/json core/fmt core/hash core/image core/image/png core/io core/log core/math/bits core/math/linalg core/math core/mem core/os core/reflect core/simd core/slice core/strconv/decimal core/strconv core/strings core/sync core/time/datetime core/time core/unicode core/unicode/utf16 core/unicode/utf8 vendor/box2d vendor/box2d/lib vendor/box2d vendor/sdl2 vendor/vulkan vendor/x11/xlib ```

And, diff'd from Linux executable build:

``` $ diff LIN_DEP_PACKAGES WEB_DEP_PACKAGES -y base/runtime base/runtime core/bufio core/bufio core/bytes core/bytes core/c core/c core/c/libc < core/compress core/compress core/compress/zlib core/compress/zlib core/container/queue < core/dynlib < core/encoding/ansi core/encoding/ansi core/encoding/base64 < core/encoding/json core/encoding/json core/fmt core/fmt core/hash core/hash core/image core/image core/image/png core/image/png core/io core/io core/log core/log core/math/bits core/math/bits core/math/linalg core/math/linalg core/math core/math core/math/rand < core/mem core/mem core/os core/os core/os/os2 < core/os < core/path/filepath < core/prof/spall < core/reflect core/reflect core/simd core/simd core/slice core/slice core/strconv/decimal core/strconv/decimal core/strconv core/strconv core/strings core/strings core/sync core/sync core/sync/chan < core/sync < core/sys/linux < core/sys/posix < core/sys/unix < core/sys/valgrind < core/testing < core/thread < core/time/datetime core/time/datetime core/time core/time core/unicode core/unicode core/unicode/utf16 core/unicode/utf16 core/unicode/utf8 core/unicode/utf8 vendor/box2d vendor/box2d vendor/box2d/lib vendor/box2d/lib vendor/box2d vendor/box2d vendor/sdl2 vendor/sdl2 vendor/vulkan vendor/vulkan vendor/x11/xlib vendor/x11/xlib ```

(apparently code blocks don't work in <details>?)

Actually, I'm realizing that I can only export the web build dependencies if the build doesn't fail, so the exported list probably doesn't have the offender in it since I can only succeed building with this PR's patch... d'oh

Here are the files that:

  • `import "core:sys/windows"
  • do not have a #+build tag or end in _windows.odin
tests/core/os/os.odin
vendor/directx/d3d11/d3d11.odin
vendor/vulkan/_gen/create_vulkan_odin_wrapper.py
vendor/directx/d3d12/d3d12.odin
vendor/directx/dxgi/dxgi.odin
vendor/directx/dxgi/dxgidebug.odin
vendor/vulkan/structs.odin
vendor/sdl3/sdl3_system.odin

I think it's likely the vulkan import? Which is getting imported by sdl2...

One fix for this may be to split vendor/vulkan/structs.odin into vendor/vulkan/structs_windows.odin etc., I'll investigate this later today.

@ekliot
Copy link
Author

ekliot commented Apr 22, 2025

Okay, so I've sourced my real issue: vendor/vulkan/structs.odin

I copied it into vendor/vulkan/structs_windows.odin, then removed win32 and such from structs.odin, and added a #+build !windows tag to the file.

My wasm build went normally, without this PR's patch (so, the only changes to the source tree was structs.odin.

However, that file is autogenerated, so hacking this seems unwise. Please advise.

I'm also uncertain why I don't get these build errors when building the Linux executable, and only the wasm obj, even though vulkan ends up in both of their dependency lists.

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

Successfully merging this pull request may close these issues.

1 participant