Bug #21793
closedfunction name conflict of "mutex_trylock" on Solaris
Description
On Solaris, with GCC 7.5.0, failed to compile thread.c with "error: conflicting types for 'mutex_trylock'".
On Solaris, the function name mutex_trylock(3C) is already used by the OS.
https://docs.oracle.com/cd/E88353_01/html/E37843/mutex-trylock-3c.html
It is a part of historical pre-POSIX mutex implementation, but it seems that it may still be internally used by the OS.
Could you please change the name of "mutex_trylock" in thread_sync.c:238 to something else?
The compile error message is below:
gcc -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wmisleading-indentation -Wundef -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE -I. -I.ext/include/sparc64-solaris2.10 -I.ext/include -I../ruby.devel/include -I../ruby.devel -I../ruby.devel/prism -I../ruby.devel/enc/unicode/17.0.0 -Dmodular_gc_dir="" -D_XOPEN_SOURCE=600 -I/usr/local/64/lib/libffi-3.0.10/include -I/usr/local/64/include -o thread.o -c ../ruby.devel/thread.c
In file included from ../ruby.devel/thread.c:293:0:
../ruby.devel/thread_sync.c:238:1: error: conflicting types for 'mutex_trylock'
mutex_trylock(rb_mutex_t *mutex, rb_thread_t *th, rb_serial_t ec_serial)
^~~~~~~~~~~~~
In file included from /usr/include/thread.h:24:0,
from ../ruby.devel/thread_pthread.c:21,
from ../ruby.devel/thread.c:278:
/usr/include/synch.h:94:5: note: previous declaration of 'mutex_trylock' was here
int mutex_trylock(mutex_t *);
^~~~~~~~~~~~~
../ruby.devel/thread.c: In function 'rb_gc_set_stack_end':
../ruby.devel/thread.c:4809:44: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
COMPILER_WARNING_IGNORED(-Wdangling-pointer);
^
../ruby.devel/thread.c: At top level:
cc1: warning: unrecognized command line option '-Wno-self-assign'
cc1: warning: unrecognized command line option '-Wno-parentheses-equality'
cc1: warning: unrecognized command line option '-Wno-constant-logical-operand'
cc1: warning: unrecognized command line option '-Wno-cast-function-type'
make: *** [thread.o] Error 1
The mutex_trylock function also exists in the Linux kernel, but is only available when the Linux kernel headers are included, so name conflicts may only occur in very specific, rare cases on Linux.
https://manpages.debian.org/testing/linux-manual-4.8/mutex_trylock.9.en.html
Updated by byroot (Jean Boussier) 1 day ago
- Status changed from Open to Closed
Applied in changeset git|fb1dd92d30a8df93f6fe2746aacc097f4c3ea62b.
thread_sync.c: rename mutex_trylock internal function
[Bug #21793]
To fix a naming conflict on solaris.