From 80df567d50c8b9399f8afe90fa20c558910a2564 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 3 Aug 2026 11:30:26 -0700 Subject: [PATCH] Remove warning when compiling to `.bc` file As part of ongoing effort to match upstream clang where possible. This warning was introduced when we made the transition from bitcode output by default to object files by default. This was many years ago now and I think its served its purpose. --- emcc.py | 2 -- test/test_other.py | 10 +++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/emcc.py b/emcc.py index 9bf2e2d5fda88..aae61e47b1655 100644 --- a/emcc.py +++ b/emcc.py @@ -541,8 +541,6 @@ def get_clang_command_asm(): return compiler + compile.get_target_flags() if state.mode == Mode.COMPILE_ONLY: - if options.output_file and get_file_suffix(options.output_file) == '.bc' and not options.lto and '-emit-llvm' not in state.orig_args: - diagnostics.warning('emcc', '.bc output file suffix used without -flto or -emit-llvm. Consider using .o extension since emcc will output an object file, not a bitcode file') if all(get_file_suffix(i) in ASSEMBLY_EXTENSIONS for i in options.input_files): cmd = get_clang_command_asm() + newargs else: diff --git a/test/test_other.py b/test/test_other.py index 4856563992fe2..0b734792f1c37 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -594,12 +594,16 @@ def test_emcc_2(self, compiler, suffix): self.run_process([compiler, target, '-o', target + '.js']) self.assertContained('Hello, world!', self.run_js(target + '.js')) - def test_bc_output_warning(self): - err = self.run_process([EMCC, '-c', test_file('hello_world.c'), '-o', 'out.bc'], stderr=PIPE).stderr - self.assertContained('emcc: warning: .bc output file suffix used without -flto or -emit-llvm', err) + def test_bc_output_suffix(self): + # Emscripten doe not use the output name when compiling to decide on the type + # of output. For example, specifying an output filename that ends in `.bc` does + # *not* imply the output is actually bitcode. + self.run_process([EMCC, '-c', test_file('hello_world.c'), '-o', 'out.bc']) + self.assertTrue(building.is_wasm('out.bc')) def test_bc_as_archive(self): self.run_process([EMCC, '-c', test_file('hello_world.c'), '-flto', '-o', 'out.a']) + self.assertTrue(is_bitcode('out.a')) self.run_process([EMCC, 'out.a']) @parameterized({