emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.88k stars 3.32k forks source link

How does emscripten generate additional warnings? #21463

Open IMSAMWIlL opened 8 months ago

IMSAMWIlL commented 8 months ago

I'm new to emscripten and I have a question regarding the emscripten's implementation. When I compile a code using emscripten it introduces the following error:

error: 'long long' is an extension when C99 mode is not enabled [-Werror,-Wlong-long]

I understand since the -Werror is enabled it treats warnings as errors. The version of emsdk I used takes Clang version 19.0.0 to compile a C program. However, when I use the same version of Clang to compile my code into x86-64, no warning will arise. Can you help me to understand what is happening in this case? I supposed that emscripten uses Clang to compile code into LLVM IR. But how does it generate additional warnings which are not introduced by Clang?

kripken commented 8 months ago

The difference could be because an x86-64 build using clang 19 targets a different triple, and perhaps the warning is triple-dependent or backend dependent somehow (as the size of long long depends on the triple).

However, when I compile

int main() {
  long long x = 0;
  return x;
}

I see no such warning with latest emscripten, so perhaps you are passing a flag like -std=.. or such that affects this warning?