diff options
| author | ruki <[email protected]> | 2023-03-06 22:55:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-03-06 22:55:57 +0800 |
| commit | a71fe6d9b138fc9bb16dfb31591f1514f34adf1b (patch) | |
| tree | 79a1979b2ce827f6c515b0c60edf6dd6d34c1a2a | |
| parent | 8bb23ca24aebe4c2dde25183a4eee7cda76e3438 (diff) | |
fix sysflags
| -rw-r--r-- | xmake/core/tool/tool.lua | 9 | ||||
| -rw-r--r-- | xmake/rules/rust/xmake.lua | 12 |
2 files changed, 14 insertions, 7 deletions
diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua index c3c256396..46e3e664b 100644 --- a/xmake/core/tool/tool.lua +++ b/xmake/core/tool/tool.lua @@ -188,15 +188,22 @@ function _instance:_sysflags(toolkind, flagkind) local sysflags = {} local sourceflags = language.sourceflags()[toolkind] if not sourceflags and flagkind then - sourceflags = {flagkind} + sourceflags = {} if flagkind == "cflags" or flagkind == "cxxflags" then + table.insert(sourceflags, flagkind) table.insert(sourceflags, "cxflags") elseif flagkind == "cxflags" then + table.insert(sourceflags, flagkind) table.insert(sourceflags, "cxxflags") elseif flagkind == "mflags" or flagkind == "mxxflags" then + table.insert(sourceflags, flagkind) table.insert(sourceflags, "mxflags") elseif flagkind == "mxflags" then + table.insert(sourceflags, flagkind) table.insert(sourceflags, "mxxflags") + else + -- flagkind may be ldflags, we need ignore it + -- and we should use more precise flagkind, e.g. rcldflags instead of ldflags end end if sourceflags then diff --git a/xmake/rules/rust/xmake.lua b/xmake/rules/rust/xmake.lua index e31e2f046..2e9295cfd 100644 --- a/xmake/rules/rust/xmake.lua +++ b/xmake/rules/rust/xmake.lua @@ -40,22 +40,22 @@ rule("rust.build") target:data_set("inherit.links.exportlinks", false) elseif cratetype == "cdylib" then assert(target:is_shared(), "target(%s) must be shared kind for cratetype(cdylib)!", target:name()) - target:add("shflags", "--crate-type=cdylib") - target:add("shflags", "-C prefer-dynamic") + target:add("shflags", "--crate-type=cdylib", {force = true}) + target:add("shflags", "-C prefer-dynamic", {force = true}) elseif target:is_static() then target:set("extension", ".rlib") - target:add("arflags", "--crate-type=lib") + target:add("arflags", "--crate-type=lib", {force = true}) target:data_set("inherit.links.deplink", false) elseif target:is_shared() then - target:add("shflags", "--crate-type=dylib") + target:add("shflags", "--crate-type=dylib", {force = true}) -- 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") + target:add("shflags", "-C prefer-dynamic", {force = true}) elseif target:is_binary() then - target:add("ldflags", "--crate-type=bin") + target:add("ldflags", "--crate-type=bin", {force = true}) end -- set edition |
