Skip to content

[RFC] Rationalize C compiler flags #3718

@voodoos

Description

@voodoos

The present situation

In order to make things clearer I tried to retrace the processing of the C compilation flags, here is what I got:
(you can click to enlarge the image)

c_flags

Please tell me if I forgot something or misunderstood part of it.

What is wrong

  • ocamlc_cflags can end duplicated in the compiler command-line (if :standard was passed all the way down)
  • Dune silently adds ocamlc_cflags + ocamlc_cppflags to the command line making the :standard set of flags SC.default_c_cxx_flags irrelevant. This was unavoidable before because dune was calling ocamlc to compile C code.
  • The CC variable will always miss the ocamlc_cppflags and sometimes the ocamlc_cflags if the standard value was discarded, while these are in fact part of the compiler command line.

Proposition

Stop adding silently the flags from the config. These should be present in the :standard field and the users should be reminded that they need to use :standard when they want to add flags to the default set. This was not possible when dune was calling ocamlc to build C code but it is now that the C compiler is directly summoned.

This would solve the previous problem:

  • No more duplication of flags
  • The CC variable would really contain the base set of flags used for compiling
  • Users will be in total control of the flags set

The new flow would be:
new_c_flags

Of course this change will break some projects in which the :standard set of flags was overridden by the user. So we should add an option to the dune-project file for users that want to use the new system before 3.0.

Metadata

Metadata

Assignees

Labels

proposalRFC's that are awaiting discussion to be accepted or rejected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions