Skip to content

Remove injection of -Werror=implicit-function-declaration #23465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def get_clang_flags(user_args):
cflags = None


def get_cflags(user_args, is_cxx):
def get_cflags(user_args):
global cflags
if cflags:
return cflags
Expand All @@ -448,17 +448,6 @@ def get_cflags(user_args, is_cxx):
# in strict mode. Code should use the define __EMSCRIPTEN__ instead.
cflags.append('-DEMSCRIPTEN')

# Changes to default clang behavior

# Implicit functions can cause horribly confusing function pointer type errors, see #2175
# If your codebase really needs them - very unrecommended! - you can disable the error with
# -Wno-error=implicit-function-declaration
# or disable even a warning about it with
# -Wno-implicit-function-declaration
# This is already an error in C++ so we don't need to inject extra flags.
if not is_cxx:
cflags += ['-Werror=implicit-function-declaration']

ports.add_cflags(cflags, settings)

def array_contains_any_of(hay, needles):
Expand Down Expand Up @@ -984,10 +973,9 @@ def get_language_mode(args):
return ''

language_mode = get_language_mode(newargs)
use_cxx = 'c++' in language_mode or shared.run_via_emxx

def get_clang_command():
return compiler + get_cflags(state.orig_args, use_cxx)
return compiler + get_cflags(state.orig_args)

def get_clang_command_preprocessed():
return compiler + get_clang_flags(state.orig_args)
Expand Down
7 changes: 0 additions & 7 deletions test/other/test_implicit_func.c

This file was deleted.

12 changes: 0 additions & 12 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -5368,18 +5368,6 @@ def test_global_inits(self):
self.assertContained('argc: 1\n16\n17\n10\n', self.run_js('a.out.js'))
self.assertContainedIf('globalCtors', src, has_global)

def test_implicit_func(self):
# EMCC makes -Wimplicit-function-declaration an error by default in all modes. Upstream LLVM
# emits a warning in gnu89 mode, but otherwise emcc's behavior is identical to upstream.
IMPLICIT_C89 = "error: implicit declaration of function 'strnlen'"
# Also check for -Wincompatible-function-pointer-types (it became an error in LLVM 16)
INCOMPATIBLE = ': incompatible function pointer types'

stderr = self.expect_fail(
[EMCC, path_from_root('test/other/test_implicit_func.c'), '-c', '-o', 'implicit_func.o', '-std=gnu89'])
self.assertContained(IMPLICIT_C89, stderr)
self.assertContained(INCOMPATIBLE, stderr)

@requires_native_clang
@crossplatform
def test_bad_triple(self):
Expand Down
Loading