Skip to content

Commit bb1ac2d

Browse files
committed
Remove injection of -Werror=implicit-function-declaration. NFC
I believe this change in the defaults was probably don't back in the day when mismatched function pointers were not otherwise will reported and could lead to hard-to-debug crashes. These days the linker will five a clear error about function signature mistmatches between object files so I think the deviation is no longer worth it. Note: Adding this extra warning actually has some cost because it requires us to understand if the compiler is running C or C++ mode. This is more complicated than is can seem because its possible to specify more than one language mode on the command line. e.g: clang -x c++ myfile.cpp -x c myfile.c We don't currently have great support for this method, and its obviously not common.
1 parent 797fcd9 commit bb1ac2d

File tree

3 files changed

+2
-33
lines changed

3 files changed

+2
-33
lines changed

emcc.py

+2-14
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def get_clang_flags(user_args):
423423
cflags = None
424424

425425

426-
def get_cflags(user_args, is_cxx):
426+
def get_cflags(user_args):
427427
global cflags
428428
if cflags:
429429
return cflags
@@ -447,17 +447,6 @@ def get_cflags(user_args, is_cxx):
447447
# in strict mode. Code should use the define __EMSCRIPTEN__ instead.
448448
cflags.append('-DEMSCRIPTEN')
449449

450-
# Changes to default clang behavior
451-
452-
# Implicit functions can cause horribly confusing function pointer type errors, see #2175
453-
# If your codebase really needs them - very unrecommended! - you can disable the error with
454-
# -Wno-error=implicit-function-declaration
455-
# or disable even a warning about it with
456-
# -Wno-implicit-function-declaration
457-
# This is already an error in C++ so we don't need to inject extra flags.
458-
if not is_cxx:
459-
cflags += ['-Werror=implicit-function-declaration']
460-
461450
ports.add_cflags(cflags, settings)
462451

463452
def array_contains_any_of(hay, needles):
@@ -979,10 +968,9 @@ def get_language_mode(args):
979968
return ''
980969

981970
language_mode = get_language_mode(compile_args)
982-
use_cxx = 'c++' in language_mode or shared.run_via_emxx
983971

984972
def get_clang_command():
985-
return compiler + get_cflags(state.orig_args, use_cxx) + compile_args
973+
return compiler + get_cflags(state.orig_args) + compile_args
986974

987975
def get_clang_command_preprocessed():
988976
return compiler + get_clang_flags(state.orig_args) + compile_args

test/other/test_implicit_func.c

-7
This file was deleted.

test/test_other.py

-12
Original file line numberDiff line numberDiff line change
@@ -5368,18 +5368,6 @@ def test_global_inits(self):
53685368
self.assertContained('argc: 1\n16\n17\n10\n', self.run_js('a.out.js'))
53695369
self.assertContainedIf('globalCtors', src, has_global)
53705370

5371-
def test_implicit_func(self):
5372-
# EMCC makes -Wimplicit-function-declaration an error by default in all modes. Upstream LLVM
5373-
# emits a warning in gnu89 mode, but otherwise emcc's behavior is identical to upstream.
5374-
IMPLICIT_C89 = "error: implicit declaration of function 'strnlen'"
5375-
# Also check for -Wincompatible-function-pointer-types (it became an error in LLVM 16)
5376-
INCOMPATIBLE = ': incompatible function pointer types'
5377-
5378-
stderr = self.expect_fail(
5379-
[EMCC, path_from_root('test/other/test_implicit_func.c'), '-c', '-o', 'implicit_func.o', '-std=gnu89'])
5380-
self.assertContained(IMPLICIT_C89, stderr)
5381-
self.assertContained(INCOMPATIBLE, stderr)
5382-
53835371
@requires_native_clang
53845372
@crossplatform
53855373
def test_bad_triple(self):

0 commit comments

Comments
 (0)