From 1acc575dc4611a76099acaf76022a8c0ad251d81 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 30 Aug 2022 00:55:25 +0800 Subject: improve msvc to fix long path --- xmake/rules/c++/modules/modules_support/msvc.lua | 31 +++++++++++------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index 8048b7041..8003ea9dc 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -60,6 +60,13 @@ function _get_modulemap_from_mapper(target) return common.localcache():get2(_mapper_cachekey(target), "modulemap") or {} end +-- do compile +function _compile(target, argv) + local compinst = target:compiler("cxx") + local msvc = target:toolchain("msvc") + os.iorunv(compinst:program(), winos.cmdargv(argv), {envs = msvc:runenvs()}) +end + -- add an objectfile to the linker flags -- -- e.g @@ -119,8 +126,6 @@ end -- generate dependency files function generate_dependencies(target, sourcebatch, opt) local compinst = target:compiler("cxx") - local toolchain = target:toolchain("msvc") - local vcvars = toolchain:config("vcvars") local scandependenciesflag = get_scandependenciesflag(target) local common_flags = {"-TP", scandependenciesflag} local cachedir = common.modules_cachedir(target) @@ -139,7 +144,7 @@ function generate_dependencies(target, sourcebatch, opt) local jsonfile = path.join(outputdir, path.filename(sourcefile) .. ".json") if scandependenciesflag then local flags = {jsonfile, sourcefile, "-Fo" .. target:objectfile(sourcefile)} - os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_flags, flags), {envs = vcvars}) + _compile(target, table.join(compinst:compflags({target = target}), common_flags, flags)) else common.fallback_generate_dependencies(target, jsonfile, sourcefile) end @@ -157,13 +162,10 @@ function generate_headerunit_for_batchjob(target, name, flags, objectfile, index -- don't generate same header unit bmi at the same time across targets if not common.memcache():get2(name, "generating") then local compinst = target:compiler("cxx") - local toolchain = target:toolchain("msvc") - local vcvars = toolchain:config("vcvars") local common_flags = {"-TP", "-c"} - common.memcache():set2(name, "generating", true) progress.show((index * 100) / total, "${color.build.object}generating.cxx.headerunit.bmi %s", name) - os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_flags, flags), {envs = vcvars}) + _compile(target, table.join(compinst:compflags({target = target}), common_flags, flags)) _add_objectfile_to_link_arguments(target, objectfile) end end @@ -171,12 +173,10 @@ end -- generate header unit module bmi for batchcmds function generate_headerunit_for_batchcmds(target, name, flags, objectfile, batchcmds, opt) local compinst = target:compiler("cxx") - local toolchain = target:toolchain("msvc") - local vcvars = toolchain:config("vcvars") + local msvc = target:toolchain("msvc") local common_flags = {"-TP", "-c"} - batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.headerunit.bmi %s", name) - batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_flags, flags), {envs = vcvars}) + batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_flags, flags), {envs = msvc:runenvs()}) _add_objectfile_to_link_arguments(target, objectfile) end @@ -359,8 +359,6 @@ end -- build module files for batchjobs function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, opt) local compinst = target:compiler("cxx") - local toolchain = target:toolchain("msvc") - local vcvars = toolchain:config("vcvars") -- get flags local ifcoutputflag = get_ifcoutputflag(target) @@ -413,7 +411,7 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op bmifile, provide.sourcefile } - os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_flags, requiresflags or {}, flags), {envs = vcvars}) + _compile(target, table.join(compinst:compflags({target = target}), common_flags, requiresflags or {}, flags)) end, {dependfile = target:dependfile(bmifile), files = {provide.sourcefile}}) _add_module_to_mapper(target, referenceflag, name, name, objectfile, bmifile, requiresflags) end) @@ -450,8 +448,7 @@ end -- build module files for batchcmds function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, opt) local compinst = target:compiler("cxx") - local toolchain = target:toolchain("msvc") - local vcvars = toolchain:config("vcvars") + local msvc = target:toolchain("msvc") -- get flags local ifcoutputflag = get_ifcoutputflag(target) @@ -487,7 +484,7 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op path(provide.sourcefile)} batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.module.bmi %s", name) batchcmds:mkdir(path.directory(objectfile)) - batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_flags, requiresflags or {}, flags), {envs = vcvars}) + batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_flags, requiresflags or {}, flags), {envs = msvc:runenvs()}) batchcmds:add_depfiles(provide.sourcefile) _add_module_to_mapper(target, referenceflag, name, name, objectfile, bmifile, requiresflags) depmtime = math.max(depmtime, os.mtime(bmifile)) -- cgit v1.3.1 From eb942b57cb3dceb2661846ca660667084fefd021 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 30 Aug 2022 00:56:18 +0800 Subject: improve compile --- xmake/rules/c++/modules/modules_support/msvc.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index 8003ea9dc..2d53eb0fc 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -61,10 +61,10 @@ function _get_modulemap_from_mapper(target) end -- do compile -function _compile(target, argv) +function _compile(target, flags) local compinst = target:compiler("cxx") local msvc = target:toolchain("msvc") - os.iorunv(compinst:program(), winos.cmdargv(argv), {envs = msvc:runenvs()}) + os.iorunv(compinst:program(), winos.cmdargv(table.join(compinst:compflags({target = target}), flags)), {envs = msvc:runenvs()}) end -- add an objectfile to the linker flags @@ -125,7 +125,6 @@ end -- generate dependency files function generate_dependencies(target, sourcebatch, opt) - local compinst = target:compiler("cxx") local scandependenciesflag = get_scandependenciesflag(target) local common_flags = {"-TP", scandependenciesflag} local cachedir = common.modules_cachedir(target) @@ -144,7 +143,7 @@ function generate_dependencies(target, sourcebatch, opt) local jsonfile = path.join(outputdir, path.filename(sourcefile) .. ".json") if scandependenciesflag then local flags = {jsonfile, sourcefile, "-Fo" .. target:objectfile(sourcefile)} - _compile(target, table.join(compinst:compflags({target = target}), common_flags, flags)) + _compile(target, table.join(common_flags, flags)) else common.fallback_generate_dependencies(target, jsonfile, sourcefile) end @@ -161,11 +160,10 @@ end function generate_headerunit_for_batchjob(target, name, flags, objectfile, index, total) -- don't generate same header unit bmi at the same time across targets if not common.memcache():get2(name, "generating") then - local compinst = target:compiler("cxx") local common_flags = {"-TP", "-c"} common.memcache():set2(name, "generating", true) progress.show((index * 100) / total, "${color.build.object}generating.cxx.headerunit.bmi %s", name) - _compile(target, table.join(compinst:compflags({target = target}), common_flags, flags)) + _compile(target, table.join(common_flags, flags)) _add_objectfile_to_link_arguments(target, objectfile) end end @@ -358,7 +356,6 @@ end -- build module files for batchjobs function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, opt) - local compinst = target:compiler("cxx") -- get flags local ifcoutputflag = get_ifcoutputflag(target) @@ -411,7 +408,7 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op bmifile, provide.sourcefile } - _compile(target, table.join(compinst:compflags({target = target}), common_flags, requiresflags or {}, flags)) + _compile(target, table.join(common_flags, requiresflags or {}, flags)) end, {dependfile = target:dependfile(bmifile), files = {provide.sourcefile}}) _add_module_to_mapper(target, referenceflag, name, name, objectfile, bmifile, requiresflags) end) -- cgit v1.3.1 From 32c93e0142d4f1454d913fa1a69a9469dff756a8 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 30 Aug 2022 00:56:23 +0800 Subject: improve codes --- xmake/rules/c++/modules/modules_support/msvc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index 2d53eb0fc..c14bd73d2 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -218,9 +218,9 @@ end -- generate target stl header units for batchcmds function generate_stl_headerunits_for_batchcmds(target, batchcmds, headerunits, opt) - local stlcachedir = common.stlmodules_cachedir(target) -- get flags + local stlcachedir = common.stlmodules_cachedir(target) local exportheaderflag = get_exportheaderflag(target) local headerunitflag = get_headerunitflag(target) local headernameflag = get_headernameflag(target) -- cgit v1.3.1 From 609805ce753cbfffc053cbcc9e40f596405694f7 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 30 Aug 2022 00:56:54 +0800 Subject: improve compile --- xmake/rules/c++/modules/modules_support/msvc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index c14bd73d2..97cc00d9c 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -64,7 +64,7 @@ end function _compile(target, flags) local compinst = target:compiler("cxx") local msvc = target:toolchain("msvc") - os.iorunv(compinst:program(), winos.cmdargv(table.join(compinst:compflags({target = target}), flags)), {envs = msvc:runenvs()}) + os.vrunv(compinst:program(), winos.cmdargv(table.join(compinst:compflags({target = target}), flags)), {envs = msvc:runenvs()}) end -- add an objectfile to the linker flags -- cgit v1.3.1 From 8aa538adbd840ae27a5f693c5117f17153dd49de Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 30 Aug 2022 22:53:32 +0800 Subject: fix jobpool --- xmake/modules/private/async/jobpool.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xmake/modules/private/async/jobpool.lua b/xmake/modules/private/async/jobpool.lua index 696515f08..84e85deaf 100644 --- a/xmake/modules/private/async/jobpool.lua +++ b/xmake/modules/private/async/jobpool.lua @@ -123,10 +123,14 @@ function jobpool:pop() -- update all parents nodes for _, p in ipairs(parents) do - p._priority = math.max(p._priority or 0, priority + 1) - p._deps:remove(job) - if p._deps:empty() and self._size > 0 then - table.insert(leafjobs, 1, p) + -- we need avoid add it the leafjobs repeatly, it will cause dead-loop when poping group job + if not p._leaf then + p._priority = math.max(p._priority or 0, priority + 1) + p._deps:remove(job) + if p._deps:empty() and self._size > 0 then + p._leaf = true + table.insert(leafjobs, 1, p) + end end end @@ -185,6 +189,7 @@ function jobpool:_genleafjobs(job, leafjobs, refs) end end else + job._leaf = true table.insert(leafjobs, job) end end -- cgit v1.3.1 From 01bf39e3ee357a63da987921f18e0c26f49445ec Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 30 Aug 2022 22:54:29 +0800 Subject: add issue link --- xmake/modules/private/async/jobpool.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/xmake/modules/private/async/jobpool.lua b/xmake/modules/private/async/jobpool.lua index 84e85deaf..0b20cd5f4 100644 --- a/xmake/modules/private/async/jobpool.lua +++ b/xmake/modules/private/async/jobpool.lua @@ -124,6 +124,7 @@ function jobpool:pop() -- update all parents nodes for _, p in ipairs(parents) do -- we need avoid add it the leafjobs repeatly, it will cause dead-loop when poping group job + -- @see https://github.com/xmake-io/xmake/issues/2740 if not p._leaf then p._priority = math.max(p._priority or 0, priority + 1) p._deps:remove(job) -- cgit v1.3.1