Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression with -o when compiling C files #10610

Closed
nojb opened this issue Sep 6, 2021 · 11 comments
Closed

Fix regression with -o when compiling C files #10610

nojb opened this issue Sep 6, 2021 · 11 comments
Assignees
Milestone

Comments

@nojb
Copy link
Contributor

nojb commented Sep 6, 2021

A friendly reminder that we shouldn't forget about this regression introduced in #9960 that needs to be fixed before 4.13 is released.

There are two issues with this patch:

  1. It broke previous behaviour of ocaml when you don't pass -o:
(before) ocamlc foo.c --> calls "$cc -c foo.c"
(after) ocamlc foo.c --> calls "$cc -o foo.o -c foo.c"

This causes problems when people use:

ocamlc -ccopt '-o whatever' foo.c

which was necessary before this PR.

  1. The -o flag to ocaml{c,opt} is ignored if -c is not passed as well when compiling C files.

Originally posted by @nojb in #9960 (comment)

cc @shindere

@nojb nojb added this to the 4.13 milestone Sep 6, 2021
@shindere
Copy link
Contributor

shindere commented Sep 6, 2021 via email

@shindere
Copy link
Contributor

shindere commented Sep 8, 2021 via email

@nojb
Copy link
Contributor Author

nojb commented Sep 8, 2021

Would somebody please be kind enough and fix that?

Fixed.

@Octachron
Copy link
Member

@nojb concerning your second point, as far as I can see, this behavior has been constant since at least OCaml 4.04? In particular,

ocamlopt -o exe a.c b.ml

generates an executable named exe.

@nojb
Copy link
Contributor Author

nojb commented Sep 8, 2021

@nojb concerning your second point, as far as I can see, this behavior has been constant since at least OCaml 4.04? In particular,

Indeed, that seems to be the case...

@shindere
Copy link
Contributor

shindere commented Sep 8, 2021 via email

@Octachron
Copy link
Member

The issue is that without -c the object file is not the final target of the compilation command, and thus

ocamlc -o anything hello.c

generates hello.o since at least OCaml 4.00.

@shindere
Copy link
Contributor

shindere commented Sep 8, 2021 via email

@gasche
Copy link
Member

gasche commented Sep 8, 2021

Would it be possible to have tests in the testsuite for the behaviors that we have decided to preserve?

@Octachron
Copy link
Member

It does not seem trivial to add test for the C compilation command, but it might it be a good idea on the medium term.

Since #10619 fixed the regression with out-of-thin-air -o flag, I am closing this specific issue. @nojb , do you think that the not obvious behavior with ocamlc -o anything hello.c warrants an issue?

@nojb
Copy link
Contributor Author

nojb commented Sep 9, 2021

@nojb , do you think that the not obvious behavior with ocamlc -o anything hello.c warrants an issue?

Done! #10625

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

No branches or pull requests

4 participants