Skip to content
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

FTBFS - Cast function type mismatch #851

Open
melizasw opened this issue Nov 1, 2024 · 2 comments
Open

FTBFS - Cast function type mismatch #851

melizasw opened this issue Nov 1, 2024 · 2 comments

Comments

@melizasw
Copy link

melizasw commented Nov 1, 2024

Shows up with Clang 19.1.2 but not with Clang 16.0.6. This is when building Swift 5.8.1, but it looks like this code hasn't changed since then.

swift-corelibs-libdispatch/src/apply.c:366:4: error: cast from 'dispatch_function_t' (aka 'void ()(void * _Nullable)') to 'dispatch_apply_function_t' (aka 'void ()(void *, unsigned long)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch]
366 | (dispatch_apply_function_t)_dispatch_Block_invoke(work));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@ggardet
Copy link

ggardet commented Nov 27, 2024

Fails also with 5.10.1 and Clang 19.1.4:

[   19s] FAILED: src/CMakeFiles/dispatch.dir/apply.c.o 
[   19s] /usr/bin/clang -DDISPATCH_USE_DTRACE=0 -DHAVE_CONFIG_H -D_GNU_SOURCE=1 -Ddispatch_EXPORTS -I/home/abuild/rpmbuild/BUILD/swift-corelibs-libdispatch-swift-5.10.1-RELEASE/build -I/home/abuild/rpmbuild/BUILD/swift-corelibs-libdispatch-swift-5.10.1-RELEASE -I/home/abuild/rpmbuild/BUILD/swift-corelibs-libdispatch-swift-5.10.1-RELEASE/src -I/home/abuild/rpmbuild/BUILD/swift-corelibs-libdispatch-swift-5.10.1-RELEASE/build/src -I/home/abuild/rpmbuild/BUILD/swift-corelibs-libdispatch-swift-5.10.1-RELEASE/private -I/home/abuild/rpmbuild/BUILD/swift-corelibs-libdispatch-swift-5.10.1-RELEASE/src/BlocksRuntime -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto -g -O2 -g -DNDEBUG -std=gnu11 -fPIC -fvisibility=hidden -Werror -Wall -Wextra -Warray-bounds-pointer-arithmetic -Wassign-enum -Watomic-properties -Wcomma -Wconditional-uninitialized -Wconversion -Wcovered-switch-default -Wdate-time -Wdeprecated -Wdocumentation -Wdouble-promotion -Wduplicate-enum -Wexpansion-to-defined -Wfloat-equal -Widiomatic-parentheses -Winfinite-recursion -Wmissing-prototypes -Wnewline-eof -Wnullable-to-nonnull-conversion -Wobjc-interface-ivars -Wover-aligned -Wpacked -Wpointer-arith -Wselector -Wshadow -Wshorten-64-to-32 -Wsign-conversion -Wstatic-in-inline -Wsuper-class-method-mismatch -Wswitch -Wunguarded-availability -Wunreachable-code -Wunused -Wno-unknown-warning-option -Wno-trigraphs -Wno-four-char-constants -Wno-disabled-macro-expansion -Wno-pedantic -Wno-bad-function-cast -Wno-c++-compat -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-cast-align -Wno-cast-qual -Wno-documentation-unknown-command -Wno-format-nonliteral -Wno-missing-variable-declarations -Wno-old-style-cast -Wno-padded -Wno-reserved-id-macro -Wno-shift-sign-overflow -Wno-undef -Wno-unreachable-code-aggressive -Wno-unused-macros -Wno-used-but-marked-unused -Wno-void-pointer-to-int-cast -Wno-vla -Wno-error=assign-enum -fmodule-map-file=/home/abuild/rpmbuild/BUILD/swift-corelibs-libdispatch-swift-5.10.1-RELEASE/dispatch/generic/module.modulemap -fmodule-map-file=/home/abuild/rpmbuild/BUILD/swift-corelibs-libdispatch-swift-5.10.1-RELEASE/private/generic/module.modulemap -fno-exceptions -fblocks -momit-leaf-frame-pointer -MD -MT src/CMakeFiles/dispatch.dir/apply.c.o -MF src/CMakeFiles/dispatch.dir/apply.c.o.d -o src/CMakeFiles/dispatch.dir/apply.c.o -c /home/abuild/rpmbuild/BUILD/swift-corelibs-libdispatch-swift-5.10.1-RELEASE/src/apply.c
[   19s] /home/abuild/rpmbuild/BUILD/swift-corelibs-libdispatch-swift-5.10.1-RELEASE/src/apply.c:366:4: error: cast from 'dispatch_function_t' (aka 'void (*)(void * _Nullable)') to 'dispatch_apply_function_t' (aka 'void (*)(void *, unsigned long)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch]
[   19s]   366 |                         (dispatch_apply_function_t)_dispatch_Block_invoke(work));
[   19s]       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[   19s] 1 error generated.

@xuzhen
Copy link

xuzhen commented Dec 21, 2024

Wrote a patch to ignore that error

--- a/cmake/modules/DispatchCompilerWarnings.cmake	2024-12-21 23:02:06.831097446 +0800
+++ b/cmake/modules/DispatchCompilerWarnings.cmake	2024-12-21 23:01:41.086280651 +0800
@@ -50,6 +50,7 @@
   add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-disabled-macro-expansion>)
   add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-pedantic>)
   add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-bad-function-cast>)
+  add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-cast-function-type-mismatch>)
   add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-c++-compat>)
   add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-c++98-compat>)
   add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-c++98-compat-pedantic>)

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

No branches or pull requests

3 participants