summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-09-06 22:48:26 +0800
committerGitHub <[email protected]>2025-09-06 22:48:26 +0800
commite2cd53a8bc9593c20aeb5c77a4a02fc38585f91e (patch)
tree812ead23123a69c2d5bd488f40078dcdf747ed3e
parent8d003d54d21714a893990e640ab6d9e711a092a5 (diff)
parente515d5bcc23ee9b8dda615540a77fd291c2b52ee (diff)
Merge pull request #6778 from xmake-io/compout
add build.linker.output
-rw-r--r--xmake/core/project/policy.lua3
-rw-r--r--xmake/modules/core/tools/gcc.lua9
2 files changed, 11 insertions, 1 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua
index 8b991553f..5c5e376a8 100644
--- a/xmake/core/project/policy.lua
+++ b/xmake/core/project/policy.lua
@@ -106,6 +106,9 @@ function policy.policies()
["build.c++.msvc.runtime"] = {description = "Set the default vs runtime.", type = "string", values = {"MT", "MD"}},
-- Enable cuda device link
["build.cuda.devlink"] = {description = "Enable Cuda devlink.", type = "boolean"},
+ -- Enable linker output, e.g. show -Wl,--print-memory-usage output for gcc/g++
+ -- @see https://github.com/xmake-io/xmake/discussions/6772
+ ["build.linker.output"] = {description = "Enable linker output.", type = "boolean"},
-- Enable build jobgraph
["build.jobgraph"] = {description = "Enable build jobgraph.", default = true, type = "boolean"},
-- Enable windows UAC and set level, e.g. invoker, admin, highest
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 7062e335f..ed8bebdbc 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -937,6 +937,13 @@ end
function link(self, objectfiles, targetkind, targetfile, flags, opt)
opt = opt or {}
+ -- enable linker output?
+ local target = opt.target
+ local linker_output = option.get("verbose")
+ if linker_output == nil and target and target.policy and target:policy("build.linker.output") then
+ linker_output = true
+ end
+
os.mkdir(path.directory(targetfile))
local implibfile = _get_implibfile(self, targetkind, targetfile, opt)
if implibfile then
@@ -944,7 +951,7 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt)
end
local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
- if option.get("verbose") then
+ if linker_output then
os.execv(program, argv, {envs = self:runenvs(), shell = opt.shell})
else
os.vrunv(program, argv, {envs = self:runenvs(), shell = opt.shell})