[MLton] symbol scopes

Matthew Fluet fluet at tti-c.org
Wed Nov 12 10:17:28 PST 2008


I still don't know that I understand the necessity for the difference 
between public and external for an imported symbol.  [Indeed, on ELF, 
there appears to be no difference.] My intuition is the following: a 
symbol that is publically exported can be accessed via an 'external' 
assembly sequence by another DSO; since that sequence works for another 
DSO, why doesn't it also work for this DSO.

Is it just an optimization?  Within the DSO, I can get to the public 
symbol via relative addressing, but from another DSO (with PIC), I need an 
indirection?

The other thing I don't understand is how gcc gets by with just two 
visibility directives ("default" and "hidden"); how does it make the 
private/public/external distinction?  I guess it is just for Win{32,64} 
that the EXTERNAL/PUBLIC/PRIVATE macros map to different annotations 
(though, I think, that is partly due to the fact that a single C 
declaration needs to serve as both an export directive (for the 
definition) and an import directive (for other uses)).  But, for Darwin, 
both EXTERNAL and PUBLIC map to the same annotation --- is the MLton 
x86/amd64 codegen for Darwin simply avoiding a cleanup step that would be 
performed by the linker (if we treated 'public' as 'external')?



More information about the MLton mailing list