Skip to content

[LLVMgold] Suppress -Wcast-function-type-mismatch diagnostic #89994

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

Conversation

MaskRay
Copy link
Member

@MaskRay MaskRay commented Apr 24, 2024

llvm/cmake/modules/HandleLLVMOptions.cmake adds -Wextra.
-Wcast-function-type-mismatch was recently added to -Wextra, leading to
a warning for the get_wrap_symbols code (https://reviews.llvm.org/D44235).

Suppress the diagnostic.

Created using spr 1.3.5-bogner
@llvmbot llvmbot added the LTO Link time optimization (regular/full LTO or ThinLTO) label Apr 24, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 24, 2024

@llvm/pr-subscribers-lto

Author: Fangrui Song (MaskRay)

Changes

llvm/cmake/modules/HandleLLVMOptions.cmake adds -Wextra.
-Wcast-function-type-mismatch was recently added to -Wextra, leading to
a warning for the get_wrap_symbols code (https://reviews.llvm.org/D44235).

Suppress the diagnostic.


Full diff: https://github.com/llvm/llvm-project/pull/89994.diff

1 Files Affected:

  • (modified) llvm/tools/gold/gold-plugin.cpp (+8-2)
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index b8a33f74bd570f..b8431334f8487c 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -434,8 +434,14 @@ ld_plugin_status onload(ld_plugin_tv *tv) {
       // FIXME: When binutils 2.31 (containing gold 1.16) is the minimum
       // required version, this should be changed to:
       // get_wrap_symbols = tv->tv_u.tv_get_wrap_symbols;
-      get_wrap_symbols =
-          (ld_plugin_get_wrap_symbols)tv->tv_u.tv_message;
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-function-type"
+#endif
+      get_wrap_symbols = (ld_plugin_get_wrap_symbols)tv->tv_u.tv_message;
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
       break;
     default:
       break;

@MaskRay
Copy link
Member Author

MaskRay commented Apr 24, 2024

@Abhinkop

@MaskRay MaskRay merged commit 0b01b21 into main Apr 25, 2024
3 of 4 checks passed
@MaskRay MaskRay deleted the users/MaskRay/spr/llvmgold-suppress-wcast-function-type-mismatch-diagnostic branch April 25, 2024 18:25
@UsmanNadeem
Copy link
Contributor

This change is breaking some of our build bots because -Wcast-function-type is only supported in clang 13.0+
I am not familiar with this warning but can this be fixed without suppressing the warning, like other patches e.g. #76875 and #86290

llvm/tools/gold/gold-plugin.cpp:475:32: error: unknown warning group '-Wcast-function-type', ignored [-Werror,-Wunknown-warning-option]
#pragma GCC diagnostic ignored "-Wcast-function-type"
^
1 error generated.

https://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library lists Clang 5.0, we are using clang 12.

@MaskRay
Copy link
Member Author

MaskRay commented May 15, 2024

I think we could use a union, but the mechanism would be too heavy.

llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library lists Clang 5.0, we are using clang 12.

While we support older clang versions down to 5, we cannot support -Werror for all of them, since every version might fix some false positives present in older versions...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTO Link time optimization (regular/full LTO or ThinLTO)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants