Skip to content

Commit feecf8c

Browse files
committed
Adapt to new rustc-cdylib-link-arg parameter
After rust-lang/rust/pull/36574 has been merged the latest Rust version 1.49 breaks the linking of dynamic libs in MacOS. These changes ensure that the extra link args are applied only at the dynamic lib generation linking step.
1 parent 5bb77fc commit feecf8c

File tree

5 files changed

+196
-20
lines changed

5 files changed

+196
-20
lines changed

ct/rebar3_cargo_SUITE_data/test_nif_app/Cargo.lock

Lines changed: 175 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ct/rebar3_cargo_SUITE_data/test_nif_app/rust_src/nifsys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Daniel Goertzen <[email protected]>"]
55

66
[lib]
77
name = "nifsys"
8-
crate-type = ["dylib"]
8+
crate-type = ["cdylib"]
99

1010
[dependencies]
1111
rustler = "0.21.1"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use std::env;
2+
3+
fn main() {
4+
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
5+
6+
if target_os == "macos" {
7+
println!("cargo:rustc-cdylib-link-arg=-flat_namespace");
8+
println!("cargo:rustc-cdylib-link-arg=-undefined");
9+
println!("cargo:rustc-cdylib-link-arg=suppress");
10+
}
11+
}

rebar.config

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
{deps, [cargo]}.
1+
{deps, [
2+
{cargo,
3+
{git, "https://github.com/lrascao/erlang-cargo.git",
4+
{branch, "fix/rustflags_hack"}}}
5+
]}.
26

37
{eunit_tests, [rebar3_cargo]}.
48

rebar.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{"1.2.0",
2-
[{<<"cargo">>,{pkg,<<"cargo">>,<<"0.1.2">>},0},
2+
[{<<"cargo">>,
3+
{git,"https://github.com/lrascao/erlang-cargo.git",
4+
{ref,"8561886f8e415afbcd9e14af1ee3ebc590f4558d"}},
5+
0},
36
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.11.0">>},1}]}.
47
[
58
{pkg_hash,[
6-
{<<"cargo">>, <<"1245B5A21454EBEABACF403911D54A82A0D457A3F635511A03AD06845F5ABF95">>},
79
{<<"jsx">>, <<"08154624050333919B4AC1B789667D5F4DB166DC50E190C4D778D1587F102EE0">>}]},
810
{pkg_hash_ext,[
9-
{<<"cargo">>, <<"EB614BA74F9F5B61643E5CC607BBF7DDC8420D368661E31C04E0DB7AD47E21B3">>},
1011
{<<"jsx">>, <<"EED26A0D04D217F9EECEFFFB89714452556CF90EB38F290A27A4D45B9988F8C0">>}]}
1112
].

0 commit comments

Comments
 (0)