From d3a75d4be2aa50a1dfdf5b7708c08409b5e28fcb Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 4 Aug 2024 18:23:32 +0200 Subject: fix gcc module scanning when buildflags are updated --- .../rules/c++/modules/modules_support/gcc/dependency_scanner.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support') diff --git a/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua index 38d7c6069..237e22627 100644 --- a/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua +++ b/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua @@ -35,6 +35,7 @@ function generate_dependency_for(target, sourcefile, opt) local depsfileflag = compiler_support.get_depsfileflag(target) local depstargetflag = compiler_support.get_depstargetflag(target) local dependfile = target:dependfile(sourcefile) + local flags = compinst:compflags({sourcefile = file, target = target}) or {} local changed = false depend.on_changed(function() @@ -48,8 +49,7 @@ function generate_dependency_for(target, sourcefile, opt) if has_depsflags and not target:policy("build.c++.gcc.fallbackscanner") then local ifile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".i")) local dfile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".d")) - local compflags = compinst:compflags({sourcefile = sourcefile, target = target}) - local flags = table.join(compflags or {}, baselineflags, {sourcefile, "-MT", jsonfile, "-MD", "-MF", dfile, depsformatflag, depsfileflag .. jsonfile, depstargetflag .. target:objectfile(sourcefile), "-o", ifile}) + local flags = table.join(flags or {}, baselineflags, {sourcefile, "-MT", jsonfile, "-MD", "-MF", dfile, depsformatflag, depsfileflag .. jsonfile, depstargetflag .. target:objectfile(sourcefile), "-o", ifile}) os.vrunv(compinst:program(), flags) os.rm(ifile) os.rm(dfile) @@ -58,7 +58,7 @@ function generate_dependency_for(target, sourcefile, opt) wprint("GCC doesn't support module scanning ! using fallback scanner") end fallback_generate_dependencies(target, jsonfile, sourcefile, function(file) - local compflags = compinst:compflags({sourcefile = file, target = target}) + local compflags = flags -- exclude -fmodule* flags because, when they are set gcc try to find bmi of imported modules but they don't exists a this point of compilation table.remove_if(compflags, function(_, flag) return flag:startswith("-fmodule") end) local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i")) @@ -73,7 +73,7 @@ function generate_dependency_for(target, sourcefile, opt) local dependinfo = io.readfile(jsonfile) return { moduleinfo = dependinfo } - end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt()}) + end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt(), values = flags}) return changed end -- cgit v1.3.1