Search code examples
c++clang++c++-modulesbuild2

build2: compiler does not support modules


I can build c++ projects without c++ modules with build2, but when i try to configure and use build2 with c++ modules, I have "compiler does not support modules" error.

I'm sure my compiler is capable of building modules, because I can manually build using these commands:

clang++ --std=c++17 -fmodules-ts --precompile foo.cppm -o foo.pcm
clang++ --std=c++17 -fmodules-ts --precompile foo2.cppm -o foo2.pcm
clang++ --std=c++17 -fmodules-ts -c foo.pcm -o foo.o
clang++ --std=c++17 -fmodules-ts -c foo2.pcm -o foo2.o
clang++ --std=c++17 -fmodules-ts -fprebuilt-module-path=. foo.o foo2.o bar.cpp

Version of my clang is 7.0.0:

$ clang++ --version
clang version 7.0.0- (trunk)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

To enable modules support in build2 I added following lines to root buildfile:

cxx.std = experimental

using cxx

assert $cxx.features.modules 'compiler does not support modules'

mxx{*}: extension = mxx
cxx{*}: extension = cxx

What can be wrong? It's my first time with build2, so I can be missing something very simple.


Solution

  • Managed it to work.

    As I understand the problem was that I changed buildfile, but should use build/root.build instead.