[MDEV-9802] [PATCH] Build fails on SmartOS and gcc 4.9.3 Created: 2016-03-27  Updated: 2020-04-04

Status: Open
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.1.8, 10.1.9, 10.1.13
Fix Version/s: 10.1

Type: Bug Priority: Major
Reporter: Brian White Assignee: Vicențiu Ciorbaru
Resolution: Unresolved Votes: 2
Labels: None
Environment:

SmartOS 5.11 joyent_20160317T000621Z, gcc 4.9.3, binutils 2.25.1, gmake 4.1


Issue Links:
Relates
relates to CONC-133 Centos 6 32 bits: Release build error... Closed
relates to MDEV-3830 Intel compiler does not work in 5.5/L... Closed

 Description   

Compilation fails at mysys/my_context.c with:

[ 75%] Building C object mysys/CMakeFiles/mysys.dir/my_rdtsc.c.o
[ 75%] Building C object mysys/CMakeFiles/mysys.dir/my_context.c.o
/var/tmp//ccjkasbn.s: Assembler messages:
/var/tmp//ccjkasbn.s:24: Error: CFI instruction used without previous .cfi_startproc
mysys/CMakeFiles/mysys.dir/build.make:2558: recipe for target 'mysys/CMakeFiles/mysys.dir/my_context.c.o' failed
make[2]: *** [mysys/CMakeFiles/mysys.dir/my_context.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:1463: recipe for target 'mysys/CMakeFiles/mysys.dir/all' failed
make[1]: *** [mysys/CMakeFiles/mysys.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

I found that if I prioritize the #elif defined(HAVE_UCONTEXT_H) check in mysys/my_context.c so that it comes before the 64-bit GNUC check, then it compiles just fine.



 Comments   
Comment by Brian White [ 2016-03-27 ]

I want to add that I have also tried ensuring -g is set in the cflags to workaround a compiler bug on solaris/sunos that was previously discussed on the mariadb mailing list, but no luck.

Comment by Ben Stillman [ 2017-09-07 ]

This is still an issue with 10.2.8 and Joint SmartOS 14.4.0. Brian White's workaround above works, but for 10.2 #elif defined(HAVE_UCONTEXT_H) has moved to include/my_context.h.

Change:

#ifdef __WIN__
#define MY_CONTEXT_USE_WIN32_FIBERS 1
#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__x86_64__) && !defined(__ILP32__)
#define MY_CONTEXT_USE_X86_64_GCC_ASM
#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__i386__)
#define MY_CONTEXT_USE_I386_GCC_ASM
#elif defined(HAVE_UCONTEXT_H)
#define MY_CONTEXT_USE_UCONTEXT
#else
#define MY_CONTEXT_DISABLE
#endif

To:

#ifdef __WIN__
#define MY_CONTEXT_USE_WIN32_FIBERS 1
#elif defined(HAVE_UCONTEXT_H)
#define MY_CONTEXT_USE_UCONTEXT
#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__x86_64__) && !defined(__ILP32__)
#define MY_CONTEXT_USE_X86_64_GCC_ASM
#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__i386__)
#define MY_CONTEXT_USE_I386_GCC_ASM
#else
#define MY_CONTEXT_DISABLE
#endif

Comment by Sergey Vojtovich [ 2017-09-08 ]

knielsen, was there a special reason why ucontext has lower priority than asm implementations?

Comment by Sergey Vojtovich [ 2017-09-08 ]

ben, did you try this on x86_64?

Comment by Kristian Nielsen [ 2017-09-08 ]

> was there a special reason why ucontext has lower priority than asm
> implementations?

Sure, ucontext is much slower. The whole point of the asm implementations
is to get good performance on common platforms, with ucontext as a fallback.

Why not fix the missing .cfi_startproc? I wonder what is special on the
SmartOS platform for this to show up only there?

Try generating the assembler output from my_context.c (gcc -S) and check
where the .cfi_escape instruction ends up and why there is no .cfi_startproc
on that function.

Does my_context_spawn() need _attribute_((noinline))?
Or is dwarf debug info maybe disabled on that platform?

If the .cfi_escape is not available on SmartOS, it can just be disabled in
the code, there is already an #ifdef for other situations. The .cfi_escape
is just a hint to debuggers that the stack trace ends here, it can be safely
omitted from the code.

(But it would still be interesting to see the assembler output from the
compiler to understand what is going on).

Comment by Valerii Kravchuk [ 2017-09-11 ]

OpenIndiana Hipster edition is also affected:

openxs@hipster:~/git/server$ uname -a
SunOS hipster 5.11 illumos-f8554bb i86pc i386 i86pc Solaris

The fix described by Ben above helped to proceed.

Comment by Rainer Orth [ 2018-01-25 ]

I've just run into the same issue when compiling MariaDB 10.2.12 on Solaris 11.4
Beta with the bundled gcc 5.5 (64-bit-default configuration).

The issue is in no way SmartOS-specific, but can happen on any x86 target: gcc
checks at build time if the toolchain used (assembler and linker) do support the
.cfi_* directives. If it doesn't (support is incomplete or buggy or there are other issues
as on Solaris with the bundled linker), it disables support for them and instead
open-codes unwind info.

In such a case (when the assembler is partially able to handle cfi directives), it
will complain about missing .cfi_startproc.

There are several ways out of this:

  • If (as it turned out in my case) gcc's configure check for cfi directive use is buggy,
    one can just override it with -fdwarf2-cfi-asm.
  • To avoid compilation failures with the unconditional use of cfi directives (.cfi_escape here), one can check for __GCC_HAVE_DWARF2_CFI_ASM which gcc predefines.
  • And finally one could open-code the .eh_frame section, as is done e.g. in libffi.

For the moment, the middle option should be use to avoid using cfi directives
if the toolchain cannot support them!

Generated at Thu Feb 08 07:37:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.