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