Clarify the use of C compiler related variables in the build system.#911
Conversation
|
I don't think this should be merged as-is since it would change many things for users of the compiler. The fact is that today, all libraries are built with $bytecccompopts and dropping these options can impact all of them In particular, options such as -fno-strict-aliasing and -fwrapv can have an impact on the code that is included in ocaml headers with e.g. macros (I haven't checked but it /is/ a possibility). Moreover, flags such as -O2 and -Wall are useful to provide to the build of libraries. I concur it is better to have compiler-specific options and the current state has bitten me too in the past but we also probably want to keep default ones for the libraries too. Even for C stubs we probably don't want to authors to have to think too much about C and its constraints. Lastly, there can be ABI issues and for instance config/Makefile.mingw{,w64} use {BYTE,NATIVE}CCCOMPOPTS to pass -mms-bitfields which has an impact on ABI; no OCaml library author should have to think about this or everything will break. (NB: -mms-bitfields has been the default for some time for mingw ports but it doesn't harm and it's more work to make it conditional on the compiler versions that really need it) I would probably introduce a new COMPILERCOMPOPTS or something like that in order to hold the compiler-specific flags such as -DCAML_NAME_SPACE. |
|
Many thans for your prompt and detailed comment, @adrien-n.
If certain options are considered important to keep when compiling
libraries, perhaps they could be moved from BYTECCCOMPOPTS to BYTECC(*),
and similarly for the native compiler, rather than adding yet another
variable? Especially given that "COMPOPTS" could already be understood
as meaning "compiler options", i.e. options to use when compiling
the compiler.
"Moreover, flags such as -O2 and -Wall are useful to provide to +the
build of libraries.": I don't know. Not sure it is good to impose them.
I think -Wall for instance was part of the flags @damiendoligez found
not right to enforce over third-party code, please Damien correct me
if I am wrong on this.
(*) BYTECC and NATIVECC do actually already contain options, e.g. on
the msvc port.
|
|
Adding the options in another variable or in BYTECC and NATIVECC should lead to the same result. As such I have no opinion on which one should be done over the other. As for -O2 and -Wall, my current concern is that the various build systems for ocaml and the compiler itself haven't really shined when it comes to passing options to the C compiler. I would prefer that this is improved before the set of flags changes. |
3d6144c to
086b546
Compare
|
The PR has been rebased and updated to take your comments into account, Most options are passed to C compilers. @alainfrisch: the SHAREDCCCOMPOPTS variable contained the -O option on the |
I guess this is ok, but this will change (silently) how C user code is compiled, no? |
086b546 to
d419a1a
Compare
|
Alain Frisch (2016/11/15 05:44 -0800):
On the MinGW port the -O option is already present in the BYTECC For the msvc port, there is already a -O2 present in BYTECC, so without |
@dra27 Do you have an opinion? |
|
It should possibly be explicitly highlighted in Changes but, realistically, this would only be being used for C stubs in user code, surely? So I can't think optimisation levels are likely to be that critical (both in terms of code generated and code emitted) - so why not go with -Ox? |
|
One reason for not doing it could be the lack of coherence with gcc
where it is -O2 (rather than a higher level) which is used, but if there
is an agreement on -Ox I will be happy to update the PR.
|
|
For reference, using |
|
Thanks, @gasche.
So is there anything you would like me to change?
|
|
I have no competence to review the PR in general, but on the specific choice of O2/Ox, MPR#6590 seems to suggest that |
|
I guess the key thing is whether the testsuite has been fixed subsequently, or whether the
Given that Appveyor's passing (and we've released two versions of OCaml since based on this), it would seem that Bear in mind when looking for comparisons with gcc that |
|
Looks good to me but note I can't say much about the MSVC part. My only question is whether we have (roughly) equivalent warning flags between MSVC and others (others have -Wall -Wno-unused, MSVC has nothing) but that's very minor. |
|
Wowzers - I thought that might happen! There's a reason that -Wall is not used in the MSVC ports 😄. There's quite a list of warnings which would need to be gone through and turned off! |
|
David Allsopp (2016/11/15 10:05 -0800):
Thanks a lot for having tested, David! Going through those warnings, trying to fix them etc. is definitely on And many thanks for the warnings you have suggested, will start from Will also use your suggestion for optimization options. You mentionned testsuite failures. What were you refering to, exactly? |
|
The Mantis report mentioned testsuite failures - but I think these were fixed by the addition of |
…les.
Before this commit, there was no distinction between the options
used to compile C source files coming with the OCaml distribution
and third-party C source files compiled by calling ocamlc or ocamlopt.
This commit makes it possible to use options when compiling C source
files that come with OCaml without imposing these options to the compilation
of third-party code.
More specifically, the options in the BYTECCCOMPOPTS and NATIVECCCOMPOPTS
variables are not passed to the C compiler when called by ocamlc and
ocamlopt any longer.
This commit also documents the role of each concerned variable.
In addition:
- On Unix:
* The -Wall and -Werror options are no longer passed to the C
compiler by ocamlc and ocamlopt for third-party C source files
- For the MinGW port:
* The -O option has been removed from the SHAREDCCCOMPOPTS variable
* The -Wall and -Wno-unused options are no longer passed to the C
compiler by ocamlc and ocamlopt for third-party C source files
- For the msvc port: the
* The -Ox option has been removed from the SHAREDCCCOMPOPTS variable.
* The -Wall and -Wno-unused options are no longer passed to the C
compiler by ocamlc and ocamlopt for third-party C source files
d419a1a to
3e81da2
Compare
|
Many thanks for your contributions, everybody.
Actually -O2 and -Gy- are what the PR already defines so my
understanding is that our last exchanges do not require any further
modification of the PR. Please let me know if I am wrong on this.
For the moment I just rebased it on latest trunk.
|
|
adrien-n (2016/11/15 09:10 -0800):
So just to make sure everything is written out clearly: no, at the |
|
Given that there seems to be a consensus, I went ahead and merged. Thanks! |
|
Thanks a lot, Gabriel! Hoping the best! :)
|
|
Moving towards using -W3 in the msvc ports is related to MPR#5079 |
Clarify the use of C compiler related variables in the build system.
… inside the handler of a recursive continuation (ocaml#911) * Increase occurrence counts within recursive continuation handlers * Set inner continuations uses of let rec to non-inlinable Co-authored-by: Vincent Laviron <[email protected]>
Co-authored-by: Sabine Schmaltz <[email protected]>
Cc @gasche @whitequark @alainfrisch @adrien-n @dra27
This PR is inspired by PR #892 and more specifically by David's
comment at #892 (comment)
So pr #892 DOES ACTUALLY DEPEND ON THIS ONE.
The part of the commit that modifies the makefiles has been reviewed
by @damiendoligez.
Comments will be warmly appreciated, especially regarding the documentation.