[MLton-commit] r6986
Ville Laurikari
ville at mlton.org
Wed Nov 12 00:59:31 PST 2008
Modified the -linkage command line option to allow control of the
symbol scope attribute in the generated _address imports, as discussed
in
http://mlton.org/pipermail/mlton-user/2008-November/001486.html
The old "-linkage static" is removed. Instead, use "-linkage archive"
(for symbols with "public" scope) or "-linkage shared" (for symbols
with "external" scope).
The "-linkage dynamic" option works the same as before.
----------------------------------------------------------------------
U mlton/trunk/mlnlffigen/control.sig
U mlton/trunk/mlnlffigen/control.sml
U mlton/trunk/mlnlffigen/gen.sml
U mlton/trunk/mlnlffigen/main.sml
----------------------------------------------------------------------
Modified: mlton/trunk/mlnlffigen/control.sig
===================================================================
--- mlton/trunk/mlnlffigen/control.sig 2008-11-12 08:40:05 UTC (rev 6985)
+++ mlton/trunk/mlnlffigen/control.sig 2008-11-12 08:59:30 UTC (rev 6986)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2005-2005 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2005-2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under a BSD-style license.
@@ -33,7 +33,7 @@
structure Linkage :
sig
- datatype t = Dynamic | Static
+ datatype t = Archive | Dynamic | Shared
end
val linkage : Linkage.t ref
Modified: mlton/trunk/mlnlffigen/control.sml
===================================================================
--- mlton/trunk/mlnlffigen/control.sml 2008-11-12 08:40:05 UTC (rev 6985)
+++ mlton/trunk/mlnlffigen/control.sml 2008-11-12 08:59:30 UTC (rev 6986)
@@ -49,11 +49,12 @@
structure Linkage =
struct
- datatype t = Dynamic | Static
+ datatype t = Archive | Dynamic | Shared
val toString =
- fn Dynamic => "dynamic"
- | Static => "static"
+ fn Archive => "archive"
+ | Dynamic => "dynamic"
+ | Shared => "shared"
end
val linkage = control {name = "linkage",
default = Linkage.Dynamic,
Modified: mlton/trunk/mlnlffigen/gen.sml
===================================================================
--- mlton/trunk/mlnlffigen/gen.sml 2008-11-12 08:40:05 UTC (rev 6985)
+++ mlton/trunk/mlnlffigen/gen.sml 2008-11-12 08:59:30 UTC (rev 6986)
@@ -1,7 +1,7 @@
(* gen.sml
* 2005 Matthew Fluet (mfluet at acm.org)
* Adapted for MLton.
-(* Copyright (C) 2005-2007 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2005-2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under a BSD-style license.
@@ -680,6 +680,11 @@
| NONE => raise Fail "missing fptr_type (mkcall)"
end
+ fun pr_addr_import (pr_fdef, name, attrs) =
+ pr_fdef ("h", [EUnit],
+ EPrim ("_address \"" ^ name ^ "\" " ^ attrs,
+ Type "CMemory.addr"))
+
fun pr_gvar_promise x =
let
val {src, name, spec = (c, t)} = x
@@ -723,12 +728,12 @@
VBox 4;
nl (); str "open C.Dim C_Int";
case linkage of
- Control.Linkage.Dynamic =>
+ Control.Linkage.Archive =>
+ pr_addr_import (pr_fdef, name, "public")
+ | Control.Linkage.Dynamic =>
pr_vdef ("h", EApp (EVar libhandle, EString name))
- | Control.Linkage.Static =>
- pr_fdef ("h", [EUnit],
- EPrim ("_address \"" ^ name ^ "\"",
- Type "CMemory.addr"));
+ | Control.Linkage.Shared =>
+ pr_addr_import (pr_fdef, name, "external");
endBox ();
nl (); str "in";
VBox 4;
@@ -837,12 +842,12 @@
VBox 4;
nl (); str "open C.Dim C_Int";
case linkage of
- Control.Linkage.Dynamic =>
+ Control.Linkage.Archive =>
+ pr_addr_import (pr_fdef, name, "public")
+ | Control.Linkage.Dynamic =>
pr_vdef ("h", EApp (EVar libhandle, EString name))
- | Control.Linkage.Static =>
- pr_fdef ("h", [EUnit],
- EPrim ("_address \"" ^ name ^ "\"",
- Type "CMemory.addr"));
+ | Control.Linkage.Shared =>
+ pr_addr_import (pr_fdef, name, "external");
endBox ();
nl (); str "in";
VBox 4;
Modified: mlton/trunk/mlnlffigen/main.sml
===================================================================
--- mlton/trunk/mlnlffigen/main.sml 2008-11-12 08:40:05 UTC (rev 6985)
+++ mlton/trunk/mlnlffigen/main.sml 2008-11-12 08:59:30 UTC (rev 6986)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2005-2005 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2005-2005, 2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under a BSD-style license.
@@ -49,13 +49,15 @@
(Normal, "light", "",
"suppress 'heavy' versions of function wrappers and field accessors",
None (fn () => weight := {heavy = false, light = true})),
- (Normal, "linkage", " {dynamic|static}",
+ (Normal, "linkage", " {archive|dynamic|shared}",
"how to link C objects",
SpaceString (fn s =>
- if s = "dynamic"
+ if s = "archive"
+ then linkage := Linkage.Archive
+ else if s = "dynamic"
then linkage := Linkage.Dynamic
- else if s = "static"
- then linkage := Linkage.Static
+ else if s = "shared"
+ then linkage := Linkage.Shared
else usage (concat ["invalid -linkage arg: ", s]))),
(Normal, "match", " <re>",
"generate ML definitions for #include-d definitions matching <re>",
More information about the MLton-commit
mailing list