It looks like what's going on here is that the input is something like this,

@the_alias = alias double (double), double (double)* @the_real

define double @the_real(double) {
  ret double 1.0
}

And exporting the alias doesn't work. In other words, emscripten's 
exporting appears to only work on functions, not aliases of functions.

It's probably possible to add that support, but I'm not sure how easy it 
would be offhand. Is there perhaps a way in Julia to work around this, to 
not use an alias for things like that?


On Thursday, September 21, 2017 at 6:00:07 PM UTC-7, Tom Short wrote:
>
>
> We're making some progress compiling Julia code with Emscripten with some 
> help from Docker to set up versions of Julia and Emscripten that match 
> best. 
>
> https://github.com/tshort/jl2js-dock/tree/master/jl2js
>
> One gotcha we've run into is in linking. Julia has a feature where we 
> decorate code that designates that it will be available for external 
> C-style linking. Emscripten can compile the following `myabs()` function:
>
> https://github.com/tshort/jl2js-dock/blob/master/jl2js/example.jl#L5
>
> But, it only generates usable JavaScript if Emscripten is invoked as 
> follows:
>
> emcc -v example.bc libuv.bc libjulia.bc -o example.js -s 
> EXPORTED_FUNCTIONS="['_myabs','_julia_myabs_2473']"
>
> Both of the `myabs` versions are needed in EXPORTED_FUNCTIONS. When 
> compiled, there's an error saying that `_myabs` can't be found, and it is 
> not exported. `_julia_myabs_2473` is exported and works fine in JavaScript 
> (but this is a pain to hook up manually). Here is what llvm-nm says about 
> these functions:
>
> -------- d -Main.myabs2474
> -------- t jlcall_myabs_2472
> -------- t jlcapi_myabs_2473
> -------- t jlcapi_myabs_2473_gfthunk
> -------- t julia_myabs_2473
> -------- T myabs
>
> After using llvm-dis, here's what the LLVM assembly code looks like:
>
> define internal i8** @jlcall_myabs_2472(i8**, i8***, i32) #4 {
> top:
>   %3 = bitcast i8*** %1 to double**
> ...
>
> define internal double @jlcapi_myabs_2473(double) #4 {
> top:
>   %1 = load i32, i32* bitcast (i8**** getelementptr inbounds (i8***, 
> i8**** @jl_tls_states, i32 1) to i32*), align 4
> ...
>
> !23696 = distinct !DISubprogram(name: "myabs", linkageName: 
> "julia_myabs_2473", scope: null, file: !658, type: !14711, isLocal: false, 
> isDefinition: true, isOptimized: true, unit: !657, variables: !4)
> !23697 = !DILocation(line: 5, scope: !23696)
>
> We are using Emscripten SDK version 1.37.6 to try to match LLVM versions 
> with Julia.
>
> Anyone have ideas on how to get `_myabs` exported properly?
>
> Bitcode is here:
>
> https://github.com/tshort/jl2js-dock/blob/master/jl2js/example.bc
>
> -Tom
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to