You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I spent an entire day to figure out that Bazel already supports modules.
Tip
Consider mention this fact in the README.
I found nothing about this in Bazel release notes, but here is confirmation from one of the contributors of this feature, and here is the demo repository by them demonstrating the usage.
I also succeeded with building C++23 std module without overridingrules_cc with some "under construction"1stuff or precompiling std.pcm manually as implied when using this fork2. Bellow are the instructions, maybe someone will find them useful.
Instructions
Find and symlink std.cppm's directory into source tree. On my system it is at /usr/lib/llvm-22/share/libc++/v1.
I spent an entire day to figure out that Bazel already supports modules.
Tip
Consider mention this fact in the README.
I found nothing about this in Bazel release notes, but here is confirmation from one of the contributors of this feature, and here is the demo repository by them demonstrating the usage.
I am successfully built the demo with Bazel 9.0.0 and Clang 22.0.0 from https://apt.llvm.org.
I also succeeded with building C++23
stdmodule without overridingrules_ccwith some "under construction"1 stuff or precompiling std.pcm manually as implied when using this fork2. Bellow are the instructions, maybe someone will find them useful.Instructions
Find and symlink std.cppm's directory into source tree. On my system it is at /usr/lib/llvm-22/share/libc++/v1.
Add
cc_library3 rule buildingstdmodule into BUILD.bazel file.Add
stdtarget as dependency for eachcc_binary/cc_library3 target that usesimport std;.Build and run the demo.
P.S. Top 5 "c++ std module bazel" results
Footnotes
I failed to build with override with the error very similar to "bazel build //example/..." fails with error: "could not build module 'std_config'" #15 (
__configis not found). ↩Compiling
stdmodule outside Bazel is quite strange solution. ↩Add
bazel_dep(name = "rules_cc", version = "0.2.16", dev_dependency = True)into MODULE.bazel to use the same version I used. ↩ ↩2