Skip to content

Module updates - #717

Open
justend29 wants to merge 8 commits into
boost-ext:masterfrom
justend29:module-updates
Open

justend29 wants to merge 8 commits into
boost-ext:masterfrom
justend29:module-updates

Conversation

@justend29

@justend29 justend29 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem:

Further use of my previous fixes to the C++ module installation rules revealed a few improvements.

  1. Installed Boost::ut_module couldn't be consumed with Clang

    The compilation flags added in WarningsAsErrors.cmake for development leaked into the install
    interface of the Boost::ut and Boost::ut_module targets, inheriting these aggressive flags.
    When using import std, Clang warns about the reserved module name std when compiling std.cc
    from libstdc++ or libc++. With warnings treated as errors, Clang's warningerror about the
    reserved module name prevented Boost::ut_module from being consumed, as it requires compiling
    std.cc. Where Boost::ut was interface-only, these leaky flags wouldn't have an effect, and be easily missed.

    Clang Warning
    [102/199] Building CXX object 'CMakeFiles/@cmake_cxx_std.dir/usr/share/libc++/v1/std.cppm.o'
    /usr/share/libc++/v1/std.cppm:163:15: warning: 'std' is a reserved name for a module [-Wreserved-module-identifier]
      163 | export module std;
          |               ^
    1 warning generated.
    [103/199] Building CXX object 'CMakeFiles/@cmake_cxx_std.dir/usr/share/libc++/v1/std.compat.cppm.o'
    /usr/share/libc++/v1/std.compat.cppm:80:15: warning: 'std' is a reserved name for a module [-Wreserved-module-identifier]
       80 | export module std.compat;
          |               ^
    1 warning generated.
  2. examples/parallel_runner failed to build with Clang

    Tons of linker errors for TBB showed up with clang because parallel_runner was disabled for other compilers. libstdc++
    requires TBB to use <execution>, and the link was missing.

  3. Clang warns when angled includes are used in modules.

    The previous PR linked Boost::ut to Boost::ut_module to propagate target properties, including INTERFACE_INCLUDE_DIRECTORIES for header ut.hpp. With this, angled includes were added in ut.cppm, as the public header could be correctly resolved.

    Clang Warning
      [15/35] Building CXX object 'CMakeFiles/Boost__ut_module@synth_0.dir/Debug/440d59585f59.bmi'
      /home/justen/pers-proj/liborbit/build-clang/vcpkg_installed/triplet-clang/include/boost/ut.cppm:12:10: warning: '#include <filename>' attaches the declarations to the named module 'boost.ut', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
         12 | #include <boost/ut.hpp>
            |          ^
      1 warning generated.

Solution:

  1. Wrap the compilation flags for development in the $<BUILD_INTERFACE:> generator expression.
    Another option would be to PRIVATEly add them to each compiled target with
    target_compile_options(<target> PRIVATE <flags>) instead of top-town with
    add_compile_options(<flags>)

  2. Link TBB when using libstdc++. TBB has a config-file (TBBConfig.cmake). A simple find_package() does the trick.

  3. <boost/ut.hpp> -> "boost/ut.hpp"

    Use quotes to please Clang. Preserve the "boost/" include prefix, as just "ut.hpp" will fail to match system include paths in consuming projects, and emit compiler warnings from the third-party ut.hpp header.

Testing

A full build and test (including from-ut-module) succeeds using GCC + libstdc++, Clang + libstdc++, and Clang + libc++. examples/parallel_runner runs for each of them, too.

Reviewers:
@kris-jusiak

@justend29
justend29 marked this pull request as draft October 6, 2026 17:32
@justend29
justend29 marked this pull request as ready for review October 6, 2026 17:57

This branch has not been deployed

No deployments
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.

1 participant