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

Add c++ modules ts build rules #569

Merged
merged 11 commits into from Sep 12, 2019

Conversation

@waruqi
Copy link
Member

commented Sep 6, 2019

Roadmap

  • module interface files
    • .ixx (msvc)
    • .cppm (clang)
    • .mxx/.mpp (recommand/xmake)
  • clang
    • hello
    • impl_unit
    • inline_and_template
    • class
    • dependence
  • gcc
  • msvc (>= vs2017)
    • hello
    • impl_unit
    • inline_and_template
    • class
    • dependence

Examples

References

waruqi added 3 commits Sep 5, 2019
@waruqi waruqi added this to the v2.2.9 milestone Sep 6, 2019
@waruqi waruqi added the in progress label Sep 6, 2019
waruqi added 4 commits Sep 6, 2019
@waruqi waruqi changed the title Add c++ modules build rules Add c++ modules ts build rules Sep 6, 2019
@waruqi

This comment has been minimized.

Copy link
Member Author

commented Sep 6, 2019

Example (hello)

projectdir
  - src
    - hello.mpp
    - main.cpp
  - xmake.lua

xmake.lua

target("hello")
    set_kind("binary")
    add_files("src/*.cpp", "src/*.mpp") 

hello.mpp

// module;
#include <cstdio>
export module hello;
using namespace std;

export namespace hello {
    void say(const char* str) {
        printf("%s\n", str);
    }
}

main.cpp

import hello;

int main() {
    hello::say("hello module!");
    return 0;
}

Build and output

ruki:hello ruki$ xmake 
[  0%]: ccache compiling.release src/hello.mpp
[ 50%]: ccache compiling.release src/main.cpp
[100%]: linking.release hello
build ok!👌
ruki:hello ruki$ xmake -r -v
[  0%]: ccache compiling.release src/hello.mpp
/usr/local/bin/ccache /usr/bin/xcrun -sdk macosx clang -c -fmodules-ts --precompile -x c++-module -Qunused-arguments -arch x86_64 -fpascal-strings -fmessage-length=0 -mmacosx-version-min=10.14 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -o build/.objs/hello/macosx/x86_64/release/src/hello.mpp.o.pcm src/hello.mpp
/usr/local/bin/ccache /usr/bin/xcrun -sdk macosx clang -c -fmodules-ts -Qunused-arguments -arch x86_64 -fpascal-strings -fmessage-length=0 -mmacosx-version-min=10.14 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -o build/.objs/hello/macosx/x86_64/release/src/hello.mpp.o build/.objs/hello/macosx/x86_64/release/src/hello.mpp.o.pcm
[ 50%]: ccache compiling.release src/main.cpp
/usr/local/bin/ccache /usr/bin/xcrun -sdk macosx clang -c -fmodules-ts -fmodule-file=build/.objs/hello/macosx/x86_64/release/src/hello.mpp.o.pcm -Qunused-arguments -arch x86_64 -fpascal-strings -fmessage-length=0 -mmacosx-version-min=10.14 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -o build/.objs/hello/macosx/x86_64/release/src/main.cpp.o src/main.cpp
[100%]: linking.release hello
"/usr/bin/xcrun -sdk macosx clang++" -o build/macosx/x86_64/release/hello build/.objs/hello/macosx/x86_64/release/src/hello.mpp.o build/.objs/hello/macosx/x86_64/release/src/main.cpp.o -arch x86_64 -mmacosx-version-min=10.14 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -stdlib=libc++ -lz
build ok!👌
waruqi added 3 commits Sep 7, 2019
@waruqi

This comment has been minimized.

Copy link
Member Author

commented Sep 12, 2019

There is currently no environment to compile gcc toolchains with c++modules. (in svn://gcc.gnu.org/svn/gcc/branches/c++-modules)

And gcc's c++ modules implementation is not perfect, for the time being I don't support it.

目前我这没环境单独做一份支持c++modules的gcc toolchains来测试c++modules,并且目前gcc对c++modules支持也还不是很完善,等之后集成到gcc正式版的时候,我再对gcc做支持好了,目前不折腾了。。

@waruqi waruqi marked this pull request as ready for review Sep 12, 2019
@waruqi waruqi merged commit 961b833 into dev Sep 12, 2019
4 checks passed
4 checks passed
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@waruqi waruqi referenced this pull request Sep 12, 2019
@waruqi waruqi deleted the cppmodules branch Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.