# HG changeset patch # User John D # Date 1513868323 18000 # Node ID a0e30199373f9a1c082a433596320ff6350e9492 # Parent 50ce0842665c9e2a9a9666f6722a37ba40db9c65 build-flex: add patch for new gcc version issues (Bug #52708) * src/build-flex-1-fixes.patch: new file * dist-files.mk: add ref to build-flex-1-fixes.patch diff -r 50ce0842665c -r a0e30199373f dist-files.mk --- a/dist-files.mk Tue Dec 19 13:13:25 2017 -0500 +++ b/dist-files.mk Thu Dec 21 09:58:43 2017 -0500 @@ -25,6 +25,7 @@ build-binutils.mk \ build-bison.mk \ build-cmake.mk \ + build-flex-1-fixes.patch \ build-flex.mk \ build-gawk.mk \ build-gcc.mk \ diff -r 50ce0842665c -r a0e30199373f src/build-flex-1-fixes.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-flex-1-fixes.patch Thu Dec 21 09:58:43 2017 -0500 @@ -0,0 +1,50 @@ +From 4b5111d9772b5c160340ca96f08d30d7f6db5cda Mon Sep 17 00:00:00 2001 +From: Explorer09 +Date: Mon, 4 Sep 2017 08:28:53 +0800 +Subject: [PATCH] scanner: Include flexdef.h at %top block of scan.l + +config.h may define macros that alter the API of the standard library +funtions, and so it should be included before any other standard +header, even before the skeleton's standard header inclusion. + +For example: config.h may #define _GNU_SOURCE that would expose the +reallocarray() prototype from on glibc 2.26+ systems. If we +include before config.h, reallocarray() would not be +available for use in lex file since the second include doesn't help +due to header guard. + +For now our config.h might `#define malloc rpl_malloc` -- this +substitution must work before including stdlib.h, or else the compiler +will complain about missing prototypes, and may result in incorrect +code in scan.l (gcc warning: return makes pointer from integer without +a cast [-Wint-conversion]). + +Fixes #247. +--- + src/scan.l | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/scan.l b/src/scan.l +index 3995bcf1..4f497acd 100644 +--- a/src/scan.l ++++ b/src/scan.l +@@ -1,5 +1,11 @@ + /* scan.l - scanner for flex input -*-C-*- */ + ++%top{ ++/* flexdef.h includes config.h, which may contain macros that alter the API */ ++/* of libc functions. Must include first before any libc header. */ ++#include "flexdef.h" ++} ++ + %{ + /* Copyright (c) 1990 The Regents of the University of California. */ + /* All rights reserved. */ +@@ -32,7 +38,6 @@ + /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */ + /* PURPOSE. */ + +-#include "flexdef.h" + #include "parse.h" + extern bool tablesverify, tablesext; + extern int trlcontxt; /* Set in parse.y for each rule. */