Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation on how to use local emscripten #1291

Open
ericoporto opened this issue Oct 21, 2023 · 9 comments
Open

Add documentation on how to use local emscripten #1291

ericoporto opened this issue Oct 21, 2023 · 9 comments

Comments

@ericoporto
Copy link

ericoporto commented Oct 21, 2023

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! 😆

@ericoporto
Copy link
Author

ericoporto commented Oct 21, 2023

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.

@sbc100
Copy link
Collaborator

sbc100 commented Oct 22, 2023

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.

@ericoporto
Copy link
Author

ericoporto commented Oct 22, 2023

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)

@sbc100
Copy link
Collaborator

sbc100 commented Oct 23, 2023

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.

@sbc100
Copy link
Collaborator

sbc100 commented Oct 23, 2023

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.

@ericoporto
Copy link
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.

@sbc100
Copy link
Collaborator

sbc100 commented Oct 23, 2023

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.

@shrinktofit
Copy link

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.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 2, 2024

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants