-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4088 from MisterDA/configurator-c-libraries
Always link the c_libraries in the configurator build command
- Loading branch information
Showing
6 changed files
with
62 additions
and
5 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
26 changes: 26 additions & 0 deletions
26
test/blackbox-tests/test-cases/configurator-c-libraries.t/discover.ml
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,26 @@ | ||
module C = Configurator.V1 | ||
|
||
let unix = {| | ||
#include <math.h> | ||
void *addr = &sin; | ||
int main(void) { | ||
return 0; | ||
} | ||
|} | ||
|
||
let windows = {| | ||
#include <winsock2.h> | ||
void *addr = &gethostname; | ||
int main(void) { | ||
return 0; | ||
} | ||
|} | ||
|
||
let main c = | ||
let code = if Sys.os_type = "Win32" then windows else unix in | ||
let b = C.c_test c code in | ||
let f = open_out_bin "out" in | ||
output_char f (if b then '1' else '0'); | ||
close_out f | ||
|
||
let () = C.main ~name:"configurator-c-libraries" main |
3 changes: 3 additions & 0 deletions
3
test/blackbox-tests/test-cases/configurator-c-libraries.t/dune
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 @@ | ||
(executable | ||
(name discover) | ||
(libraries dune.configurator)) |
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/configurator-c-libraries.t/dune-project
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 @@ | ||
(lang dune 2.8) |
13 changes: 13 additions & 0 deletions
13
test/blackbox-tests/test-cases/configurator-c-libraries.t/run.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,13 @@ | ||
Test that configurator always picks the value of the `c_libraries` | ||
flag from `ocamlc -config`. If not, there's a failure to link a | ||
configuration test program that uses functions from these libraries. | ||
For that, we need functions outside of libc. On Unix, that would be | ||
`sin(3)` that requires the `-lm` flag for the math library, and on | ||
Windows `gethostname` that requires WinSock2 (`ws2_32.dll`). | ||
link successfully | ||
================================== | ||
$ dune exec -- ./discover.exe | ||
$ cat out | ||
1 |