From 2c2b0f08e4f4f3b65a153f06d49f4728c3f77615 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 21 Sep 2024 20:16:56 +0800 Subject: [PATCH] add special language linker flags for package --- xmake/core/tool/builder.lua | 11 ++++++++++- xmake/core/tool/linker.lua | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index 54652326d2..2bf4efc1f5 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -222,8 +222,17 @@ end -- add flags from the target packages function builder:_add_flags_from_targetpkgs(flags, target) + local kind = self:kind() for _, flagkind in ipairs(self:_flagkinds()) do - local result = target:get_from(flagkind, "package::*") + -- attempt to add special lanugage flags from package first, e.g. gcldflags, dcarflags + -- @see https://github.com/xmake-io/xmake-repo/issues/5255 + local result + if kind:endswith("ld") or kind:endswith("sh") then + result = target:get_from(kind .. "flags", "package::*") + end + if not result then + result = target:get_from(flagkind, "package::*") + end if result then for _, values in ipairs(table.wrap(result)) do table.join2(flags, self:_mapflags(values, flagkind, target)) diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index 070c90a9f6..2094d40a5a 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -63,7 +63,7 @@ function linker:_add_flags_from_linker(flags) local toolkind = self:kind() for _, flagkind in ipairs(self:_flagkinds()) do -- attempt to add special lanugage flags first, e.g. gcldflags, dcarflags - table.join2(flags, self:get(toolkind .. 'flags') or self:get(flagkind)) + table.join2(flags, self:get(toolkind .. "flags") or self:get(flagkind)) end end