diff options
| author | ruki <[email protected]> | 2025-08-10 21:37:03 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-10 21:37:03 +0800 |
| commit | 74f61a33d6af99e80bf55fee60c3acea09f4e1d8 (patch) | |
| tree | 74484bffe991b178c2ee5f9340114d97ae99dbc0 | |
| parent | 58f011fb3257a963e607e0b0337f11031025d3ba (diff) | |
| parent | d9af634da2cbbe29c1e185890255db39a4d5f60b (diff) | |
Merge pull request #6686 from xmake-io/toolchain
fix compiler cache #6672
| -rw-r--r-- | xmake/core/tool/compiler.lua | 23 | ||||
| -rw-r--r-- | xmake/core/tool/tool.lua | 5 |
2 files changed, 9 insertions, 19 deletions
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index b3a84e2a5..541a172b6 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -93,8 +93,6 @@ end -- load compiler tool function compiler._load_tool(sourcekind, target) - - -- get program from target local program, toolname, toolchain_info if target and target.tool then program, toolname, toolchain_info = target:tool(sourcekind) @@ -136,16 +134,15 @@ function compiler.load(sourcekind, target) local plat = compiler_tool:plat() or config.plat() or os.host() local arch = compiler_tool:arch() or config.arch() or os.arch() local cachekey = sourcekind .. (program_or_errors or "") .. plat .. arch + if target then + cachekey = cachekey .. tostring(target) + end -- get it directly from cache dirst compiler._INSTANCES = compiler._INSTANCES or {} local instance = compiler._INSTANCES[cachekey] if not instance then - - -- new instance instance = table.inherit(compiler, builder) - - -- save the compiler tool instance._TOOL = compiler_tool -- load the compiler language from the source kind @@ -200,8 +197,6 @@ end -- build the source files (compile and link) function compiler:build(sourcefiles, targetfile, opt) - - -- init options opt = opt or {} -- get compile flags @@ -225,15 +220,11 @@ function compiler:build(sourcefiles, targetfile, opt) if not targetkind and opt.target and opt.target.targetkind then targetkind = opt.target:kind() end - - -- get it return sandbox.load(self:_tool().build, self:_tool(), sourcefiles, targetkind or "binary", targetfile, flags) end -- get the build arguments list (compile and link) function compiler:buildargv(sourcefiles, targetfile, opt) - - -- init options opt = opt or {} -- get compile flags @@ -257,8 +248,6 @@ function compiler:buildargv(sourcefiles, targetfile, opt) if not targetkind and opt.target and opt.target.targetkind then targetkind = opt.target:kind() end - - -- get it return self:_tool():buildargv(sourcefiles, targetkind or "binary", targetfile, flags) end @@ -322,14 +311,10 @@ end -- @return flags list -- function compiler:compflags(opt) - - -- init options opt = opt or {} -- get target - local target = opt.target - - -- get target kind + local target = opt.target or self:target() local targetkind = opt.targetkind if not targetkind and target and target:type() == "target" then targetkind = target:kind() diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua index 0443498fe..06a5ca3ad 100644 --- a/xmake/core/tool/tool.lua +++ b/xmake/core/tool/tool.lua @@ -246,6 +246,11 @@ function tool.load(kind, opt) -- init cachekey local cachekey = kind .. (program or "") .. plat .. arch .. (opt.host and "host" or "") + if toolchain_info and toolchain_info.cachekey then + -- it maybe contains target key + -- @see https://github.com/xmake-io/xmake/issues/6672 + cachekey = cachekey .. toolchain_info.cachekey + end -- get it directly from cache dirst tool._TOOLS = tool._TOOLS or {} |
