Skip to content

Enable modulemaps for being able to use module mode of cling in CppInterOp - #144

Closed
keremsahn wants to merge 1 commit into
compiler-research:mainfrom
keremsahn:module-fix
Closed

keremsahn wants to merge 1 commit into
compiler-research:mainfrom
keremsahn:module-fix

Conversation

@keremsahn

@keremsahn keremsahn commented Oct 10, 2026 •

Copy link
Copy Markdown

Cling cannot use -fmodules after cmake --install.
libstdc++ and glibc do not supply modulemaps. cling supplies its own. But its install rule does not copy .modulemap files.
https://github.com/root-project/cling/blob/1807a1e6f8819029e0931e8c829de794db60f71f/CMakeLists.txt#L405-L413
And without modulemaps this PR introduces, cling can not work in module mode.

So we are copying these modulemaps into an etc/Interpreter directory as ROOT does, https://github.com/root-project/root/blob/3de9c792f4c8594f6a360e18b7b604c06879439c/core/clingutils/CMakeLists.txt#L158-L180

The PR is linux limited, the problem itself and the way ROOT handles it were different for macos and microsoft

@vgvassilev

cmake --build . --parallel "${ncpus}"
cmake --install .

# Stage cling's runtime headers and modulemaps as ROOT,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why cmake install does not install them?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

.modulemap files in the source tree are not installed https://github.com/root-project/cling/blob/1807a1e6f8819029e0931e8c829de794db60f71f/CMakeLists.txt#L406-L413 check here there
is no .modulemap extension. Moreover, adding *.modulemap is not enough, because there are two module.modulemap, one is for cling's own way to include its own compile time headers
(the headers include llvm), other for being able to support using modules with cling, which is named module.modulemap.build and it is renamed to the module.modulemap later. So if we
just add *.modulemap to the cmake list, it will lead to install wrong modulemap.

How ROOT solves it: https://github.com/root-project/root/blob/master/core/clingutils/CMakeLists.txt#L158 it installs other necessary .modulemap files while excluding
module.modulemap(cling's compile time headers),

https://github.com/root-project/root/blob/master/core/clingutils/CMakeLists.txt#L171
Later, installs and renames module.modulemap.build (Runtime module) . So either we change cling code, or install these in CI manually.

@keremsahn keremsahn Oct 12, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I just duplicated ROOT's code but seems like we do not need to install runtime headers, the reason cling installs them is to build a .pch for runtime headers, so probably it is enough to install necessary .modulemap files

@keremsahn keremsahn closed this Oct 12, 2026
@keremsahn keremsahn reopened this Oct 12, 2026
@keremsahn keremsahn closed this Oct 17, 2026
@vgvassilev

Copy link
Copy Markdown
Contributor

Is that not needed anymore?

@keremsahn

Copy link
Copy Markdown
Author

Is that not needed anymore?

Yes we solved it on Cling side

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