-
-
Notifications
You must be signed in to change notification settings - Fork 774
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 submodules #1982
Fix clang submodules #1982
Conversation
| local moduleinfo = data.moduleinfo | ||
| moduledeps = moduledeps or {} | ||
| moduledeps[moduleinfo.name] = moduleinfo | ||
| if data.moduleinfo then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and
local moduleinfo = data.moduleinfo
if moduleinfo then
moduledeps = moduledeps or {}
moduledeps[moduleinfo.name] = moduleinfo
end
| @@ -100,6 +100,14 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt) | |||
| opt2.objectfile = modulefiles[i] | |||
| opt2.dependfile = target:dependfile(opt2.objectfile) | |||
| opt2.sourcekind = assert(sourcebatch.sourcekind, "%s: sourcekind not found!", sourcefile) | |||
| if moduledep["deps"] then | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use moduledep.deps moduledep.name
| if found == nil then | ||
| target:add("cxxflags", "-fmodule-file=" .. modulefile, {force = true}) | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? The code below will add it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xmake/xmake/rules/c++/modules/build_modules/clang.lua
Lines 122 to 129 in 1b2a5da
| count = count + 1 | |
| if count == sourcefiles_total then | |
| target:add("cxxflags", modulesflag, "-fmodules-cache-path=" .. cachedir, {force = true}) | |
| -- FIXME It is invalid for the module implementation unit | |
| --target:add("cxxflags", "-fimplicit-modules", "-fimplicit-module-maps", "-fprebuilt-module-path=" .. cachedir, {force = true}) | |
| for _, modulefile in ipairs(modulefiles) do | |
| target:add("cxxflags", "-fmodule-file=" .. modulefile, {force = true}) | |
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code above doesn't add the pcm file to the compilation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've turned on -fimplicit-modules and module cache, clang should find submodules without explicitly setting -fmodule-file.
The root cause of it is that the module files for cache/module1.pcm are not named correctly, in case of submodules, it should be cache/main_module.module1.pcm so that clang can find them correctly.
I have tested your demo project and confirmed that it can be fixed successfully.
|
I can't reproduce it, It work fine here xmake f --toolchain=clang-13 -cvD;xmake -r
checking for platform ... linux
checking for architecture ... x86_64
checking for clang-13 ... /usr/bin/clang-13
configure
{
ndk_stdcxx = true
ccache = true
arch = x86_64
mode = release
buildir = build
toolchain = clang-13
clean = true
plat = linux
host = linux
kind = static
}
[ 14%]: ccache compiling.release src/math.math1.mpp
[ 14%]: ccache compiling.release src/math.math2.mpp
[ 42%]: ccache compiling.release src/math.mpp
[ 57%]: ccache compiling.release src/main.cpp
[ 71%]: linking.release math
[100%]: build ok!Can you give a reproducible example? or provide your error output? |
|
This is the complete flow that led to the error and the build with my patches |
|
can you upload your demo project? |
|
The zip file is attached
modfix.zip
<https://drive.google.com/file/d/1nSYd-79nsJKSkJQaiAg7TzvQ5fuQdx1_/view?usp=drivesdk>
Em ter., 18 de jan. de 2022 10:14, ruki ***@***.***> escreveu:
… can you upload your demo project?
—
Reply to this email directly, view it on GitHub
<#1982 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARARENZQEEA3HBCJHGOO5LUWVRS3ANCNFSM5MFMM3MA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
thanks, I will look at it in these days |
I cannot downlload it, can you upload it to github issues attachment? |
|
I added your demo project as test. https://github.com/xmake-io/xmake/tree/dev/tests/projects/c%2B%2B/modules/submodules2 |
|
Here follows the test project |
|
Does it work for this patch now? |
|
Yes, I merged the latest master commits and it is working fine. Thanx |

I made this pull request due to build failures with submodules and clang 13. I've tested it with the project
xmake/tests/projects/c++/modules/submodulesand it runs as expected.