Skip to content

feat(cc): align C compiler vendor detection with the OCaml compiler#15423

Merged
Alizter merged 1 commit into
ocaml:mainfrom
chizy7:fix/cc-vendor-align
Jul 6, 2026
Merged

feat(cc): align C compiler vendor detection with the OCaml compiler#15423
Alizter merged 1 commit into
ocaml:mainfrom
chizy7:fix/cc-vendor-align

Conversation

@chizy7

@chizy7 chizy7 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #14870.

Dune detected the C/C++ compiler vendor with a coarser vocabulary than the OCaml compiler's own OCAML_CC_VENDOR macro (ocaml/aclocal.m4). It recognized only msvc/clang/gcc/other and emitted a "please open an issue" warning for compilers the compiler already names.

What changed

  • The detection probe now mirrors OCAML_CC_VENDOR's ordered #if ladder and identifiers: msvc, icc, mingw, clang, gcc, xlc, sunc, unknown.
  • cc_vendor now includes: Gcc | Clang | Msvc | Mingw | Intel | Xlc | Sun | Other.

ocamlc -config does not expose c_compiler_vendor, so dune keeps its own preprocessor probe. Only the detection table, parser, and vendor type changed.

Testing

Added a pure-function expect test covering every vendor word. The existing foreign-stubs/cxx-flags.t still passes unchanged.

Two points I'd like a call on

  1. mingw-clang link flags now use -lstdc++ instead of -lc++. I believe this is the correct behavior since MinGW ships GNU libstdc++, but wanted to call it out because it changes behavior.
  2. xlc/sunc are now recognized but remain flag-neutral. I avoided adding compiler-specific flags that I couldn't test.

Signed-off-by: Chizaram Chibueze <chizy7@gmail.com>
@chizy7 chizy7 marked this pull request as draft July 5, 2026 15:22
@rgrinberg

Copy link
Copy Markdown
Member

Looks good at first glance. @MisterDA or @nojb could you look this over as well?

@nojb

nojb commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Does this change have any user-visible effect?

@chizy7

chizy7 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Mostly no. gcc, clang, msvc, mingw-gcc, and icc all get the same flags as before.

Two exceptions:

  1. xlc/sunc used to hit the "please open an issue" warning on every build. They're now recognized, so the warning no longer apears (flags remain unchanged).

  2. mingw-clang now links against -lstdc++ instead of -lc++, which is the behavior change I noted above

@chizy7 chizy7 marked this pull request as ready for review July 5, 2026 18:14

@nojb nojb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested, but LGTM

@Alizter Alizter merged commit fbdedfe into ocaml:main Jul 6, 2026
30 checks passed
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.

Detect C vendor as compiler does

4 participants