Skip to content

Add documentation on how to use local emscripten #1291

Closed

Description

@ericoporto

Hi,

I think the documentation here in the readme has unfortunately aged: https://github.com/emscripten-core/emsdk#how-do-i-use-my-own-emscripten-github-fork-with-the-sdk

I tried to instead just cd upstream/emscripten as emscripten/main dir doesn't exist, but that didn't work either, because that will instead switch the remote of the emsdk local git repo as whole. My hack so far has been to rm -rf emscripten && ln -s ../../emscripten (this surprisingly works in git-bash on windows!), which has my outer clone of emscripten.

There is an issue that I don't know how to install emsdk and activate it, with my fork and branch, without getting

error: BINARYEN_ROOT is set to empty value  C:\Users\user\git\emsdk\upstream\emscripten\.emscripten

I don't know what is the right approach but I guess there is a process everyone here uses - it's just everyone is so used they forgot to document! 😆

Activity

  1. ericoporto commented on Oct 21, 2023

    @ericoporto
    Author

    I guess the docs that are here are supposed to mysteriously explain this in some other way, but find . -iname ".emscripten" comes up empty in the emsdk directory after clone or after ./emsdk install tot do all it's things... I have no idea what this file is or how it's supposed to work. The environment variable thing also doesn't work as it's apparently supposed to point to a dir that contains this mysterious file.

  2. sbc100 commented on Oct 22, 2023

    @sbc100
    Collaborator

    The .emscripten file in the emsdk directory is created by ./emsdk activate tot (which should be done after ./emsdk install tot). Once you have don't that setting EM_CONFIG=/path/to/emsdk/.emscripten should work.

    As for the docs at https://github.com/emscripten-core/emsdk#how-do-i-use-my-own-emscripten-github-fork-with-the-sdk, I agree they are perhpas out-of-date or confusing. They are referring to how using a custom branch in the "build-from-source" scenario which is different way to use emsdk. Most folks don't use that method so we should probably either remove or update the question.

  3. ericoporto commented on Oct 22, 2023

    @ericoporto
    Author

    I don't understand this yet, I don't want to pass a "path/to/emsdk", I want to pass a path to emscripten! My local emscripten doesn't have that dot emscripten file, no matter what I do.

    (but like, it's Sunday, I am ok getting a better answer during the week :p)

  4. sbc100 commented on Oct 23, 2023

    @sbc100
    Collaborator

    I don't understand this yet, I don't want to pass a "path/to/emsdk", I want to pass a path to emscripten! My local emscripten doesn't have that dot emscripten file, no matter what I do.

    (but like, it's Sunday, I am ok getting a better answer during the week :p)

    The .emscripten file in emsdk is the one you want. You don't need to have in your emscripten checkout.

    To use your emscripten just make sure it comes first in the PATH. Then you run emcc it will find your local checkout in the PATH.. and then EM_CONFIG will tell your checkout of emscripten where to find other things like llvm and binaryen.

  5. sbc100 commented on Oct 23, 2023

    @sbc100
    Collaborator

    In other words the .emscripten file in the emsdk works for any/all versions of emscripten. It doesn't say where emscripten lives.. only where the dependencies live.

  6. ericoporto commented on Oct 23, 2023

    @ericoporto
    Author

    Sorry, what are supposed the contents of this file? I think it's not being created. I am on Windows. I would like to create it by hand.

  7. sbc100 commented on Oct 23, 2023

    @sbc100
    Collaborator

    The .emscripten file in the emsdk directory is created for you by the emsdk activate command, for example emsdk activate latest.

    If you don't want to use emsdk and you want to build your own dependencies for some reason you can create a .emscripten file in your emscripten checkout. You can use ./emcc --generate-config to have emscripten create a dummy config file for you. See https://emscripten.org/docs/building_from_source/configuring_emscripten_settings.html#configuring-emscripten-settings-when-manually-building-from-source for more on that.

    However, I would strongly recommend using emsdk since that avoids build the dependencies yourself.

  8. shrinktofit commented on Dec 23, 2023

    @shrinktofit

    I had this question as well. I want to figure out why DWARF was not correctly generated. So I want to git clone the emscripten-core repository and debug. Briefly, I want:

    • Use myown fork of emscripten-core, of some version(3.1.43)

    • Keep other dependencies(those prebuilt binaries) by default, once they're suitable for 3.1.43.

    What I tried:

    • emsdk install tot. This install all things as latest. Not what I want.

    • emsdk install sdk-main-64bit. This install all things as source, such as LLVM source. Also not what I want. I don't have to compile LLVM.

    • emsdk install 3.1.43 install all for me, but it keeps <emsdk>/upstream/emscripten an unzipped stuff, not git.

    Here is my final solution:

    1. emsdk install 3.1.43 then emsdk activate 3.1.43

    This install and activate the prebuilt dependencies.

    1. ./emsdk_env

    This makes the dependencies available.

    1. Set environment variable EMSCRIPTEN = <path-to-my-emscripten-fork>.

    This might be optional. My project use this env var to locate emscripten CMake toolchain.

    1. Set environment variable EM_CONFIG = <path-to-emsdk>/.emscripten.

    I don't know why this is required, but I have to do this.

  9. sbc100 commented on Jan 2, 2024

    @sbc100
    Collaborator

    Your solution looks good. The EM_CONFIG environment is most important thing which tells emcc where to find its dependencies.

    The EMSCRIPTEN environment variable is not used by emscripten itself these days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions