Dear ROOT-Team,
I started to investigate cxxmodules and ran into a compilation error for a simple example built with CMake.
I add parts of the CMakeLists.txt
below, but you can find the whole reproducer at [1] and attached as an archive to this post.
# CMakeLists.txt
...
add_executable(myapp main.cc)
target_link_libraries(myapp ROOT::RIO)
ROOT_GENERATE_DICTIONARY(myapp_dict
functor.h
MODULE myapp
LINKDEF LinkDef.h
OPTIONS --cxxmodule)
...
Build the example with:
git clone https://github.com/LukasBreitwieser/ROOT-cxxmodule-reproducer.git
# or by extracting ROOT-cxxmodule-reproducer.zip
cd ROOT-cxxmodule-reproducer
mkdir build && cd build
cmake .. && make
Here the complete build output including the error on ubuntu 22.04 with ROOT 6.28/04:
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/lukas/ROOT-cxxmodule-reproducer/build
[ 25%] Generating myapp_dict.cxx, libmyapp_rdict.pcm, libmyapp.rootmap
/home/lukas/ROOT-cxxmodule-reproducer/build/module.modulemap:3:31: error: cannot emit module myapp: size must be explicitly specified for missing header file "functor.h"
module "functor.h" { header "functor.h" export * }
^
/home/lukas/ROOT-cxxmodule-reproducer/build/module.modulemap:3:31: error: cannot emit module myapp: size must be explicitly specified for missing header file "functor.h"
[ 25%] Generating myapp_dict.cxx, libmyapp_rdict.pcm, libmyapp.rootmap
/home/lukas/ROOT-cxxmodule-reproducer/build/module.modulemap:3:31: error: cannot emit module myapp: size must be explicitly specified for missing header file "functor.h"
module "functor.h" { header "functor.h" export * }
^
/home/lukas/ROOT-cxxmodule-reproducer/build/module.modulemap:3:31: error: cannot emit module myapp: size must be explicitly specified for missing header file "functor.h"
[ 50%] Building CXX object CMakeFiles/myapp_dict.dir/myapp_dict.cxx.o
[ 50%] Built target myapp_dict
[ 75%] Building CXX object CMakeFiles/myapp.dir/main.cc.o
[100%] Linking CXX executable myapp
[100%] Built target myapp
Here the rootcling call that errors out (copied from make VEBOSE=1
):
/home/lukas/programs/root/bin/rootcling -v2 -f myapp_dict.cxx \
-s /home/lukas/ROOT-cxxmodule-reproducer/build/libmyapp.so \
-rml libmyapp.so -rmf /home/lukas/ROOT-cxxmodule-reproducer/build/libmyapp.rootmap \
--cxxmodule \
-compilerI/usr/include/c++/11 \
-compilerI/usr/include/x86_64-linux-gnu/c++/11 \
-compilerI/usr/include/c++/11/backward \
-compilerI/usr/lib/gcc/x86_64-linux-gnu/11/include \
-compilerI/usr/local/include \
-compilerI/usr/include/x86_64-linux-gnu \
-compilerI/usr/include \
-compilerI/usr/lib/gcc/x86_64-linux-gnu/11/include \
-compilerI/usr/local/include \
-compilerI/usr/include/x86_64-linux-gnu \
-compilerI/usr/include \
-I/home/lukas/programs/root/include \
-I/home/lukas/ROOT-cxxmodule-reproducer \
-I/home/lukas/programs/root/include \
functor.h \
/home/lukas/ROOT-cxxmodule-reproducer/LinkDef.h
functor.h
is stored in /home/lukas/ROOT-cxxmodule-reproducer
, which is given as an include directory, so cling should find the header.
I also tried setting the ROOT_INCLUDE_PATH
environment variable, but to no avail.
Can you confirm that this is a bug of rootcling
, or did I miss something?
I found a workaround by setting the path of functor.h
in module.modulemap
relative to the build directory. (Uncomment the last four lines in CMakeLists.txt
to try it out.)
However, I am unsure of the implications. Does this mess things up in the generated pcm that will only show up for more complex examples, e.g. with multiple modules?
Many thanks in advance for your help!
Lukas
[1] LukasBreitwieser/ROOT-cxxmodule-reproducer · GitHub
ROOT Version: 6.28/04 (Binaries from the root website)
Platform: Ubuntu 22.04
Compiler: g++ 11.3.0
ROOT-cxxmodule-reproducer.zip (2.0 KB)