summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-05-08 23:40:07 +0800
committerruki <[email protected]>2024-05-08 23:40:07 +0800
commitf7ee280ab5326abf641fe7bc1ebf12b31cf2423c (patch)
treeca71d74c14ceb3a16b4a7017cd6c87415a65165d
parent3e9e12adad6b63334d25e3861405246afce948c9 (diff)
fix gcc-ar #5051
-rw-r--r--xmake/modules/core/tools/ar.lua5
-rw-r--r--xmake/modules/core/tools/gcc_ar.lua22
-rw-r--r--xmake/toolchains/cross/load.lua3
3 files changed, 24 insertions, 6 deletions
diff --git a/xmake/modules/core/tools/ar.lua b/xmake/modules/core/tools/ar.lua
index b302504d8..e8f4f58dc 100644
--- a/xmake/modules/core/tools/ar.lua
+++ b/xmake/modules/core/tools/ar.lua
@@ -30,8 +30,7 @@ end
-- make the strip flag
function strip(self, level)
- local maps =
- {
+ local maps = {
debug = "-S"
, all = "-s"
}
@@ -57,7 +56,7 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt)
os.tryrm(targetfile)
-- link it
- local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags)
+ local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
os.runv(program, argv, {envs = self:runenvs(), shell = opt.shell})
end
diff --git a/xmake/modules/core/tools/gcc_ar.lua b/xmake/modules/core/tools/gcc_ar.lua
index ecfdca92a..f6834a20c 100644
--- a/xmake/modules/core/tools/gcc_ar.lua
+++ b/xmake/modules/core/tools/gcc_ar.lua
@@ -20,3 +20,25 @@
inherit("ar")
+-- make the link arguments list
+-- @see https://github.com/xmake-io/xmake/issues/5051
+-- @note gcc-ar.exe does not support `gcc-ar.exe @file`
+function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
+ local argv = table.join(flags, targetfile, objectfiles)
+ return self:program(), argv
+end
+
+-- link the library file
+function link(self, objectfiles, targetkind, targetfile, flags, opt)
+ opt = opt or {}
+ os.mkdir(path.directory(targetfile))
+
+ -- @note remove the previous archived file first to force recreating a new file
+ os.tryrm(targetfile)
+
+ -- link it
+ local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
+ os.runv(program, argv, {envs = self:runenvs(), shell = opt.shell})
+end
+
+
diff --git a/xmake/toolchains/cross/load.lua b/xmake/toolchains/cross/load.lua
index 285a3a8a0..f34b1fd58 100644
--- a/xmake/toolchains/cross/load.lua
+++ b/xmake/toolchains/cross/load.lua
@@ -24,9 +24,6 @@ import("core.project.config")
-- load the cross toolchain
function main(toolchain)
- -- imports
- import("core.project.config")
-
-- get cross prefix
local cross = toolchain:cross() or ""