From db20cfd095229b79d97337e60ff4154c3c986970 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 23 Jul 2020 16:03:06 +0800 Subject: [PATCH] ceph.spec.in: cull _FORTIFY_SOURCE macro from CXXFLAGS for seastar seastar uses setjmp() and longjmp() to implement coroutine, but longjmp() is defined as ____longjmp_chk() by GCC if _FORTIFY_SOURC is defined. ____longjmp_chk() simply bails out with an error message if the dest stack pointer is higher than the src stack pointer, or the dest stack pointer is not in the sigaltstack. in the case of seastar, the dst %sp is not necessarily higher than src stack pointer, and it's not handling a signal for switching the thread context. that's why we have the "longjmp causes uninitialized stack frame" error when running crimson-osd on RHEL/CentOS 8 using the prebuilt rpm packages. the optflags rpm macro adds -D_FORTIFY_SOURCE=2 to CFLAGS and CXXFLAGS, so even seastar tries to pass -U_FORTIFY_SOURCE to GCC, there is chance that cmake append CXXFLAGS at the end of the option list passed to GCC. and this renders seastar's attempt to undefine _FORTIFY_SOURCE useless. another way to address this issue is to undefine this macro in seastar:src/core/thread.cc. but since seastar tries neutralize the macro in its cmake script instead of source file, i assume they have their considerations. let's drop it in the rpm recipe instead. Signed-off-by: Kefu Chai --- ceph.spec.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ceph.spec.in b/ceph.spec.in index ea1238f1f0b..4b20dc2fa19 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -1086,6 +1086,11 @@ export CFLAGS="$RPM_OPT_FLAGS" export CXXFLAGS="$RPM_OPT_FLAGS" export LDFLAGS="$RPM_LD_FLAGS" +%if 0%{with seastar} +# seastar uses longjmp() to implement coroutine. and this annoys longjmp_chk() +export CXXFLAGS=$(echo $RPM_OPT_FLAGS | sed -e 's/-Wp,-D_FORTIFY_SOURCE=2//g') +%endif + # Parallel build settings ... CEPH_MFLAGS_JOBS="%{?_smp_mflags}" CEPH_SMP_NCPUS=$(echo "$CEPH_MFLAGS_JOBS" | sed 's/-j//') -- 2.39.5