Hi Fernando,

There seems to be an unfortunate name clash here between the "-s
RELOCATABLE=1" option and the concept of a relocatable object. The
description of the "-s RELOCATABLE=1" option from settings.js is:

// If set to 1, we emit relocatable code from the LLVM backend; both
// globals and function pointers are all offset (by gb and fp, respectively)
// Automatically set for SIDE_MODULE or MAIN_MODULE.

This is somewhat confusing because it says "relocatable code," but then
talks about making the code position independent, which is a different
meaning of relocatable. My guess is that this Emscripten option predates
real WebAssembly object files. Anyway, the point is that this option does
not make Emscripten emit a real object file, so it is not surprising that
wasm-ld doesn't know what to do with it. You can make Emscripten produce
an object file using "-c", just like gcc or clang.

Thomas

On Sun, Jun 7, 2020 at 06:34 Fernando Bitti Loureiro <
[email protected]> wrote:

> Hi, everyone,
>
> First of all, congratulations on the amazing job of developing a tool like
> Emscripten.
> In order to learn wasm in practice, I've started to compile other people's
> libraries and, when I find any roadblock, google my way around it.
>
> I'm asking for your help because in this case, I don't know what else to
> do.
>
> This is the project: https://github.com/OpenGene/repaq.
> The moment I face an issue is when I ask Emscripten to generate the JS
> code to let me run the WASM code.
>
> These are the steps I followed.
> 1. First of all, I checked I could compile the repository using C++, by
> running make. And it worked.
>
> 2. Then I run:
> # emmake make repaq CXX=emcc CXXFLAGS="-s USE_ZLIB=1 -s RELOCATABLE=1 -s
> USE_PTHREADS=0 $CXXFLAGS"
> Emscripten also works and, despite some warnings, I get a valid repaq.wasm
> file.
>
> 3. I rename repaq.wasm to repaq.o for the next step.
> # mv repaq.wasm repaq.o
>
> 4. Now I run:
> # emcc -v repaq.o -o repaq.js -s USE_ZLIB=1 -s RELOCATABLE=1 -s
> USE_PTHREADS=0 -s EXTRA_EXPORTED_RUNTIME_METHODS="['callMain']"
> -Wl,--relocatable
> and it fails with:
> *wasm-ld: error: repaq.o: not a relocatable wasm file*
>
> The files were clearly generated with "-s RELOCATABLE=1" and I don't find
> documentation on what else to do about it.
> Any ideas?
>
> Thank you for your kind attention,
>
> Fernando
>
> *These are the versions of the tools I'm using: *
> *# emcc --version*
> *emcc (Emscripten gcc/clang-like replacement) 1.39.17
> (e4271595539cf1ca81128280cdc72f7245e700a0)*
>
> *# emcc -Wl,--version*
> *LLD 11.0.0
> (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-llvm-llvm--project
> cc2349e3cf0e1f492433941b359a03fc3f746410)*
>
> *Note: I already tried combining lots of options, as well as removing
> "-lpthreads" from the make file, but I always get stuck here.*
>
> *If I use "-s USE_PTHREADS=1" I get a different type of error, related to
> atomics. However as the original project still compiles in C++ and works
> even without "-lpthreads", I preferred to test it this way in order to
> simplify.*
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/c8f14aed-8071-4f3f-9e9a-0d82f332d7cao%40googlegroups.com
> <https://groups.google.com/d/msgid/emscripten-discuss/c8f14aed-8071-4f3f-9e9a-0d82f332d7cao%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CAJZD_EWo-NMOZay8RmX0TDWW-yiaJehiCOjw5VkrAbhMt-8kVA%40mail.gmail.com.

Reply via email to