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

C++20 module support when using clang toolchain in windows #2954

Closed
CCCptH opened this issue Oct 21, 2022 · 8 comments
Closed

C++20 module support when using clang toolchain in windows #2954

CCCptH opened this issue Oct 21, 2022 · 8 comments
Labels
Milestone

Comments

@CCCptH
Copy link

CCCptH commented Oct 21, 2022

Xmake Version

2.7.2

Operating System Version and Architecture

windows11

Describe Bug

Environment:

  • os: windows11
  • toolchain:clang

I want use xmake to build a project that consists of c++20 modules. And I use module partition features. The code is as follow.

// baseclass.ixx
export module traits:base_class;

export namespace xx {
    ...
}
// traits.ixx
export module traits;
export import :base_class;

Then I run xmake build, it shows that:

error: error: unable to rename temporary 'build\.gens\ntl\windows\x64\release\rules\modules\cache\traits:base_class-ca54136f.pcm.tmp' to output file 'build\.gens\ntl\windows\x64\release\rules\modules\cache\traits:base_class.pcm': 'invalid argument'

Because character ':' is not supported in path string of windows. So xmake build failed.

Expected Behavior

Successfully build.

Project Configuration

target('ntl')
    set_languages('c++20')
    set_kind('static')
    add_files('./Ntl/Public/**.ixx', './Ntl/Private/**.cxx', './Ntl/Private/**.cpp')

Additional Information and Error Logs

[ 14%]: generating.cxx.module.bmi ntl.type_traits:base_class
clang -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -fmodules -fbuiltin-module-map -fimplicit-modules -fno-implicit-module-maps -fno-ms-compatibility -DNDEBUG -fmodules-cache-path=build\.gens\ntl\windows\x64\release\rules\modules\cache -c -x c++-module --precompile Source\Ntl\Public\TypeTraits\BaseClasses.ixx -o build\.gens\ntl\windows\x64\release\rules\modules\cache\ntl.type_traits:base_class.pcm
[ 14%]: generating.cxx.module.bmi ne
clang -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -fmodules -fbuiltin-module-map -fimplicit-modules -fno-implicit-module-maps -fno-ms-compatibility -DNDEBUG -fmodules-cache-path=build\.gens\ncore\windows\x64\release\rules\modules\cache -c -x c++-module --precompile Source\NCore\Public\DynamicLib.ixx -o build\.gens\ncore\windows\x64\release\rules\modules\cache\ne.pcm
error: unable to rename temporary 'build\.gens\ntl\windows\x64\release\rules\modules\cache\ntl.type_traits:base_class-b418c1fa.pcm.tmp' to output file
      'build\.gens\ntl\windows\x64\release\rules\modules\cache\ntl.type_traits:base_class.pcm': 'invalid argument'
1 error generated.
error: @programdir\modules\private\async\runjobs.lua:256: @programdir\core\sandbox\modules\os.lua:372: execv(clang -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -fmodules -fbuiltin-module-map -fimplicit-modules -fno-implicit-module-maps -fno-ms-compatibility -DNDEBUG -fmodules-cache-path=build\.gens\ntl\windows\x64\release\rules\modules\cache -c -x c++-module --precompile Source\Ntl\Public\TypeTraits\BaseClasses.ixx -o build\.gens\ntl\windows\x64\release\rules\modules\cache\ntl.type_traits:base_class.pcm) failed(1)
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:897]:
    [@programdir\core\sandbox\modules\os.lua:372]:
    [@programdir\core\sandbox\modules\os.lua:285]: in function 'vrunv'
    [@programdir\rules\c++\modules\modules_support\clang.lua:383]: in function 'callback'
    [@programdir\modules\core\project\depend.lua:193]: in function 'on_changed'
    [@programdir\rules\c++\modules\modules_support\clang.lua:372]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:232]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:897: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\modules\private\async\runjobs.lua:256: in field 'catch'
        @programdir\core\sandbox\modules\try.lua:123: in global 'try'
        @programdir\modules\private\async\runjobs.lua:218: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:388: in function <@programdir\core\base\scheduler.lua:385>
warning: cannot match target(ntl).add_files("Source\Ntl\Private\**.cxx") at .\Source\xmake.lua:4
@CCCptH CCCptH added the bug label Oct 21, 2022
@waruqi
Copy link
Member

waruqi commented Oct 21, 2022

What's your clang version?

@CCCptH
Copy link
Author

CCCptH commented Oct 21, 2022

What's your clang version?

15.0.2

I note that the executed command that is automatically generated by xmake is

clang -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -fmodules -fbuiltin-module-map -fimplicit-modules -fno-implicit-module-maps -fno-ms-compatibility -DNDEBUG -fmodules-cache-path=build\.gens\ntl\windows\x64\release\rules\modules\cache -c -x c++-module --precompile Source\Ntl\Public\TypeTraits\BaseClasses.ixx -o build\.gens\ntl\windows\x64\release\rules\modules\cache\ntl.type_traits:base_class.pcm

