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

emcc --generate-config fails unless local config is already present #16251

Open
jermy opened this issue Feb 11, 2022 · 6 comments
Open

emcc --generate-config fails unless local config is already present #16251

jermy opened this issue Feb 11, 2022 · 6 comments

Comments

@jermy
Copy link

jermy commented Feb 11, 2022

I would like to set up some automated builds using emscripten but it won't run without a configuration file present, and doesn't provide a way to generate a configuration file without a configuration file already existing - or being in the user's home directory - creating a race-condition if multiple builds are running at the same time.

Ideally, I'd want to run:

export EM_CONFIG=$(mktemp)
trap "rm -f ${EM_CONFIG}" EXIT
emcc --generate-config ${EM_CONFIG}

and be able to run subsequent builds without issue, however I instead get the following:

$ export EM_CONFIG=$(mktemp)
$ emcc --generate-config ${EM_CONFIG}
emcc: error: LLVM_ROOT is not defined in /tmp/tmp.gHD6nAEeYP

An alternative failure mode is shown below where attempting to generate a configuration file generates an unwanted user configuration file instead.

A minimal fix may be to move --generate-config handling into tools/config.py such that it always runs before attempting to parse a config file. For my use case, there would ideally be an argument/environment setting to use the automatically generated config file and not write a file to disk, although perhaps that is closer to the deprecated functionality in #11684 than wanted.

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.3 ()
Debian clang version 13.0.1-+rc3-1~exp1+b1
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /usr/bin

Failing command line in full:

rm ~/.emscripten
emcc -v --generate-config=/tmp/emscripten_config
ls -l /tmp/emscripten_config

Full link command and output with -v appended:

$ emcc -v --generate-config /tmp/emscripten_config

==============================================================================
Welcome to Emscripten!

This is the first time any of the Emscripten tools has been run.

A settings file has been copied to /home/jeremy/.emscripten, at absolute path: /home/jeremy/.emscripten

It contains our best guesses for the important paths, which are:

  LLVM_ROOT       = /usr/bin
  NODE_JS         = /usr/bin/node
  EMSCRIPTEN_ROOT = /usr/share/emscripten

Please edit the file if any of those are incorrect.

This command will now exit. When you are done editing those paths, re-run it.
==============================================================================

$ ls -l /tmp/emscripten_config
ls: cannot access '/tmp/emscripten_config': No such file or directory
@jermy
Copy link
Author

jermy commented Feb 11, 2022

I see this is likely related to (and fixed by?) PR #13962 - let me know if there's anything I can do to help get that merged.

@sbc100
Copy link
Collaborator

sbc100 commented Feb 15, 2022

Yup, it looks like #13962 will solve this issue. I'll try to get that landed.

BTW, can I ask if you actually plan on using the auto-generated config? Does it contain the right values for you?

@jermy
Copy link
Author

jermy commented Feb 15, 2022

Great, many thanks.

I do use the default configuration in this build environment. With a downstream Debian patch, the relevant bits of an automatically generated config end up as:

LLVM_ROOT = '/usr/bin'
NODE_JS = '/usr/bin/node'
BINARYEN_ROOT = '/usr'
LLVM_ADD_VERSION = '13'
CLANG_ADD_VERSION = '13'

Where the latter two lines meaning I also don't need to install the llvm-defaults related packages.

@sbc100
Copy link
Collaborator

sbc100 commented Feb 15, 2022

Is there some reason you prefer to use --generate-config over just including that config file that you just quoted?

@sbc100
Copy link
Collaborator

sbc100 commented Feb 15, 2022

(Also, I wonder if we can/should make those first three lines completely optional and use PATH by default?)

@jermy
Copy link
Author

jermy commented Feb 15, 2022

I'd generally prefer to avoid hardcoding paths if I can avoid it - particularly as emscripten has a better idea of what those paths are! I'd also be happy with an option to not requiring a config file.

I have a workaround at the moment that involves importing the config.py file, then truncating it after the generate_config function and executing that. I'm not especially proud of it, but it avoids having to hardcode versions and paths for now.

I'm guessing the standard user workflow of emscripten is too use various locally installed versions of binaries & node?

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

2 participants