Open
Description
Hi, I love rust and golang both!
Rust call golang by ffi.
windows11:
stable & beta & nightly:
error: linking with `link.exe` failed: exit code: 1120
libstd-d9ee307034db292c.rlib(std-d9ee307034db292c.std.e9da0a539f4e1ec4-cgu.0.rcgu.o) : warning LNK4078: multiple '.drectve' sections found with different attributes (00100A00)
libffi_go_print.lib(000005.o) : error LNK2019: unresolved external symbol fprintf referenced in function _cgo_beginthread
C:\Users\oligami\ffi-rust-go\target\debug\deps\ffi_rust_go.exe : fatal error LNK1120: 1 unresolved externals
wsl(ubuntu22):
stable & beta & nightly:
conplete
:print on rust
:print on golang
program end
alpine(docker):
stable & beta & nightly: segmentation fault on golang func
:print on rust
Segmentation fault
code on https://github.com/oligami-0424/ffi-rust-go
I tried this code:
package main
import (
"C"
)
//export ffi_go_print
func ffi_go_print() {
println(":print on golang")
}
extern "C" {
fn ffi_go_print();
}
fn main() {
println!(":print on rust");
unsafe { ffi_go_print() };
println!("program end");
}
fn main() {
cgo_oligami::Build::new()
.build_mode(cgo_oligami::BuildMode::CArchive)
.change_dir("./golib")
.package("main.go")
.build("ffi_go_print");
println!("cargo:rerun-if-changed=golib/main.go");
}
I expected to see this happen: success on all
Instead, this happened: success on only ubuntu
rustc --version --verbose
:
windows11
rustc 1.72.1 (d5c2e9c34 2023-09-13)
binary: rustc
commit-hash: d5c2e9c342b358556da91d61ed4133f6f50fc0c3
commit-date: 2023-09-13
host: x86_64-pc-windows-msvc
release: 1.72.1
LLVM version: 16.0.5
ubuntu(wsl)
rustc 1.72.1 (d5c2e9c34 2023-09-13)
binary: rustc
commit-hash: d5c2e9c342b358556da91d61ed4133f6f50fc0c3
commit-date: 2023-09-13
host: x86_64-unknown-linux-gnu
release: 1.72.1
LLVM version: 16.0.5
alpine
rustc 1.72.0 (5680fa18f 2023-08-23)
binary: rustc
commit-hash: 5680fa18feaa87f3ff04063800aec256c3d4b4be
commit-date: 2023-08-23
host: x86_64-unknown-linux-musl
release: 1.72.0
LLVM version: 16.0.5