Actions
Bug #18785
closedRbConfig::MAKEFILE_CONFIG["warnflags"] contains "-Wno-cast-function-type" which is not compatible with clang 13.0.0
Status:
Feedback
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
Description
Hi,
I was having an issue installing the curses gem: https://github.com/ruby/curses/issues/41#issuecomment-1127293843
A minimal reproduction script is:
require "mkmf"
curses = ["ncurses.h"]
convertible_int('chtype', [["#undef MOUSE_MOVED\n"]]+curses)
Then in the output of mkmf.log https://gist.github.com/b938f83aac977cd6db2a2e216b6ff17b
There is:
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dorianmariefr/.asdf/installs/ruby/3.1.2/lib "clang -I/Users/dorianmariefr/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/dorianmariefr/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/dorianmariefr/.asdf/installs/ruby/3.1.2/include/ruby-3.1.0 -I. -I/Users/dorianmariefr/.asdf/installs/ruby/3.1.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -fno-common -pipe -Werror -c conftest.c"
error: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Werror,-Wunknown-warning-option]
checked program was:
/* begin */
1: #include "ruby.h"
2:·
3: #undef MOUSE_MOVED
4:·
5: #include <ncurses.h>
6:·
7: typedef chtype rbcv_typedef_;
8:·
9: extern rbcv_typedef_ foo();
10: extern unsigned long long foo();
/* end */
--------------------
In particular the -Wno-cast-function-type is not compatible with clang 13.0.0
clang -v
Apple clang version 13.0.0 (clang-1300.0.27.3)
Target: arm64-apple-darwin21.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
After debugging, it seems to be coming from RbConfig::MAKEFILE_CONFIG["warnflags"]
:
> RbConfig::MAKEFILE_CONFIG["warnflags"]
=> "-Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef"
Another project had the same issue and the solution seems to be doing feature detection:
https://github.com/tarantool/tarantool/commit/a8c214c2ddf151139b7be70c95328a3a15fe29e2
check_c_compiler_flag("-Wno-cast-function-type" CC_HAS_WNO_CAST_FUNCTION_TYPE)
# ...
if (CC_HAS_WNO_CAST_FUNCTION_TYPE)
add_compile_flags("C;CXX" "-Wno-cast-function-type")
endif()
Actions
Like0
Like0Like0Like0