GithubHelp home page GithubHelp logo

Comments (13)

sbc100 avatar sbc100 commented on July 24, 2024 1

In that case I would recommend using -sMAIN_MODULE=2 rather then -sRELOCTABLE

from emscripten.

sbc100 avatar sbc100 commented on July 24, 2024

Can I ask why are you trying to build with -sRELOCATABLE? Obviously we should fix this, but using that flag directly not common/recommended.

from emscripten.

sbc100 avatar sbc100 commented on July 24, 2024

The reason that _emscripten_thread_exit_joinable is not available is that that symbol is only defined when -sMAIN_MODULE is used:

#if MAIN_MODULE
_emscripten_thread_exit_joinable: (thread) => {

Unfortunetly at the callsite we protect that call with -DEMSCRIPTEN_DYNAMIC_LINKING which I believe is set whenever -sRELOCTABLE is used.. so there is a mismatch there:

#ifdef EMSCRIPTEN_DYNAMIC_LINKING
// When dynamic linking is enabled we need to keep track of zombie threads
_emscripten_thread_exit_joinable(self);
#endif

from emscripten.

allsey87 avatar allsey87 commented on July 24, 2024

Can I ask why are you trying to build with -sRELOCATABLE? Obviously we should fix this, but using that flag directly not common/recommended.

I am probably a bit confused here, but I am trying to compile a set of static libraries that will be linked into either the main module or the side module. Now these libraries are built via Autoconf and Automake so the build process also includes compiling small test programs to see what features emcc has.

Initially I was just using -fPIC since I thought that neither -sMAIN_MODULE or -sSIDE_MODULE made sense here, but just using -fPIC alone is not enough to get PIC variants of system libraries from the cache. In order to get the PIC variants, -sRELOCATABLE has to be set (or set indirectly via -sMAIN_MODULE or -sSIDE_MODULE in emcc) to get the correct cache path.

Since I am compiling static libraries, I guess the version of the cache in use doesn't really matter since the static library will never actually be linked against anything in there, but I thought for the configure script compiler tests it would be more correct for those tests to use the system libraries coming from the correct cache path.

from emscripten.

sbc100 avatar sbc100 commented on July 24, 2024

If you are building static libraries that you don't need -fPIC or MAIN_MODULE. For autoconf and automake and would recommend disabling dynamic linking completely using --disable-shared.

from emscripten.

allsey87 avatar allsey87 commented on July 24, 2024

Huh, I thought the code would still need to be compiled with -fPIC if it is going to be linked into a relocatable module at some point...

from emscripten.

sbc100 avatar sbc100 commented on July 24, 2024

Sure, yes, if you the final output is a MAIN_MODULE or a SIDE_MODULE than yes you would want to build with -fPIC. Is your final output of those?

from emscripten.

sbc100 avatar sbc100 commented on July 24, 2024

In any case #22110 should fix this particular bug. In the long run I'm still hoping we can remove -sRELOCATBLE as a link flag since we don't test that mode fully, and I'm not sure what its usefulness is these days.

from emscripten.

allsey87 avatar allsey87 commented on July 24, 2024

Sure, yes, if you the final output is a MAIN_MODULE or a SIDE_MODULE than yes you would want to build with -fPIC. Is your final output of those?

Yes, the final output will be either a MAIN_MODULE or SIDE_MODULE, the reason for adding -sRELOCATBLE is because I want the configure tests to link against the -fPIC variants of the system libraries since those are the only ones available when using emscripten_cache(flags = ["--pic"]).

from emscripten.

sbc100 avatar sbc100 commented on July 24, 2024

Sure, yes, if you the final output is a MAIN_MODULE or a SIDE_MODULE than yes you would want to build with -fPIC. Is your final output of those?

Yes, the final output will be either a MAIN_MODULE or SIDE_MODULE, the reason for adding -sRELOCATBLE is because I want the configure tests to link against the -fPIC variants of the system libraries since those are the only ones available when using emscripten_cache(flags = ["--pic"]).

Can't you setup the cache to contains both types of libraries? What if you have a statically linked binary and a dynamically linked binary in the same project?

from emscripten.

allsey87 avatar allsey87 commented on July 24, 2024

Yeah, I was thinking that. Once I get some initial feedback on the direction of that PR, I will investigate calling embuilder multiple times with the different configurations.

from emscripten.

allsey87 avatar allsey87 commented on July 24, 2024

In that case I would recommend using -sMAIN_MODULE=2 rather then -sRELOCTABLE

This is a decent workaround, but it seems incorrect that by default, if I compile code with -fPIC, it will link against non--fPIC system libraries. Perhaps the cache should be checking these flags directly instead of relying on the higher level Emscripten arguments like -sRELOCATABLE?

from emscripten.

sbc100 avatar sbc100 commented on July 24, 2024

I'm proposing that we drop -sRELOCATABLE completely... unless you can think of a good use case for it.

from emscripten.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.