diff options
| author | ruki <[email protected]> | 2024-09-21 00:56:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-09-23 09:43:53 +0800 |
| commit | 7af1ca50e38a7cf21048be7a62bd30103421cceb (patch) | |
| tree | aeb13deca5fcab0a43554fe120d3091a52e5637c | |
| parent | 4fd8d5eec226060ee62b24c56ae4e303d4ededba (diff) | |
fix host toolchain
| -rw-r--r-- | xmake/core/platform/platform.lua | 5 | ||||
| -rw-r--r-- | xmake/core/tool/compiler.lua | 12 | ||||
| -rw-r--r-- | xmake/core/tool/linker.lua | 12 | ||||
| -rw-r--r-- | xmake/core/tool/tool.lua | 6 | ||||
| -rw-r--r-- | xmake/core/tool/toolchain.lua | 2 |
5 files changed, 29 insertions, 8 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index 1a8beb357..a58d225e5 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -204,7 +204,10 @@ function _instance:toolchains(opt) if not toolchain_inst then os.raise(errors) end - table.insert(toolchains, toolchain_inst) + -- ignore cross toolchains for the host platform:w + if (self:is_host() and not toolchain_inst:is_cross()) or not self:is_host() then + table.insert(toolchains, toolchain_inst) + end end end self:_memcache():set("toolchains", toolchains) diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index c11b2ba1d..d90ccb7c1 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -100,8 +100,18 @@ function compiler._load_tool(sourcekind, target) program, toolname, toolchain_info = target:tool(sourcekind) end + -- is host? + local is_host + if target and target.is_host then + is_host = target:is_host() + end + -- load the compiler tool from the source kind - local result, errors = tool.load(sourcekind, {program = program, toolname = toolname, toolchain_info = toolchain_info}) + local result, errors = tool.load(sourcekind, { + host = is_host, + program = program, + toolname = toolname, + toolchain_info = toolchain_info}) if not result then return nil, errors end diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index 2094d40a5..d91da81d8 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -88,8 +88,18 @@ function linker._load_tool(targetkind, sourcekinds, target) program, toolname, toolchain_info = target:tool(_linkerinfo.linkerkind) end + -- is host? + local is_host + if target and target.is_host then + is_host = target:is_host() + end + -- load the linker tool from the linker kind (with cache) - linkertool, errors = tool.load(_linkerinfo.linkerkind, {program = program, toolname = toolname, toolchain_info = toolchain_info}) + linkertool, errors = tool.load(_linkerinfo.linkerkind, { + host = is_host, + program = program, + toolname = toolname, + toolchain_info = toolchain_info}) if linkertool then linkerinfo = _linkerinfo linkerinfo.program = program diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua index 8a453e1f0..9022880a4 100644 --- a/xmake/core/tool/tool.lua +++ b/xmake/core/tool/tool.lua @@ -237,8 +237,6 @@ end -- @param opt.toolchain_info the toolchain info (optional) -- function tool.load(kind, opt) - - -- get tool information opt = opt or {} local program = opt.program local toolname = opt.toolname @@ -249,7 +247,7 @@ function tool.load(kind, opt) local arch = toolchain_info.arch or config.get("arch") or os.arch() -- init cachekey - local cachekey = kind .. (program or "") .. plat .. arch + local cachekey = kind .. (program or "") .. plat .. arch .. (opt.host and "host" or "") -- get it directly from cache dirst tool._TOOLS = tool._TOOLS or {} @@ -273,7 +271,7 @@ function tool.load(kind, opt) -- get the tool program and name if not program then - program, toolname, toolchain_info = platform.tool(kind, plat, arch) + program, toolname, toolchain_info = platform.tool(kind, plat, arch, {host = opt.host}) if toolchain_info then assert(toolchain_info.plat == plat) assert(toolchain_info.arch == arch) diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index ce6b834a6..a8c4e514a 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -167,7 +167,7 @@ end function _instance:is_cross() if self:kind() == "cross" then return true - elseif self:kind() == "standalone" and (self:cross() or self:sdkdir()) then + elseif self:kind() == "standalone" and (self:cross() or self:config("sdkdir") or self:info():get("sdkdir")) then return true end end |
