Skip to content

Use same cflags and cppflags for ocamlc -c and ocamlopt -c (#7678)#8631

Merged
dra27 merged 1 commit intoocaml:trunkfrom
dra27:unify--c
Apr 21, 2020
Merged

Use same cflags and cppflags for ocamlc -c and ocamlopt -c (#7678)#8631
dra27 merged 1 commit intoocaml:trunkfrom
dra27:unify--c

Conversation

@dra27
Copy link
Copy Markdown
Member

@dra27 dra27 commented Apr 20, 2019

Config.ocamlopt_cflags and Config.ocamlopt_cppflags were solely used by the driver when compiling .c files passed on the command line. The behaviour of this should be the same as for ocamlc -c and the
inclusion of -fPIC in ocamlc_cflags only on some systems causes problems for ocamlmklib which behaves as though the two drivers compile C files identically.

This PR eliminates the separate settings in configure.ac and deprecates the old variables in Config.

Closes #7678

Config.ocamlopt_cflags and Config.ocamlopt_cppflags were solely used by
the driver when compiling .c files passed on the command line. The
behaviour of this should be the same as for `ocamlc -c` and the
inclusion of `-fPIC` in `ocamlc_cflags` only on some systems causes
problems for `ocamlmklib` which behaves as though the two drivers
compile C files identically.

This PR eliminates the separate settings in configure.ac and deprecates
the old variables in Config.
@dra27
Copy link
Copy Markdown
Member Author

dra27 commented Apr 20, 2019

I have a recollection that merging OCAMLC_CFLAGS and OCAMLOPT_CFLAGS has been discussed before, but I can't remember what the conclusion was. Anyhow, as far as I can tell, the only way in which OCAMLOPT_CFLAGS and OCAMLOPT_CPPFLAGS were ever used was for the handling of .c files, so I think that this merging is safe.

@damiendoligez damiendoligez added this to the 4.09 milestone Sep 4, 2019
@Octachron Octachron modified the milestones: 4.09, 4.10 Sep 16, 2019
@dra27
Copy link
Copy Markdown
Member Author

dra27 commented Oct 19, 2019

Rebased, but still in need of a review if it's to go into 4.10

@shindere
Copy link
Copy Markdown
Contributor

shindere commented Oct 24, 2019 via email

@shindere
Copy link
Copy Markdown
Contributor

shindere commented Oct 25, 2019 via email

@Octachron
Copy link
Copy Markdown
Member

@dra27 what is the status of this PR? Do we only need to add the -fPIC option and it should be mergeable in 4.11 ? It seems a little late for 4.10 .

@shindere
Copy link
Copy Markdown
Contributor

shindere commented Feb 12, 2020 via email

@dra27
Copy link
Copy Markdown
Member Author

dra27 commented Apr 21, 2020

Sorry for dropping the ball on this one. It's rebased - on change is required, the point I was making is that -fPIC is now passed by ocamlopt (i.e. either both drivers will pass it or neither, if the compiler has been configured without shared library support).

This is good to go, assuming a CI pass, therefore.

@dra27
Copy link
Copy Markdown
Member Author

dra27 commented Apr 21, 2020

@Octachron - I marked this a "breaking change" because the native driver passes a flag which it didn't before. Do you agree with that designation, and should this therefore go in 4.10?

@shindere
Copy link
Copy Markdown
Contributor

shindere commented Apr 21, 2020 via email

@Octachron
Copy link
Copy Markdown
Member

If it is a breaking change, it cannot be backported to 4.10 .
If I read the change properly, the breaking scenario would be some code that somehow relies on the fact that ocamlc and ocamlopt compiles C files with different flags by default?

@dra27
Copy link
Copy Markdown
Member Author

dra27 commented Apr 21, 2020

Yes, indeed - the breaking change would be that something used ocamlopt -c foo.c relying on the fact that it doesn't include -fPIC. I'm not even sure that that would be an impact (producing non-PIC code when you need PIC is clearly a problem, but the reverse shouldn't ever be, right?)

@dra27 dra27 merged commit a7dbb97 into ocaml:trunk Apr 21, 2020
@dra27 dra27 deleted the unify--c branch April 21, 2020 13:16
@mshinwell
Copy link
Copy Markdown
Contributor

@dra27 There could be a performance implication. Although I think there is a general trend towards having to produce PIC code anyway even for executables.

@dra27
Copy link
Copy Markdown
Member Author

dra27 commented Apr 21, 2020

It sounds as though this should remain for 4.11 only, then.

shindere added a commit to shindere/ocaml that referenced this pull request May 11, 2024
shindere added a commit to shindere/ocaml that referenced this pull request May 27, 2024
To make it possible to instrument only native code, we need to have
two sets of flags to be passed to the C compiler, one when called
by ocamlc and one when called by ocamlopt.

This commit re-introduces this distinction by reverting
commit 2b4fe09, Submitted as PR ocaml#8631.
shindere added a commit to shindere/ocaml that referenced this pull request May 27, 2024
To make it possible to instrument only native code, we need to have
two sets of flags to be passed to the C compiler, one when called
by ocamlc and one when called by ocamlopt.

This commit re-introduces this distinction by reverting
commit 2b4fe09, Submitted as PR ocaml#8631.
shindere added a commit to shindere/ocaml that referenced this pull request May 30, 2024
To make it possible to instrument only native code, we need to have
two sets of flags to be passed to the C compiler, one when called
by ocamlc and one when called by ocamlopt.

This commit re-introduces this distinction by reverting
commit 2b4fe09, Submitted as PR ocaml#8631.
shindere added a commit to shindere/ocaml that referenced this pull request May 30, 2024
To make it possible to instrument only native code, we need to have
two sets of flags to be passed to the C compiler, one when called
by ocamlc and one when called by ocamlopt.

This commit re-introduces this distinction by reverting
commit 2b4fe09 (PR ocaml#8631).
shindere added a commit to shindere/ocaml that referenced this pull request May 30, 2024
To make it possible to instrument only native code, we need to have
two sets of flags to be passed to the C compiler, one when called
by ocamlc and one when called by ocamlopt.

This commit re-introduces this distinction by reverting
commit 2b4fe09 (PR ocaml#8631).
shindere added a commit to shindere/ocaml that referenced this pull request May 31, 2024
To make it possible to instrument only native code, we need to have
two sets of flags to be passed to the C compiler, one when called
by ocamlc and one when called by ocamlopt.

This commit re-introduces this distinction by reverting
commit 2b4fe09 (PR ocaml#8631).
shindere added a commit to shindere/ocaml that referenced this pull request Jun 3, 2024
To make it possible to instrument only native code, we need to have
two sets of flags to be passed to the C compiler, one when called
by ocamlc and one when called by ocamlopt.

This commit re-introduces this distinction by reverting
commit 2b4fe09 (PR ocaml#8631).
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.

ocamlc -c and ocamlopt -c differ for C files

5 participants