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

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jan 22, 2025

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.

This change only effect C and not C++.

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.

@sbc100 sbc100 requested a review from dschuff January 22, 2025 00:53
@sbc100 sbc100 changed the title Remove injection of -Werror=implicit-function-declaration. NFC Remove injection of -Werror=implicit-function-declaration Jan 22, 2025
@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 22, 2025

Indeed, based on #2175 it looks like these errors used to result in run time crashes, but now they will result in linker failure (including the names of the function and the two object files that disagree about its signature).

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.
@sbc100 sbc100 force-pushed the remove_clang_change branch from bb1ac2d to fa61c74 Compare January 22, 2025 00:56
@sbc100 sbc100 requested a review from kripken January 22, 2025 00:56
@dschuff
Copy link
Member

dschuff commented Jan 22, 2025

Yeah I think this makes sense. This was from before we even had a linker and were just generating output blindly.

@dschuff
Copy link
Member

dschuff commented Jan 22, 2025

do we have a test for the linker behavior?

@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 22, 2025

do we have a test for the linker behavior?

We certainly have plenty of signature-mismatch tests in wasm-ld. I don't know if we also test that downstream, but it doesn't seem necessary.

@sbc100 sbc100 enabled auto-merge (squash) January 22, 2025 01:41
@sbc100 sbc100 merged commit 61c9bd2 into emscripten-core:main Jan 22, 2025
29 checks passed
@sbc100 sbc100 deleted the remove_clang_change branch January 22, 2025 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants