Merge pull request #9212 from kit-ty-kate/fix-dynlink
Fix access to C symbols when using Dynlink (cherry picked from commit c67990cedea7932b5b1a877c1479c9b7b9f910da)master
parent
780f175895
commit
50da1ce8c3
|
@ -0,0 +1,63 @@
|
|||
(* TEST
|
||||
|
||||
include dynlink
|
||||
files = "lib.ml lib2.ml test.c"
|
||||
ld_library_path += "${test_build_directory}"
|
||||
|
||||
* shared-libraries
|
||||
** setup-ocamlc.byte-build-env
|
||||
*** ocamlc.byte
|
||||
compile_only = "true"
|
||||
all_modules = "lib.ml lib2.ml test.c dyn.ml"
|
||||
**** ocamlmklib
|
||||
program = "lib"
|
||||
modules = "lib.cmo test.${objext}"
|
||||
compile_only = "false"
|
||||
***** ocamlc.byte
|
||||
program = "lib2.cma"
|
||||
libraries = ""
|
||||
all_modules = "lib2.cmo"
|
||||
compile_only = "false"
|
||||
flags = "-a"
|
||||
****** ocamlc.byte
|
||||
libraries += "dynlink"
|
||||
program = "${test_build_directory}/main.exe"
|
||||
all_modules = "dyn.cmo"
|
||||
flags = ""
|
||||
******* run
|
||||
output = "main.output"
|
||||
******** check-program-output
|
||||
|
||||
** native-dynlink
|
||||
*** setup-ocamlopt.byte-build-env
|
||||
**** ocamlopt.byte
|
||||
compile_only = "true"
|
||||
all_modules = "lib.ml lib2.ml test.c dyn.ml"
|
||||
***** ocamlmklib
|
||||
program = "test"
|
||||
modules = "test.${objext}"
|
||||
compile_only = "false"
|
||||
****** ocamlopt.byte
|
||||
program = "lib.cmxs"
|
||||
libraries = ""
|
||||
flags = "-shared -cclib -L. -cclib -ltest"
|
||||
all_modules = "lib.cmx"
|
||||
compile_only = "false"
|
||||
******* ocamlopt.byte
|
||||
program = "lib2.cmxs"
|
||||
all_modules = "lib2.cmx"
|
||||
compile_only = "false"
|
||||
flags = "-shared"
|
||||
******** ocamlopt.byte
|
||||
libraries += "dynlink"
|
||||
program = "${test_build_directory}/main.exe"
|
||||
all_modules = "dyn.cmx"
|
||||
flags = ""
|
||||
********* run
|
||||
output = "main.output"
|
||||
********** check-program-output
|
||||
*)
|
||||
let () =
|
||||
Dynlink.allow_unsafe_modules true;
|
||||
Dynlink.adapt_filename "lib.cma" |> Dynlink.loadfile;
|
||||
Dynlink.adapt_filename "lib2.cma" |> Dynlink.loadfile
|
|
@ -0,0 +1 @@
|
|||
external test : unit -> unit = "testdynfail"
|
|
@ -0,0 +1 @@
|
|||
let test = Lib.test
|
|
@ -0,0 +1 @@
|
|||
dyn.ml
|
|
@ -0,0 +1,3 @@
|
|||
int testdynfail() {
|
||||
return 0;
|
||||
}
|
|
@ -201,7 +201,8 @@ let byte_name p =
|
|||
p.prim_name
|
||||
|
||||
let native_name_is_external p =
|
||||
p.prim_native_name <> "" && p.prim_native_name.[0] <> '%'
|
||||
let nat_name = native_name p in
|
||||
nat_name <> "" && nat_name.[0] <> '%'
|
||||
|
||||
let report_error ppf err =
|
||||
match err with
|
||||
|
|
Loading…
Reference in New Issue