Extend -o to work when compiling C files#9960
Merged
gasche merged 1 commit intoocaml:trunkfrom Jan 6, 2021
Merged
Conversation
Octachron
reviewed
Oct 13, 2020
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"; |
Member
There was a problem hiding this comment.
Shouldn't this case should be combined with the one below to reject
ocamlopt -c a.c b.ml -o something?
Contributor
Author
|
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.
|
Contributor
Author
|
Is there anything that prevents this from being approved / merged? Would be happy to fix any remaining issue. |
gasche
approved these changes
Jan 5, 2021
Member
gasche
left a comment
There was a problem hiding this comment.
The code looks good and the feature is useful.
The change needs a Changes entry.
Contributor
Author
|
Many thanks for your prompt response and approval, @gasche.
The PR has been rebased on latest trunk and a Changes entry added.
|
Member
|
Thanks! |
Contributor
Author
|
Gabriel Scherer (2021/01/05 04:18 -0800):
Thanks! `check-typo` complains:
[...]
Gosh. Sorry, and thanks. Fixed.
|
Member
|
|
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.
Contributor
Author
|
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.
|
Contributor
Author
|
Gabriel Scherer (2021/01/06 00:07 -0800):
Merged #9960 into trunk.
Great! Thanks!
|
This was referenced Jan 6, 2021
Contributor
|
There are two issues with this patch:
This causes problems when people use: which was necessary before this PR.
|
Octachron
added a commit
that referenced
this pull request
Sep 9, 2021
Fix regression introduced by #9960
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-existsaction 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