emscripten-core / emscripten-core/emscripten

Inconsistent output of first invocation of `em++ -dumpmachine` is breaking tools

Open
#12,769 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Observed
----------

After a fresh install from sources of emscripten, the first invocation of `em++ -dumpmachine` will output first this line before the real output:
```
shared:INFO: (Emscripten: Running sanity checks)
```
Any future invocation will then never output this line.

When a tool relies on invoking `em++ -dumpmachine` they parse the output value directly. This will fail at the very first invocation after installation, but not afterwards, making working with `em++` looking midly inconsistent.

I'm hitting a concrete example using `build2` (https://build2.org): when initializing a configuration where we specified to use `em++` (or `emcc`) as compiler, `build2` will first invoke `em++ -dumpmachine` (with some other flags) to gather information about the target configuration. It fails the first time after installation of emscripten, but never afterwards.

Note that this sanity check output line is not output with other info commands like `em++ --version`.

Expected
---------

Consistent output for the same command executed with the same input and environment, so that tools can rely on that consistency.

How To Reproduce
-------------------

```
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest

source ./emsdk_env.sh
em++ --version # Consistent: output will always be the same.
em++ -dumpmachine # Inconsistent: additional output "shared:INFO: (Emscripten: Running sanity checks)"
em++ -dumpmachine # Consistent from now on.

```

Proposition
------------

Either one of these would be fine to me (and probably to tool implementers):

- Do not output that line at all, except using a flag to display it if requested;
- Output that line by default, but have a flag to not output it -- that flag can then be used with all commands generated by tools;
- Do not do sanity checks for `-dumpmachine` command, like it's not done for `--version`.
- Never do sanity checks unless a specific sanity-check command is used;

Workaround
-------------

Invoke `em++ -dumpmachine` manually or via scripts before doing any work with the compiler. That works but looks like it could be avoided.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.