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

Support GCC C++20+ modules. #21

Closed
wants to merge 6 commits into from
Closed

Conversation

Islam0mar
Copy link

@Islam0mar Islam0mar commented Jul 13, 2023

This PR does the following:

  • Used mapper.txt to expose .gcm location to top/down files, example:
    • mapper.txt content: hello /abs./path/to//modules/example/build/gcm.cache/hello.gcm
    • compile main with: -fmodule-mapper=/abs./path/to/mapper.txt
  • Added cmake_parse_arguments as it handle arguments better.

NOTE:

  • I haven't tried system modules, maybe some modifications will be needed!
  • Tested with gcc-13.1.0 and clang-17.0.0

@vitaut
Copy link
Owner

vitaut commented Jul 15, 2023

Thanks for the PR. GCC C++20 modules are already supported, is there any advantage to using mapper.txt?

modules.cmake Outdated Show resolved Hide resolved
@Islam0mar
Copy link
Author

You can try to compile module library in path x and use this module inside another source file in parent directory or sub directory of path x i.e different build directories. In this case the error of

error: failed to read compiled module: No such file or directory
note: compiled module file is ‘gcm.cache/~.gcm’
note: imports must be built before being imported
fatal error: returning to the gate for a mechanical issue

is shown.

when gcm.cache/~.gcm isn't in the same directory in build path, gcc can't find the location of .gcm file .

@Islam0mar Islam0mar requested a review from vitaut July 15, 2023 18:16
modules.cmake Outdated Show resolved Hide resolved
@Islam0mar Islam0mar requested a review from vitaut July 22, 2023 17:30
@vitaut
Copy link
Owner

vitaut commented Jul 23, 2023

You can try to compile module library in path x and use this module inside another source file in parent directory or sub directory of path x i.e different build directories

This can be solved by setting the cache path (e.g. https://stackoverflow.com/q/69549286/471164). Is there any advantage to using a mapper file?

@Islam0mar
Copy link
Author

Islam0mar commented Jul 23, 2023

GCC doesn't have this option -fmodules-cache-path= this is for clang!

xmake used the same approach here.
I am assuming module file name and module name are the same.

@vitaut
Copy link
Owner

vitaut commented Jul 23, 2023

GCC doesn't have this option -fmodules-cache-path= this is for clang!

I mean that you can set the path for the cache directory with -fmodule-mapper=|@g++-mapper-server -r${MAPPER_DIR}. This seems like an easier option.

@Islam0mar
Copy link
Author

Looks nice, but you still have to work out dependencies with foreach and maybe some name conflicts. I haven't tried that, but I may give that another try!

Feel free to close his PR.

@vitaut
Copy link
Owner

vitaut commented Jul 26, 2023

Closing then but thanks for working on this anyway!

@vitaut vitaut closed this Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants