summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-06-20 19:48:49 +0800
committerruki <[email protected]>2020-06-20 19:48:49 +0800
commita98aac667515d3fd59056a541199cdfe460f3d89 (patch)
treed15db9f9c4ea68587b67fe0900c45542d168b84a
parent8a4d7349f8562a3cf5869dfa4a6460c049f44f3b (diff)
fix link args
-rw-r--r--xmake/core/sandbox/modules/import/core/project/config.lua14
-rw-r--r--xmake/core/sandbox/modules/import/core/project/project.lua21
-rw-r--r--xmake/modules/core/tools/link.lua15
3 files changed, 27 insertions, 23 deletions
diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua
index 20fec1d4f..73dd71daf 100644
--- a/xmake/core/sandbox/modules/import/core/project/config.lua
+++ b/xmake/core/sandbox/modules/import/core/project/config.lua
@@ -124,20 +124,6 @@ function sandbox_core_project_config.check()
else
raise(errors)
end
-
- -- check toolchains configuration for all target in the current project
- local targets = project.targets()
- if targets then
- for _, target in pairs(targets) do
- if target:get("enabled") ~= false and target:get("toolchains") then
- for _, toolchain_inst in pairs(target:toolchains()) do
- if not toolchain_inst:check() then
- raise("toolchain(\"%s\"): not found!", toolchain_inst:name())
- end
- end
- end
- end
- end
end
-- dump the configuration
diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua
index cb7465fcd..c42563470 100644
--- a/xmake/core/sandbox/modules/import/core/project/project.lua
+++ b/xmake/core/sandbox/modules/import/core/project/project.lua
@@ -83,9 +83,6 @@ function sandbox_core_project.check()
raise(errors)
end
- -- enter toolchains environment
- environment.enter("toolchains")
-
-- init check task
local checked = {}
local checktask = function (index)
@@ -114,12 +111,24 @@ function sandbox_core_project.check()
local jobs = baseoption.get("jobs") or math.ceil(os.cpuinfo().ncpu * 3 / 2)
import("private.async.runjobs", {anonymous = true})("check_options", instance:fork(checktask):script(), {total = #options, comax = jobs})
- -- leave toolchains environment
- environment.leave("toolchains")
-
-- save all options to the cache file
option.save()
+ -- check toolchains configuration for all target in the current project
+ -- @note we must check targets after loading options
+ local targets = project.targets()
+ if targets then
+ for _, target in pairs(targets) do
+ if target:get("enabled") ~= false and target:get("toolchains") then
+ for _, toolchain_inst in pairs(target:toolchains()) do
+ if not toolchain_inst:check() then
+ raise("toolchain(\"%s\"): not found!", toolchain_inst:name())
+ end
+ end
+ end
+ end
+ end
+
-- leave the project directory
local ok, errors = os.cd(oldir)
if not ok then
diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua
index 8d1f9083d..10a242e6d 100644
--- a/xmake/modules/core/tools/link.lua
+++ b/xmake/modules/core/tools/link.lua
@@ -29,10 +29,10 @@ function init(self)
self:set("ldflags", "-nologo", "-dynamicbase", "-nxcompat")
-- init arflags
- self:set("arflags", "-lib", "-nologo")
+ self:set("arflags", "-nologo")
-- init shflags
- self:set("shflags", "-dll", "-nologo")
+ self:set("shflags", "-nologo")
-- init flags map
self:set("mapflags",
@@ -94,7 +94,16 @@ end
function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
opt = opt or {}
local argv = table.join(flags, "-out:" .. targetfile, objectfiles)
- return self:program(), opt.rawargs and argv or winos.cmdargv(argv)
+ if not opt.rawargs then
+ argv = winos.cmdargv(argv)
+ end
+ -- @note we cannot put -lib/-dll to @args.txt
+ if targetkind == "static" then
+ table.insert(argv, 1, "-lib")
+ elseif targetkind == "shared" then
+ table.insert(argv, 1, "-dll")
+ end
+ return self:program(), argv
end
-- link the target file