emscripten-core / emscripten-core/emscripten
Building for profiling (--profiling) disregards ENVIRONMENT
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
**Version of emscripten/emsdk:**
```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.27 (afa75f342eef4d925172479afa8e6233eb0ae5a9)
clang version 16.0.0 (https://github.com/llvm/llvm-project dee009d3b5c71a340eb4ebb3cfb49f6015a789cc)
Target: wasm32-unknown-emscripten
Thread model: posix
```
**Failing command line in full:**
-
**Full link command and output with `-v` appended:**
```
emcc -Werror --profiling --closure 0 -sWASM=1 -sASSERTIONS=1 -sINITIAL_MEMORY=67108864 -sSTACK_SIZE=5MB -sALLOW_MEMORY_GROWTH=1 -sFILESYSTEM=0 -sENVIRONMENT=web -sSINGLE_FILE=1 -sMODULARIZE=1 -sEXPORTED_RUNTIME_METHODS=ccall,cwrap -I include -o ...
```
**Description**
I'm using emscripten to create a library for browser target (`-sENVIRONMENT=web`) that is integrated into another library.
Building with production settings works fine. When I build for profiling (using `--profiling`), the generated JavaScript contains the following lines:
```
[...]
if (ENVIRONMENT_IS_SHELL) {
if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof importScripts == 'function') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
[...]
```
The statement `typeof process == 'object'` which I assume checks for Node.js environment (not an expert, please correct if this is not true) causes an import of `process' in the downstream bundling process which consumes emscripten's JavaScript output.
```
import * as $hgUW1$process from "process";
```
Shouldn't `-sENVIRONMENT=web` remove these checks altogether?
Contributor guide
Assessment
This issue has not been assessed yet.