Opened 4 years ago

Last modified 3 years ago

#59927 closed defect

bison @3.5 does not build with older gcc versions (gcc-4.2 and similar) because "#pragma GCC diagnostic not allowed inside functions" — at Version 4

Reported by: ballapete (Peter "Pete" Dyballa) Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.6.2
Keywords: Cc: Schamschula (Marius Schamschula)
Port: bison

Description (last modified by kencu (Ken))

This error shows up on systems that default to gcc-4.2 (10.4 and 10.5):

/opt/local/bin/gcc-apple-4.2 -std=gnu99 -DEXEEXT=\"\"   -I. -I./lib -I. -I./lib -DINSTALLDIR=\"/opt/local/bin\" -I/opt/local/include   -pipe -Os -arch ppc -MT src/bison-InadequacyList.o -MD -MP -MF src/.deps/bison-InadequacyList.Tpo -c -o src/bison-InadequacyList.o `test -f 'src/InadequacyList.c' || echo './'`src/InadequacyList.c
src/InadequacyList.c: In function 'InadequacyList__new_conflict':
src/InadequacyList.c:37: error: #pragma GCC diagnostic not allowed inside functions
src/InadequacyList.c:37: error: #pragma GCC diagnostic not allowed inside functions
src/InadequacyList.c:40: error: #pragma GCC diagnostic not allowed inside functions
make: *** [src/bison-InadequacyList.o] Error 1
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_lil.fr.rsync.macports.org_release_tarballs_ports_devel_bison/bison/work/bison-3.5'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_lil.fr.rsync.macports.org_release_tarballs_ports_devel_bison/bison/work/bison-3.5" && /usr/bin/make -w all 
Exit code: 2

Change History (5)

Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Attachment: main.log added

Main.log from PPC Tiger

comment:1 Changed 4 years ago by jmroot (Joshua Root)

Cc: Schamschula added

comment:2 Changed 4 years ago by kencu (Ken)

bison was broken by this thread and commit <https://lists.gnu.org/archive/html/bug-bison/2019-10/msg00061.html> and the test for GCC is not quite right yet.

In libuv we use this.

#if defined(__GNUC__)
#define GCC_VERSION \
	(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif
#if defined(__clang__) || (defined(GCC_VERSION) && (GCC_VERSION >= 40500))
/* gcc diagnostic pragmas available */
# define GCC_DIAGNOSTIC_AVAILABLE
#endif

In bison in src/system.h:

/* See https://lists.gnu.org/archive/html/bug-bison/2019-10/msg00061.html. */
# if defined __GNUC__ && ! defined __clang__ && ! defined __ICC && __GNUC__ < 5
#  define IGNORE_TYPE_LIMITS_BEGIN \
     _Pragma ("GCC diagnostic push") \
     _Pragma ("GCC diagnostic ignored \"-Wtype-limits\"")
#  define IGNORE_TYPE_LIMITS_END \
     _Pragma ("GCC diagnostic pop")
# else
#  define IGNORE_TYPE_LIMITS_BEGIN
#  define IGNORE_TYPE_LIMITS_END
# endif

That block needs to be adjusted so that older gcc versions fall through to the no-ops.

comment:3 Changed 4 years ago by kencu (Ken)

Changing the test to disable the macro indeed fixes it.

BTW, you don't need Tiger to test this. Just force a build with any gcc-4.2 version, eg on Lion:

sudo port -v destroot bison configure.compiler=llvm-gcc-4.2

comment:4 Changed 4 years ago by kencu (Ken)

Description: modified (diff)
Keywords: tiger removed
Summary: bison @3.5 does not build on PPC Tiger, Mac OS X 10.4.11, because "#pragma GCC diagnostic not allowed inside functions"bison @3.5 does not build with older gcc versions (gcc-4.2 and similar) because "#pragma GCC diagnostic not allowed inside functions"
Note: See TracTickets for help on using tickets.