Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clang module builds using outdated build flags #5425

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions xmake/rules/c++/modules/modules_support/clang/builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,21 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)

local build, dependinfo
local dependfile = target:dependfile(bmifile or opt.objectfile)
if provide or compiler_support.has_module_extension(opt.cppfile) then
build, dependinfo = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires})

-- needed to detect rebuild of dependencies
if provide and build then
mark_build(target, name)
end
build, dependinfo = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires})

-- needed to detect rebuild of dependencies
if provide and build then
mark_build(target, name)
end

-- append requires flags
if opt.module.requires then
_append_requires_flags(target, opt.module, name, opt.cppfile, bmifile, opt)
_append_requires_flags(target, opt.module, name, opt.cppfile, bmifile, table.join(opt, {build = build}))
end

-- for cpp file we need to check after appendings the flags
if build == nil then
if not provide and not compiler_support.has_module_extension(opt.cppfile) then
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little...uncertain about this. It essentially means that, for non-modules, should_build gets called twice, one before the requires flags are added and one after, In theory, the second one wouldn't be needed, because _append_requires_flags seems to always compute the flags from opt.module.requires, which was already passed to the first call. However, the above comment explicitly says the check needs to happen after the flags are added, which makes me think that there's a distinct reason for that? But I don't know what that reason is, so I just left the second call in place. If I can safely remove this, I'll just update the PR.

build, dependinfo = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires})
end

Expand Down Expand Up @@ -274,9 +273,11 @@ function make_module_buildcmds(target, batchcmds, opt)
mapped_bmi = get_from_target_mapper(target, name).bmi
end

local build = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires})

-- append requires flags
if opt.module.requires then
_append_requires_flags(target, opt.module, name, opt.cppfile, bmifile, opt)
_append_requires_flags(target, opt.module, name, opt.cppfile, bmifile, table.join(opt, {build = build}))
end

-- compile if it's a named module
Expand Down
Loading