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

Cross-compiling from Linux to Windows #380

Closed
John-Nagle opened this issue Mar 11, 2022 · 8 comments
Closed

Cross-compiling from Linux to Windows #380

John-Nagle opened this issue Mar 11, 2022 · 8 comments

Comments

@John-Nagle
Copy link
Contributor

John-Nagle commented Mar 11, 2022

It almost works. But not quite.

Tried to build Rend3 on Linux with Windows target "i686-pc-windows-gnu". This fails because Tracy won't build.
Rust Tracy dev blames upstream C++ Tracy project and MinGW C++ environment. See

nagisa/rust_tracy_client#31

This isn't really a Rend3 problem. But perhaps Tracy inclusion in the project could be tied to a "tracy" feature gate.
I use this in my own code:

[features]
#   Feature "tracy" enables profiing with Tracy
tracy = ["tracy-client", "profiling/profile-with-tracy", "slscene/tracy"]

With a "tracy" feature gate I can better debug and report cross-compile problems.

When I compile my own application, with the "tracy" feature gate off, I get all the way to linking, and then fail.
The missing symbol needed is _Unwind_Resume, which is part of the C++ exception system.

This came up in some other Rust context at: rust-lang/rust#77394

This is probably a "need to install some library"/"missing dependency" problem. I'm using the current release Rust on Ubuntu 20.04 LTS, so in theory I'm current.

(I don't use Windows much and have only an old Windows 7 machine without MSVC.)

Attached entire compile.
crosscompilelinkfail.txt

@John-Nagle
Copy link
Contributor Author

The _Unwind_Resume problem is known, but not fixed. It's not Rend3. See

rust-lang/rust#79489

@cwfitzgerald
Copy link
Member

Tracy is already feature gated: https://github.com/BVE-Reborn/rend3/blob/trunk/examples/scene-viewer/Cargo.toml#L27-L28

Unfortunately I don't know much about cross compiling, I always use native builds through CI, so I'm not going to be much help here.

@John-Nagle
Copy link
Contributor Author

Thanks. The undefined symbol isn't a Rend3 problem, anyway.

Where do I turn the feature off? It's apparently on by default if I just build "rend3" with its examples.

@John-Nagle
Copy link
Contributor Author

John-Nagle commented Mar 12, 2022

Sorry, version problem. With the current Github Rend3, "tracy" is not loaded by default. So, past that problem.

@cwfitzgerald
Copy link
Member

Great!

Going to close as the rest of this seems outside of rend3's jurisdiction

@John-Nagle
Copy link
Contributor Author

John-Nagle commented Mar 13, 2022

It's not a Rend3 problem. Now that I have it working, though, here's what's required:

I've been able to run most of the Rend3 tests and my own application, cross-compiled from Linux to Windows and then run under Wine.

Notes:

  • cargo build --target x86_64-pc-windows-gnu --examples --release

  • Needs Wine 7.0 to run Rend3/WGPU. Wine 5.0, which ships with Ubuntu 20.04 LTS, has incompatibilities around GPU memory types, and WGPU startup can't find a supported GPU memory type.

  • Needs these files copied to the executable directory for more complex Rend3 applications:

/usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/libgcc_s_seh-1.dll
/usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/libstdc++-6.dll

Rust is supposed to statically link the standard C++ libraries, but it doesn't for some C++ dependencies. Ref: Rust issue #67408

Sample output:
firstwinerender

@John-Nagle
Copy link
Contributor Author

Fixed dependency issue. I was still pulling in the deprecated "basis" package, which pulls in those DLLs. After revising my code to load the skybox without using "basis", the Windows executable ran under Wine 7.0 with no need to provide extra DLLs.

So Rend3 now cross-compiles nicely.

@cwfitzgerald
Copy link
Member

Great to hear!

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

No branches or pull requests

2 participants