Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-753

[PATCH] Build fails on SmartOS and gcc 4.9.3

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 3.3.15
    • Non blocking API
    • None
    • SmartOS 5.11 joyent_20160317T000621Z, gcc 4.9.3, binutils 2.25.1, gmake 4.1

    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.

      Attachments

        Issue Links

          Activity

            > 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).

            knielsen Kristian Nielsen added a comment - > 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).

            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.

            valerii Valerii Kravchuk added a comment - 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.
            ro Rainer Orth added a comment -

            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!

            ro Rainer Orth added a comment - 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!

            cvicentiu I have a patch for this, so grabbing this if that's ok.

            knielsen Kristian Nielsen added a comment - cvicentiu I have a patch for this, so grabbing this if that's ok.

            Merged to 3.3

            knielsen Kristian Nielsen added a comment - Merged to 3.3

            People

              knielsen Kristian Nielsen
              mscdex Brian White
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.