-
Notifications
You must be signed in to change notification settings - Fork 42
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 Golang static lib along with Rust using MSVC runtime on Linux #138
Comments
As a side note, it might not be even possible to use MSVC to build the Golang archive. Not really sure, but I've found this StackOverflow answer and a repo using MSVC with MinGW-generated Go archive to link C code. Not sure, how I can translate the magic code to Rust either. |
And this is the simplest Go CGO code to reproduce the issue: package main
import (
"C"
)
//export Add
func Add(a C.int, b C.int) C.int {
return C.int(internal_add(int(a), int(b)))
}
func internal_add(a int, b int) int {
return a + b
} |
https://github.com/trcrsired/windows-msvc-sysroot what about trying this? I am maintaining the headers myself since these headers need more tweaks rather than "just downloading files from microsoft". This xwin is terrible project since rust folks have no idea how compilers work in general |
Thanks! I'll bookmark it to check out later. |
Thank you very much for the awesome project and your blog post about it.
I'm using rust-cross/cargo-xwin to build the Rust portion of the code which works fine. Then I try to build a Go library which my Rust code relies on using FFI, so ideally, I would like to build the Go code with the same toolchain.
Since Go by default relies on MinGW and not MSVC toolchain to produce the archive file, I decided to go using Zig CC. This is how it's invoked:
The errors I get:
Unfortunately, I was not able to go further, even reordering the included paths seems not to work.
The text was updated successfully, but these errors were encountered: