From 788d4e5929e89c3d0faaee311d3aa8b60bbb419a Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 22 Oct 2023 18:50:28 +0800 Subject: improve link group and whole #4308 --- xmake/modules/core/tools/gcc.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'xmake/modules/core/tools/gcc.lua') diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 6ccf50266..c0b2acf46 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -313,11 +313,13 @@ function nf_linkgroup(self, linkgroup, target) local flags = {} if not self:is_plat("macosx", "windows", "mingw") then local group = target:extraconf("linkgroups", linkgroup, "group") - if group then - table.join2(flags, "-Wl,--start-group", linkflags, "-Wl,--end-group") - end local whole = target:extraconf("linkgroups", linkgroup, "whole") - if whole then + if group and whole then + -- https://github.com/xmake-io/xmake/issues/4308 + table.join2(flags, "-Wl,--whole-archive", "-Wl,--start-group", linkflags, "-Wl,--end-group", "-Wl,--no-whole-archive") + elseif group then + table.join2(flags, "-Wl,--start-group", linkflags, "-Wl,--end-group") + elseif whole then table.join2(flags, "-Wl,--whole-archive", linkflags, "-Wl,--no-whole-archive") end local static = target:extraconf("linkgroups", linkgroup, "static") -- cgit v1.3.1