-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend -o to work when compiling C files
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.
- Loading branch information
Showing
12 changed files
with
92 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,5 @@ val run : Actions.t | |
val script : Actions.t | ||
|
||
val check_program_output : Actions.t | ||
|
||
val file_exists : Actions.t |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main() | ||
{ | ||
printf("Hello, world!\n"); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(* TEST | ||
files = "hello.c" | ||
* setup-ocamlopt.opt-build-env | ||
** script | ||
script = "mkdir outputdir" | ||
*** ocamlopt.opt | ||
all_modules = "hello.c" | ||
compile_only = "true" | ||
flags = "-o outputdir/hello.${objext}" | ||
**** file-exists | ||
file = "outputdir/hello.${objext}" | ||
*) | ||
|
||
(* | ||
This test makes sure it is possible to specify the name of the output | ||
object file when compiling a C file with the OCaml compiler. | ||
The test does not need to contain any OCaml code. | ||
*) |
1 change: 1 addition & 0 deletions
1
testsuite/tests/tool-command-line/test-o-several-files.compilers.reference
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Options -c -o are incompatible with compiling multiple files |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(* TEST | ||
* setup-ocamlopt.opt-build-env | ||
** ocamlopt.opt | ||
all_modules = "foo.c bar.c" | ||
compile_only = "true" | ||
flags = "-o outputdir/baz.${objext}" | ||
ocamlopt_opt_exit_status = "2" | ||
*** check-ocamlopt.opt-output | ||
*) | ||
|
||
(* | ||
This test makes sure that the -o option is rejected when trying to | ||
compile several C files during the same invocatin of the OCaml compiler. | ||
The test does not need to contain any OCaml code. | ||
*) |
File renamed without changes.
This file contains 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