rust-cross / cargo-zigbuild

Compile Cargo project with zig as linker
MIT License
1.43k stars 51 forks source link

fix zig: unsupported exported_symbols_list #171

Closed serjflint closed 11 months ago

serjflint commented 11 months ago

Relates: #164

messense commented 11 months ago

I'm not sure if this actually works because -exported_symbols_list takes a value, see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-exported_symbols_list.

messense commented 11 months ago

And looks like it only applies to macOS targets, see https://github.com/rust-lang/rust/blob/dda95c14e1a9356397c6369762047db031e69461/compiler/rustc_codegen_ssa/src/back/linker.rs#L714-L715

serjflint commented 11 months ago

I'm not sure if this actually works because -exported_symbols_list takes a value, see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-exported_symbols_list.

Thanks for pointing that out. Should I do something like this?

And looks like it only applies to macOS targets, see https://github.com/rust-lang/rust/blob/dda95c14e1a9356397c6369762047db031e69461/compiler/rustc_codegen_ssa/src/back/linker.rs#L714-L715

My bad. I haven't checked prior conditions.

I am good at neither Rust nor compiling but I will try to make a PR =)

messense commented 11 months ago

Should I do something like this?

I think we need remove both -Wl,--exported_symbols_list and the value follows, currently filter_linker_arg doesn't support that, so the code needs a bit refactoring.

serjflint commented 11 months ago

I think we need remove both -Wl,--exported_symbols_list and the value follows, currently filter_linker_arg doesn't support that, so the code needs a bit refactoring.

My case looks like "-Wl,-exported_symbols_list,/tmp/rustcnkqKsZ/list" so arg.starts_with should do the job.

messense commented 11 months ago

What's your Rust version?

serjflint commented 11 months ago

What's your Rust version?

Stable 0.17.2 Upd: Stable 17.2

messense commented 11 months ago

OK, so according to the commit message, both -Wl,-exported_symbols_list,<path> and -Wl,-exported_symbols_list <path> can happen.

So IMO we can merge this first and deal with -Wl,-exported_symbols_list <path> later.

messense commented 11 months ago

Thanks!