forked from ocaml/dune
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(library (extra_objects)): avoid double linking (ocaml#10783)
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
- Loading branch information
1 parent
8babdb4
commit 9475228
Showing
3 changed files
with
50 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- In a `(library)` stanza with `(extra_objects)` and `(foreign_stubs)`, avoid | ||
double linking the extra object files in the final executable. | ||
(#10783, @nojb) |
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
40 changes: 40 additions & 0 deletions
40
test/blackbox-tests/test-cases/extra-objects/extra-objects-indirect.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
---------------------------------------------------------------------------------- | ||
Build an library which indirectly depends on foreign object files. | ||
|
||
---------------------------------------------------------------------------------- | ||
* Building library with indirect dependency on object file | ||
|
||
$ echo "(lang dune 3.5)" > dune-project | ||
|
||
$ mkdir -p lib | ||
|
||
$ cat >lib/dune <<EOF | ||
> (library | ||
> (name calc) | ||
> (extra_objects add) | ||
> (foreign_stubs (language c) (names dep))) | ||
> EOF | ||
|
||
$ cat >lib/calc.ml <<EOF | ||
> external add : int -> int -> int = "add" | ||
> EOF | ||
|
||
$ cat >lib/dep.c <<EOF | ||
> #include <caml/mlvalues.h> | ||
> extern value add(value x, value y); | ||
> value dummy() { return add(Val_int(1), Val_int(2)); } | ||
> EOF | ||
|
||
$ cat >lib/add.c <<EOF | ||
> #include <caml/mlvalues.h> | ||
> value add(value x, value y) { return Val_int(Int_val(x) + Int_val(y)); } | ||
> EOF | ||
|
||
$ cat >>lib/dune <<EOF | ||
> (rule | ||
> (target add.o) | ||
> (deps add.c) | ||
> (action (run %{bin:ocamlc} add.c))) | ||
> EOF | ||
|
||
$ dune build |