emscripten-core / emscripten-core/emscripten
emcc --generate-config fails unless local config is already present
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
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
```
Contributor guide
Assessment
This issue has not been assessed yet.