[MLton] Intel Mac version of MLton
Matthew Fluet
fluet at cs.cornell.edu
Sun Oct 15 11:36:14 PDT 2006
Thanks for the explaination. We'll probably go with a statically-linked
wrapper function in C, since that is what we use for many other functions.
It's a little unfortunate to pay the two levels of indirection.
On Fri, 13 Oct 2006, John Reppy wrote:
> Looking at the assembler code, I think that I know what the problem is. Mac
> OS uses
> a different linking scheme for libraries, which support dynamic linking the
> first
> time a function is called. Basically, calling a library function like tanh
> requires
> going through a stub function. If you look at what gcc generates, you would
> see
> something like:
>
> call L_tanh$stub
>
> ...
>
> .section __IMPORT,__jump_table,symbol_stubs,self_modifying_code
> +pure_instructions,5
> L_tanh$stub:
> .indirect_symbol _tanh
> hlt ; hlt ; hlt ; hlt ; hlt
>
> whereas mlton is just generating
>
> call _tanh
>
> The simple workaround is to create statically-linked wrapper functions in C
> or you can bite the
> bullet and implement the Mach-O calling convention for external functions.
>
> - John
>
> On Oct 12, 2006, at 10:07 AM, Matthew Fluet wrote:
>
>>
>>> I would guess that it is in the assembly code that you produce. The rules
>>> for MACH-O files are different in places than those for ELF and COFF.
>>
>> I can believe that MACH-O is different than ELF or COFF, but I guess I
>> would have hoped that the assembler would complain, rather than producing
>> an object file that doesn't link.
>>
>>> Will the flags you suggest save the asm code?
>>
>> Yes; '-keep g' is "keep code-Generated files".
>>
>>>> Well, its obviously a linker issue. You could try compiling
>>>> regression/math.sml with the options '-keep g -keep o -verbose 1'
>>>> which will save the intermediate files and print out the command line
>>>> passed to gcc. I would also try '-codegen c -verbose 1' to see whether
>>>> it is a general linker problem or specific to the native codegen.
>>>> I googled for the error message, and there are a number of pages/posts
>>>> where people report seeing the error, but I haven't found an explaination
>>>> or a solution.
>>>> On Wed, 11 Oct 2006, John Reppy wrote:
>>>>> I did a bin/regression and got a failure (see below).
>>>>> - John
>>>>> <jhr at frogbat> bin/regression
>>>>> MLton MLTONVERSION (built Mon Oct 09 23:08:56 2006 on frogbat.local)
>>>>> flags = -type-check true
>>>>> testing 1
>>>>> ...
>>>>> testing math
>>>>> /usr/bin/ld: /tmp/file1D7oqw.o has external relocation entries in non-
>>>>> writable section (__TEXT,__text) for symbols:
>>>>> _tanh
>>>>> _cosh
>>>>> _sinh
>>>>> _pow
>>>>> collect2: ld returned 1 exit status
>>>>> call to system failed with exit status 1:
>>>>> gcc -o math /tmp/filen4F46H.o /tmp/file1D7oqw.o -L/Users/jhr/Work/
>>>>> mlton/mlton/build/lib/self -lmlton -L/sw/lib -lgmp -lgdtoa -lm
>>>>> _______________________________________________
>>>>> MLton mailing list
>>>>> MLton at mlton.org
>>>>> http://mlton.org/mailman/listinfo/mlton
>>>
>>
>
>
> _______________________________________________
> MLton mailing list
> MLton at mlton.org
> http://mlton.org/mailman/listinfo/mlton
>
More information about the MLton
mailing list