rust-cross / cargo-zigbuild

Compile Cargo project with zig as linker
MIT License
1.35k stars 50 forks source link

Missing Exports from Windows GNU Target #251

Open SBuercklin opened 2 months ago

SBuercklin commented 2 months ago

When I compile the following lib.rs with the accompanying Cargo.toml for x86_64-pc-windows-gnu, the function test_fn is missing from the resulting DLL. However, this code compiles and exposes test_fn for x86_64-unknown-linux-gnu, aarch64-apple-darwin.

I compile the code with cargo zigbuild --release --target *insert_target* using a slightly modified version of the cargo-zigbuild Docker image

source:

#[no_mangle]
pub extern "C" fn test_fn(tag_id_c: i32) -> i32 {
    return tag_id_c;
}

Cargo.toml:

[package]
name = "wincompile"
version = "0.1.0"
edition = "2021"

[dependencies]

[lib]
crate-type = ["cdylib"]
messense commented 2 months ago

Mostly likely a zig cc issue since there isn't any special handling for DLL in this project, try to reproduce it using zig cc directly and report to zig for help.