Skip to content

-gz argument seems to enable debugging information #24080

@jmcclellan-figma

Description

@jmcclellan-figma

Please include the following in your bug report:

Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.3 (a9651ff)
clang version 21.0.0git (https:/github.com/llvm/llvm-project 6dc41a639334b913e762f65410fcd14a722b137f)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: ~/emsdk/upstream/bin

Failing command line in full:

emcc hello.cc -o hello.html -g0 -gz

Full link command and output with -v appended:

/wasm-ld -o hello.wasm /var/folders/fn/j37bx8dd6qx5_dcnlqgq110m0000gp/T/emscripten_temp_q01d0kcp/hello_0.o -L/Users/jmcclellan/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -L/Users/jmcclellan/emsdk/upstream/emscripten/src/lib -lGL-getprocaddr -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc-debug -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /var/folders/fn/j37bx8dd6qx5_dcnlqgq110m0000gp/T/tmp9r7nvx20libemscripten_js_symbols.so --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=_emscripten_stack_alloc --export=__wasm_call_ctors --export=_emscripten_stack_restore --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=main --export-if-defined=__main_argc_argv --export-if-defined=fflush --export-table -z stack-size=65536 --no-growable-memory --initial-heap=16777216 --no-entry --stack-first --table-base=1
#include <iostream>

int main() { std::cout << "Hello world\n"; }

Based on experience from clang, I would have expected -gz to enable debug compression but not necessarily enable any debugging information. Instead, it seems to enable extra debug sections.

emcc hello.cc -o hello.html -g0 -gz

creates a wasm file that is 2.2mb

while

emcc hello.cc -o hello.html -g0

creates one that is 189kb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions