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
Extend -o to work when compiling C files #9960
Conversation
driver/compenv.ml
Outdated
if List.length (List.filter (function | ||
| ProcessCFile _ -> true | ||
| _ -> false) !deferred_actions) > 1 then | ||
fatal "Option -o makes no sense when compiling several C files"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this case should be combined with the one below to reject
ocamlopt -c a.c b.ml -o something
?
Florian Angeletti (2020/10/13 01:16 -0700):
Shouldn't this case should be combined with the one below to reject
```ocaml
ocamlopt -c a.c b.ml -o something
```
?
That was definitely a good idea, many thanks for the suggestion.
The PR has been rebased on latest trunk and updated accordingly.
|
Is there anything that prevents this from being approved / merged? Would be happy to fix any remaining issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good and the feature is useful.
The change needs a Changes entry.
Many thanks for your prompt response and approval, @gasche.
The PR has been rebased on latest trunk and a Changes entry added.
|
Thanks!
|
Gabriel Scherer (2021/01/05 04:18 -0800):
Thanks! `check-typo` complains:
[...]
Gosh. Sorry, and thanks. Fixed.
|
|
When using ocamlc/ocamlopt to compile C files, it was not possible so far to control where the resulting object file should be written. In other words, before this commit a command like ocamlopt -c foo.c -o /tmp/foo.o produced the following error message: Options -c and -o are incompatible when compiling C files This commit removes this restriction and lets the compiler accept that the command-line options -c and -o are given simultaneously also when compiling one C file, so that the previous command now works. The -o command-line option remains forbidden when compiling several source files.
Gabriel Scherer (2021/01/05 08:48 -0800):
`check-typo` is still complaining in the same way, are you sure that
you pushed your fixing change?
They should be there now. Sorry.
|
Gabriel Scherer (2021/01/06 00:07 -0800):
Merged #9960 into trunk.
Great! Thanks!
|
There are two issues with this patch:
This causes problems when people use:
which was necessary before this PR.
|
Fix regression introduced by #9960
This PR fixes issue #7677.
When using ocamlc/ocamlopt to compile C files, it is currently not possible
to control where the C compiler should place the resulting object file.
In other words, without this PR, a command like
produced the following error message:
Options -c and -o are incompatible when compiling C files
This PR removes this restriction and lets the compiler accept
that the command-line options -c and -o are given simultaneously
also when compiling one C file, so that the previous command now works.
The -o command-line option remains however forbidden when compiling
several C files during the same compiler invocation.
The PR includes tests to ensure the compiler behaves as expected when
only one C file is provided on the command-line and when several
of them are provided.
A
file-exists
action has been added to ocamltest to make testing for thepresence of the object file easier.
The code has been tested with precheck, see build
##521.
Cc @dbuenzli