Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Nov 2018 21:13:49 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 233481] flex/lex: __dead2 define in flex.skl precludes cross compiles for embedded systems
Message-ID:  <bug-233481-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D233481

            Bug ID: 233481
           Summary: flex/lex: __dead2 define in flex.skl precludes cross
                    compiles for embedded systems
           Product: Base System
           Version: 11.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: leres@freebsd.org

We're unable to compile a lex generated module for the openvehicles.com pro=
ject
with the devel/xtensa-esp32-elf toolchain. The problem is the flex/lex
generated code unconditionally defines __dead2 when !defined(__FreeBSD__):

    In file included from
/home/leres/esp/openvehicles-xtensa-esp32-elf/components/newlib/include/std=
io.h:35:0,
                     from
/home/leres/src/Open-Vehicle-Monitoring-System-3/vehicle/OVMS.V3/components=
/dbc/yacclex/dbc_tokeniser.c:30:
=20=20=20
/home/leres/esp/openvehicles-xtensa-esp32-elf/components/newlib/include/sys=
/cdefs.h:246:0:
warning: "__dead2" redefined
     #define __dead2  __attribute__((__noreturn__))
     ^
=20=20=20
/home/leres/src/Open-Vehicle-Monitoring-System-3/vehicle/OVMS.V3/components=
/dbc/yacclex/dbc_tokeniser.c:26:0:
note: this is the location of the previous definition
     #define __dead2

The problem is the generated code unconditionally defines __dead2:

    /* First, we deal with  platform-specific or compiler-specific issues. =
*/

    #if defined(__FreeBSD__)
    #ifndef __STDC_LIMIT_MACROS
    #define __STDC_LIMIT_MACROS
    #endif
    #include <sys/cdefs.h>
    #include <stdint.h>
    #else
    #define __dead2
    #endif

And then later includes stdio.h:

    /* begin standard C headers. */
    #include <stdio.h>
    #include <string.h>
    #include <errno.h>
    #include <stdlib.h>

    /* end standard C headers. */

But stdio.h causes the xtensa-esp32-elf version sys/cdefs.h to be included
which defines __dead2 for the second time:

    #if __GNUC_PREREQ__(2, 7)
    #define __dead2         __attribute__((__noreturn__))
    [...]

The only workaround is to do hacky post-processing on the generated code (or
perhaps use the textproc/flex port which does not patch the standard flex.s=
kl
file).

The attached patch moves the __dead2 define after the "standard C headers" =
are
included and only attempts to define __dead2 if it is not already defined.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-233481-227>