From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q2MBlGfQ032442 for ; Thu, 22 Mar 2012 12:47:16 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvwEAEwQa09QRFuw/2dsb2JhbABEtziBB4I3gSEmKIhCmAygPYVEh36CP2MEjmaBIoVWkCmCZw X-IronPort-AV: E=Sophos;i="4.73,629,1325458800"; d="ml'?scan'208";a="137246841" Received: from furbychan.cocan.org ([80.68.91.176]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 22 Mar 2012 12:47:11 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.72) (envelope-from ) id 1SAgU2-0005fb-Mg for caml-list@inria.fr; Thu, 22 Mar 2012 11:47:10 +0000 Date: Thu, 22 Mar 2012 11:47:10 +0000 From: "Richard W.M. Jones" To: caml-list@inria.fr Message-ID: <20120322114710.GA21740@annexia.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pf9I7BMVVzbSWLtt" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Subject: [Caml-list] Native dynlink and reloading modules --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I'm a bit surprised to find that native dynlink doesn't work in the same way as bytecode dynlink in respect to reloading the same module. (See attached test program) In bytecode dynlink, reloading (ie. Dynlink.loadfile) the same module causes the new module code to override the old module code: $ ./dynlink_test testing bytecode ... a b But in native dynlink, the new module is silently discarded and the old code appears to run: $ ./dynlink_test testing native ... a a I would classify this as a bug, but I'm not quite sure what is expected to happen. Is there some other way to override a module as in bytecode? $ ocaml -version The Objective Caml toplevel, version 3.12.1 Rich. -- Richard Jones Red Hat --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dynlink_test.ml" (* Save this file as 'dynlink_test.ml' * and compile it with: * ocamlc dynlink.cma dynlink_value.ml dynlink_test.ml -o dynlink_test * or: * ocamlopt dynlink.cmxa dynlink_value.ml dynlink_test.ml -o dynlink_test *) open Printf let native = Dynlink.is_native let suffix = if native then "cmxs" else "cmo" let write_test_module v = let chan = open_out "dynlink_test_module.ml" in fprintf chan "Dynlink_value.value := \"%s\"\n" v; close_out chan; let cmd = if native then "ocamlopt -c dynlink_test_module.ml &&\nocamlopt -shared dynlink_test_module.cmx -o dynlink_test_module.cmxs" else "ocamlc -c dynlink_test_module.ml" in assert (Sys.command cmd = 0) let main () = printf "testing %s ...\n" (if native then "native" else "bytecode"); write_test_module "a"; Dynlink.loadfile (sprintf "dynlink_test_module.%s" suffix); print_endline !Dynlink_value.value; write_test_module "b"; Dynlink.loadfile (sprintf "dynlink_test_module.%s" suffix); print_endline !Dynlink_value.value let () = try main () with | Dynlink.Error err -> eprintf "dynlink: %s\n" (Dynlink.error_message err) --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dynlink_value.ml" (* Save this file as 'dynlink_value.ml' *) let value = ref "none" --pf9I7BMVVzbSWLtt--