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
mcpp's ninja backend previously routed every non-.cppm source through one
`cxx_object` rule that invokes g++ with `-std=c++23 -fmodules`. .c files
went through cc1plus, which rejects mainstream C constructs (implicit
`void*` conversion from malloc/calloc, the `restrict` keyword, ...) and
silently warns on `-std=c++23`. Real-world C libraries — verified against
mbedtls 3.6.1's 108 sources — cannot build under that path.
Add a parallel C compile path:
* `BuildConfig` gains `cflags`, `cxxflags`, `cStandard`. Both the
`[build]` TOML section and the `mcpp = {}` xpkg segment parse them, so
index entries can carry per-package flags.
* The ninja backend probes the plan for `.c` sources; when present it
derives a sibling C compiler from the resolved C++ binary
(`g++ -> gcc`, `clang++ -> clang`, `c++ -> cc`, with prefix
preserved for cross toolchains like `x86_64-linux-musl-gcc`) and
emits `cc` / `cflags` / `c_object` alongside the existing `cxx_*`
set. `cflags` carries `-std=$c_standard` (default `c11`) plus the
shared opt / pic / sysroot / -B / include baseline and the user
tail.
* Compile-edge dispatch picks `cxx_module` for `.cppm`, `c_object` for
`.c`, and `cxx_object` otherwise. dyndep phase-1 skips `.c` so they
don't go through P1689 / `-fmodules`; the static-deps fallback skips
BMI implicit inputs for the same reason.
* Module scanner short-circuits `.c` files with an empty `SourceUnit`
to avoid any chance of a benign C identifier
(`import_foo`, `module_t`) being misparsed as a module statement.
Coverage: two unit tests in `test_manifest.cpp` cover both parse paths,
and a new `tests/e2e/26_c_language_support.sh` scaffolds a mixed
`.c` + modular-`.cpp` project, asserts the generated `build.ninja`
contains the expected `c_object` rule / `cc` variable / extension
dispatch, exercises user-supplied `cflags`/`cxxflags` forwarding, and
runs the resulting binary end-to-end.
0 commit comments