From f8a88c362c7d87f23680ecb4c6027b21537714a0 Mon Sep 17 00:00:00 2001 From: Sam Surtees Date: Sun, 2 Feb 2020 16:46:52 +1000 Subject: [PATCH] Fixed bug with linkgroups only working on Premake projects --- src/tools/gcc.lua | 10 +++++----- tests/tools/test_gcc.lua | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 4afab09e..f9dab594 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -467,11 +467,6 @@ end end - if not nogroups and #result > 1 and (cfg.linkgroups == p.ON) then - table.insert(result, 1, "-Wl,--start-group") - table.insert(result, "-Wl,--end-group") - end - -- The "-l" flag is fine for system libraries local links = config.getlinks(cfg, "system", "fullpath") local static_syslibs = {"-Wl,-Bstatic"} @@ -511,6 +506,11 @@ end move(shared_syslibs, result) + if not nogroups and #result > 1 and (cfg.linkgroups == p.ON) then + table.insert(result, 1, "-Wl,--start-group") + table.insert(result, "-Wl,--end-group") + end + return result end diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index ab5b77fe..dfab6d2b 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -504,6 +504,24 @@ end +-- +-- Test that sibling and external links are grouped when required +-- + + function suite.linkgroups_onSiblingAndExternalLibrary() + links { "MyProject2", "ExternalProj" } + linkgroups "On" + + test.createproject(wks) + system "Linux" + kind "StaticLib" + targetdir "lib" + + prepare() + test.isequal({ "-Wl,--start-group", "lib/libMyProject2.a", "-lExternalProj", "-Wl,--end-group" }, gcc.getlinks(cfg)) + end + + -- -- When linking object files, leave off the "-l". --