summaryrefslogtreecommitdiff
path: root/xmake/rules/rust/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-11-10 23:05:38 +0800
committerruki <[email protected]>2021-11-10 23:05:38 +0800
commitbc404bc6481de0c934aa5ff4523924688b72a2d4 (patch)
tree13d21c0ca6bd6881ae110809e815d37665c4fd88 /xmake/rules/rust/xmake.lua
parentb6ed301feb4b223a8c0faa9dd979a722b6e04555 (diff)
fix rpath for rust
Diffstat (limited to 'xmake/rules/rust/xmake.lua')
-rw-r--r--xmake/rules/rust/xmake.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/xmake/rules/rust/xmake.lua b/xmake/rules/rust/xmake.lua
index a8ccae429..b823ef753 100644
--- a/xmake/rules/rust/xmake.lua
+++ b/xmake/rules/rust/xmake.lua
@@ -21,6 +21,23 @@
-- define rule: rust.build
rule("rust.build")
set_sourcekinds("rc")
+ on_load(function (target)
+ if target:is_static() then
+ target:set("extension", ".rlib")
+ target:add("arflags", "--crate-type=lib")
+ elseif target:is_shared() then
+ target:add("shflags", "--crate-type=dylib")
+ -- fix cannot satisfy dependencies so `std` only shows up once
+ -- https://github.com/rust-lang/rust/issues/19680
+ --
+ -- but it will link dynamic @rpath/libstd-xxx.dylib,
+ -- so we can no longer modify and set other rpath paths
+ target:add("shflags", "-C prefer-dynamic")
+ elseif target:is_binary() then
+ target:add("ldflags", "--crate-type=bin")
+ end
+ target:data_set("inherit.links.deplink", false)
+ end)
on_build("build.target")
-- define rule: rust