Bug #49521
openbuild failure on centos-8, bad/incorrect use of #ifdef/#elif
0%
Description
building 15.2.9 for CentOS Storage SIG el8 I hit this compile error:
cmake ... -DWITH_REENTRANT_STRSIGNAL=ON ...
...
[ 8%] Building CXX object src/mgr/CMakeFiles/mgr_cap_obj.dir/MgrCap.cc.o
cd /builddir/build/BUILD/ceph-15.2.9/build/src/mgr && /usr/bin/c++ -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D__linux__ -isystem /builddir/build/BUILD/ceph-15.2.9/build/boost/include -I/builddir/build/BUILD/ceph-15.2.9/build/src/include -I/builddir/build/BUILD/ceph-15.2.9/src -isystem /builddir/build/BUILD/ceph-15.2.9/build/include -isystem /builddir/build/BUILD/ceph-15.2.9/src/xxHash -isystem /builddir/build/BUILD/ceph-15.2.9/src/rapidjson/include -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wall -fno-strict-aliasing -fsigned-char -Wtype-limits -Wignored-qualifiers -Wpointer-arith -Werror=format-security -Winit-self -Wno-unknown-pragmas -rdynamic -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-unknown-pragmas -Wnon-virtual-dtor -Wno-ignored-qualifiers -ftemplate-depth-1024 -Wstrict-null-sentinel -Woverloaded-virtual -fno-new-ttp-matching -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fdiagnostics-color=auto -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -O2 -g -DNDEBUG -fPIC -DHAVE_CONFIG_H -D__CEPH__ -D_REENTRANT -D_THREAD_SAFE -D__STDC_FORMAT_MACROS -std=c++1z -o CMakeFiles/mgr_cap_obj.dir/MgrCap.cc.o -c /builddir/build/BUILD/ceph-15.2.9/src/mgr/MgrCap.cc
In file included from /builddir/build/BUILD/ceph-15.2.9/src/global/global_init.cc:26:
/builddir/build/BUILD/ceph-15.2.9/src/global/signal_handler.h:25:31: error: #elif with no expression
#elif HAVE_REENTRANT_STRSIGNAL
^
make2: Leaving directory '/builddir/build/BUILD/ceph-15.2.9/build'
...
This is apparently due to the change made for 15.2.9 in commit bb85219ea47f0b8ebb6027e78fadd156be9950ee (octopus), and b9b6faf66ae67648626470cb4fc3f0850ac4d842 (main/master). Also in nautilus and pacific branches.
I fixed it with:
--- ceph-15.2.9/src/global/signal_handler.h.orig 2021-02-26 15:34:39.500250672 -0500
+++ ceph-15.2.9/src/global/signal_handler.h 2021-02-26 15:35:39.514842687 -0500@ -20,9 +20,9
@
typedef void (*signal_handler_t)(int);
-#ifdef HAVE_SIGDESCR_NP
+#if defined(HAVE_SIGDESCR_NP)
# define sig_str(signum) sigdescr_np(signum)
-#elif HAVE_REENTRANT_STRSIGNAL
+#elif defined(HAVE_REENTRANT_STRSIGNAL)
# define sig_str(signum) strsignal(signum)
#else
# define sig_str(signum) sys_siglist[signum]
For good measure I also made this change:
--- ceph-15.2.9/src/include/config-h.in.cmake.orig 2021-02-26 13:32:11.218444320 -0500
+++ ceph-15.2.9/src/include/config-h.in.cmake 2021-02-26 15:00:31.976950884 -0500@ -1,7 +1,6
@
/* config.h file expanded by Cmake for build */
#ifndef CONFIG_H#define CONFIG_H
+#pragma once
/* fallocate(2) is supported /
#cmakedefine CEPH_HAVE_FALLOCATE
@ -354,4 +353,3
@
/ Define if RWL is enabled */
#cmakedefine WITH_RBD_RWL
-#endif /* CONFIG_H */
Updated by Kaleb KEITHLEY about 3 years ago
N.B. fedora-33 and later have sigdescr_np(); ditto for rhel-9.
Also strsignal(3) is not MT-SAFE. (It's also not reentrant.) MT-SAFE is the more important distinction and the choice of HAVE_REENTRANT_STRSIGNAL is a tad misleading.
Updated by Sage Weil almost 3 years ago
- Project changed from Ceph to RADOS
- Category deleted (
common)