It contains build\.gens\ntl\windows\x64\release\rules\modules\cache\ntl.type_traits:base_class.pcm in which ntl.type_traits:base_class.pcm is the name of module. But in windows system character : can not exist in path string. I think : should be replaced by some way.

But I know nothing about lua language. I dont know how to fix it.

@waruqi
Copy link
Member

waruqi commented Oct 22, 2022

I tried clang-15 on linux, it works for me. please provide your project example.

@CCCptH
Copy link
Author

CCCptH commented Oct 22, 2022

I tried clang-15 on linux, it works for me. please provide your project example.

windows上不可以,因为windows的路径不能包含:。如果module使用了module partition,生成的pcm文件的路径包含:字符,进而导致构建失败。

构建命令:

xmake f --toolchain=clang -c
xmake build

环境:

  • windows11
  • clang15.0.2

样例:

module_example.zip

报错:

[  0%]: generating.cxx.module.deps module.ixx
[  0%]: generating.cxx.module.deps partition.ixx
[  0%]: generating.cxx.module.deps main.cxx
[ 12%]: generating.cxx.module.bmi xx:partition
error: error: unable to rename temporary 'build\.gens\test\windows\x64\release\rules\modules\cache\xx:partition-6c7c97ca.pcm.tmp' to output file 'build\.gens\test\windows\x64\release\rules\modules\cache\xx:partition.pcm': 'invalid argument'
1 error generated.

详细报错:

checking for flags (clang_modules_cache_path) ... ok
> clang "-fmodules-cache-path=C:\Users\puppy\AppData\Local\Temp\.xmake\221023"
checking for flags (clang_module_file) ... ok
> clang "-fmodule-file=C:\Users\puppy\AppData\Local\Temp\.xmake\221023\_EB9B9DAE56BA480088023DF5E5D0FD30.pcm"
[ 12%]: generating.cxx.module.bmi xx:partition
checking for flags (-std=c++20) ... ok
> clang "-std=c++20"
checking for flags (-fmodules) ... ok
> clang "-fmodules"
clang -Qunused-arguments -m64 -std=c++20 -fmodules -fbuiltin-module-map -fimplicit-modules -fno-implicit-module-maps -fmodules-cache-path=build\.gens\test\windows\x64\release\rules\modules\cache -c -x c++-module --precompile partition.ixx -o build\.gens\test\windows\x64\release\rules\modules\cache\xx:partition.pcm
error: unable to rename temporary 'build\.gens\test\windows\x64\release\rules\modules\cache\xx:partition-08e0afb0.pcm.tmp' to output file 'build\.gens\test\windows\x64\release\rules\modules\cache\xx:partition.pcm': 'invalid argument'
1 error generated.
error: @programdir\modules\private\async\runjobs.lua:256: @programdir\core\sandbox\modules\os.lua:372: execv(clang -Qunused-arguments -m64 -std=c++20 -fmodules -fbuiltin-module-map -fimplicit-modules -fno-implicit-module-maps -fmodules-cache-path=build\.gens\test\windows\x64\release\rules\modules\cache -c -x c++-module --precompile partition.ixx -o build\.gens\test\windows\x64\release\rules\modules\cache\xx:partition.pcm) failed(1)
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:897]:
    [@programdir\core\sandbox\modules\os.lua:372]:
    [@programdir\core\sandbox\modules\os.lua:285]: in function 'vrunv'
    [@programdir\rules\c++\modules\modules_support\clang.lua:383]: in function 'callback'
    [@programdir\modules\core\project\depend.lua:193]: in function 'on_changed'
    [@programdir\rules\c++\modules\modules_support\clang.lua:372]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:232]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:897: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\modules\private\async\runjobs.lua:256: in field 'catch'
        @programdir\core\sandbox\modules\try.lua:123: in global 'try'
        @programdir\modules\private\async\runjobs.lua:218: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:388: in function <@programdir\core\base\scheduler.lua:385>

@waruqi
Copy link
Member

waruqi commented Oct 23, 2022

我暂时没有 win clang 环境,你可以直接 https://github.com/xmake-io/xmake/blob/master/xmake/modules/core/tools/clang.lua 里面调试下,然后来个 pr

waruqi added a commit that referenced this issue Oct 24, 2022
waruqi added a commit that referenced this issue Oct 24, 2022
@waruqi
Copy link
Member

waruqi commented Oct 24, 2022

是个 bug,之前对分区路径其实有处理,只是没处理对, #2970

先试下

xmake update github:xmake-io/xmake#module

@waruqi waruqi added this to the v2.7.3 milestone Oct 24, 2022
waruqi added a commit that referenced this issue Oct 24, 2022
@waruqi
Copy link
Member

waruqi commented Oct 24, 2022

我merge了,直接 dev 试就行了。xmake update -s dev

@CCCptH
Copy link
Author

CCCptH commented Oct 24, 2022

我merge了,直接 dev 试就行了。xmake update -s dev

多谢, 目前应该没有问题了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants