Opened 10 months ago

Closed 10 months ago

Last modified 5 months ago

#59927 closed defect (fixed)

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

Reported by: ballapete (Peter Dyballa) Owned by: kencu (Ken)
Priority: Normal Milestone:
Component: ports Version: 2.6.2
Keywords: Cc: Schamschula (Marius Schamschula), akimd (Akim Demaille)
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

Attachments (2)

main.log (117.4 KB) - added by ballapete (Peter Dyballa) 10 months ago.
Main.log from PPC Tiger
bison-3.5.3.13.log (221.9 KB) - added by kencu (Ken) 7 months ago.

Download all attachments as: .zip

Change History (36)

Changed 10 months ago by ballapete (Peter Dyballa)

Attachment: main.log added

Main.log from PPC Tiger

comment:1 Changed 10 months ago by jmroot (Joshua Root)

Cc: Schamschula added

comment:2 Changed 10 months 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 10 months 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 10 months 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"

comment:5 Changed 10 months ago by kencu (Ken)

Even if that is fixed, the test suite for bison won't run, due to other errors related to older gcc versions:

/usr/bin/llvm-gcc-4.2 -std=gnu99 -DEXEEXT=\"\"   -I./examples/c/reccalc -I./examples/c/reccalc -I/opt/local/include  -pipe -Os -arch x86_64 -MT examples/c/reccalc/reccalc-parse.o -MD -MP -MF examples/c/reccalc/.deps/reccalc-parse.Tpo -c -o examples/c/reccalc/reccalc-parse.o `test -f 'examples/c/reccalc/parse.c' || echo './'`examples/c/reccalc/parse.c
In file included from examples/c/reccalc/parse.c:1678:
examples/c/reccalc/scan.h:112: error: redefinition of typedef 'yyscan_t'
examples/c/reccalc/parse.c:117: error: previous declaration of 'yyscan_t' was here
make[3]: *** [examples/c/reccalc/reccalc-parse.o] Error 1

It's looking simpler, perhaps, to just require a newer c compiler with

compiler.c_standard 2011

comment:6 Changed 10 months ago by ballapete (Peter Dyballa)

On PPC Leopard, Mac OS X 10.5.8, the same failure happens.

comment:7 Changed 10 months ago by kencu (Ken)

unfortunately

compiler.c_standard 2011

does not work on Tiger PPC, as you then later get this error:

In file included from lib/strverscmp.c:21:0:
./lib/libc-config.h:78:21: error: operator '%' has no left operand
 # define __WORDSIZE %%%
                     ^
./lib/libc-config.h:78:21: error: operator '%' has no left operand
 # define __WORDSIZE %%%
                     ^

comment:8 in reply to:  7 Changed 10 months ago by ballapete (Peter Dyballa)

Replying to kencu:

On Leopard bison @3.5 built with GCC7.

comment:9 Changed 10 months ago by kencu (Ken)

but throwing in the definition to lib/libc-config.h, works:

#define __WORDSIZE 32

bison does some trickery in libc-config.h that I don't fully understand to not include some standard headers...

comment:10 Changed 10 months ago by kencu (Ken)

OK, so Leopard does work, Tiger fails for odd reasons. Probably have to throw in the __WORDSIZE definition on Tiger, unless we sort out why it is needed there in the first place and fix that.

Last edited 10 months ago by kencu (Ken) (previous) (diff)

comment:11 Changed 10 months ago by kencu (Ken)

comment:12 Changed 10 months ago by kencu (Ken)

Owner: set to kencu
Resolution: fixed
Status: newclosed

In 421e073d982bbc8461a419183e65a6504dbd6e19/macports-ports (master):

bison: require C11

the build uses C11 features in the test builds
and requires newer gcc versions to support the
pragmas inside functions

closes: #59927

comment:13 in reply to:  5 Changed 10 months ago by jmroot (Joshua Root)

Replying to kencu:

Even if that is fixed, the test suite for bison won't run, due to other errors related to older gcc versions:

/usr/bin/llvm-gcc-4.2 -std=gnu99 -DEXEEXT=\"\"   -I./examples/c/reccalc -I./examples/c/reccalc -I/opt/local/include  -pipe -Os -arch x86_64 -MT examples/c/reccalc/reccalc-parse.o -MD -MP -MF examples/c/reccalc/.deps/reccalc-parse.Tpo -c -o examples/c/reccalc/reccalc-parse.o `test -f 'examples/c/reccalc/parse.c' || echo './'`examples/c/reccalc/parse.c
In file included from examples/c/reccalc/parse.c:1678:
examples/c/reccalc/scan.h:112: error: redefinition of typedef 'yyscan_t'
examples/c/reccalc/parse.c:117: error: previous declaration of 'yyscan_t' was here
make[3]: *** [examples/c/reccalc/reccalc-parse.o] Error 1

Please report this upstream; it's clearly a bug to be both redefining typedefs and building with -std=gnu99.

comment:14 Changed 9 months ago by kencu (Ken)

bit confusing... some google hits suggest redefining typedefs is allowed by gnu99, but the exact gcc and clang versions may handle the situation differently...

will see if a clear understanding is possible...

comment:15 Changed 7 months ago by ballapete (Peter Dyballa)

  bison @3.5.3_0 (active) platform='darwin 8' archs='ppc' date='2020-03-21T17:54:43+0100'
  bison-runtime @3.5.3_0 (active) platform='darwin 8' archs='noarch' date='2020-03-21T17:44:26+0100'

built on PPC Tiger, Mac OS X 10.4.11, today.

comment:16 Changed 7 months ago by akimd (Akim Demaille)

Hi,

I'm the Bison upstream maintainer.

Why on Earth this was never reported to bug-bison@…? I was told about this issue *today*, three all months afterwards. As you may have noticed, we make quite frequent bug fix releases, the last one being 3.5.3. We should have known about this earlier, the bugs/issues would have been fixed long ago.

Bison does not require C11 to build.

None of these errors are visible on our CI. We need your input to improve Bison. Please, work with us.

comment:17 Changed 7 months ago by kencu (Ken)

Well, that's nice to hear.

Honest truth is not many upstream projects are too interested in tweaking builds for compilers like gcc-4.2 any more, and working around things missing from the MacOSX Tiger headers even less, so we are fairly used to doing a little surgery on these ports for our rather dedicated legacy system user base.

redefining typedefs was introduced in some compiler version > gcc-4.2 -- I don't recall just when it occurred -- but in the way MacPorts works, it's basically a built-in next compiler step to set the bar at C11 and that sets a generation of compilers that do work rather than doing a lot of experimenting to find out just exactly which version of gcc allowed it and then undertaking a project of blacklisting or fallbacking.

Appreciate your interest.

comment:18 in reply to:  17 Changed 7 months ago by akimd (Akim Demaille)

Hi Ken,

Replying to kencu:

Well, that's nice to hear.

Honest truth is not many upstream projects are too interested in tweaking builds for compilers like gcc-4.2 any more, and working around things missing from the MacOSX Tiger headers even less, so we are fairly used to doing a little surgery on these ports for our rather dedicated legacy system user base.

Ok, I see. Out of curiosity: how long do you plan on keeping these platforms updated?

I'm using Travis for the CI, and unfortunately I don't think I can run GCC 4.2 over there, the oldest we have currently is 4.6 (see https://travis-ci.org/github/akimd/bison/builds/669995270 for instance).

redefining typedefs was introduced in some compiler version > gcc-4.2 -- I don't recall just when it occurred --

Yep, it's C11, rejected in C99.

I took care of two issues:

  • the pragmas for diagnostics
  • the double typedef

So it is my understanding that in this case the C11 compiler is no longer needed, and as a consequence the WORDSIZE hack is no longer needed either, right? Do you have means to check a tarball? If you can, please give a shot at this one:

https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.3-6e89b.tar.gz https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.3-6e89b.tar.xz

I'll release it once I know it addresses your concerns.

Cheers!

comment:19 Changed 7 months ago by kencu (Ken)

thanks. i'll test it tomorrow, assuming cv-19 doesn't get me overnight...

comment:20 Changed 7 months ago by akimd (Akim Demaille)

Hi Ken,

If you have some spare time, I'm ready to release 3.5.4, I'm just waiting for your ACK. Please use these tarballs instead.

https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.9-21320.tar.gz https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.9-21320.tar.xz

Cheers!

comment:21 Changed 7 months ago by kencu (Ken)

apologies for delay-will get on it in a few hours in am.

comment:22 Changed 7 months ago by akimd (Akim Demaille)

comment:23 Changed 7 months ago by akimd (Akim Demaille)

Hi Ken,

Sorry to insist, but I would like to release 3.5.4 today. Cheers!

comment:24 Changed 7 months ago by akimd (Akim Demaille)

Cc: akimd added

comment:25 Changed 7 months ago by akimd (Akim Demaille)

(Actually, I need feedback from anybody on PPC Tiger, it doesn't have to be Ken.)

comment:26 Changed 7 months ago by kencu (Ken)

Hi Akim -- can you recheck that URL?

$ sudo wget https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.9-c199f-dirty.tar.xz
--2020-04-04 22:55:06--  https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.9-c199f-dirty.tar.xz
Resolving www.lrde.epita.fr (www.lrde.epita.fr)... 163.5.55.8
Connecting to www.lrde.epita.fr (www.lrde.epita.fr)|163.5.55.8|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2020-04-04 22:55:07 ERROR 404: Not Found.

$ sudo wget https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.9-c199f-dirty.tar.gz
--2020-04-04 22:55:19--  https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.9-c199f-dirty.tar.gz
Resolving www.lrde.epita.fr (www.lrde.epita.fr)... 163.5.55.8
Connecting to www.lrde.epita.fr (www.lrde.epita.fr)|163.5.55.8|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2020-04-04 22:55:20 ERROR 404: Not Found.

comment:27 Changed 7 months ago by akimd (Akim Demaille)

Doh... My uploading script was not -dirty compliant, and I was stupid enough to forget the damn set -e...

I'm sorry for the waste of time. Here's a newer one:

https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.13-961ea.tar.gz https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.13-961ea.tar.xz

Thanks!

comment:28 Changed 7 months ago by kencu (Ken)

It's building now! I'll run the tests and report back shortly.

comment:29 Changed 7 months ago by kencu (Ken)

When the compiler gcc-4.2 is used, there still is a redefinition error here when building the tests :

updating examples/c/reccalc/parse.output
updating examples/c/reccalc/parse.h
/opt/local/bin/gcc-apple-4.2 -std=gnu99 -DEXEEXT=\"\"   -I./examples/c/reccalc -I./examples/c/reccalc -I/opt/local/include  -pipe -Os -arch ppc -MT examples/c/reccalc/reccalc-parse.o -MD -MP -MF examples/c/reccalc/.deps/reccalc-parse.Tpo -c -o examples/c/reccalc/reccalc-parse.o `test -f 'examples/c/reccalc/parse.c' || echo './'`examples/c/reccalc/parse.c
examples/c/reccalc/parse.c:1680: error: redefinition of typedef 'yyscan_t'
examples/c/reccalc/parse.c:117: error: previous declaration of 'yyscan_t' was here
make[3]: *** [Makefile:6952: examples/c/reccalc/reccalc-parse.o] Error 1

Changed 7 months ago by kencu (Ken)

Attachment: bison-3.5.3.13.log added

comment:30 Changed 7 months ago by kencu (Ken)

when I force the compiler to gcc7, it gets past the redefinition error, but still has the WORDSIZE error (which is a deficiency in the Tiger stdint.h header):

lib/strverscmp.c
In file included from lib/strverscmp.c:21:0:
./lib/libc-config.h:87:21: error: operator '%' has no left operand
 # define __WORDSIZE %%%
                     ^
./lib/libc-config.h:87:21: error: operator '%' has no left operand
 # define __WORDSIZE %%%
                     ^
make: *** [Makefile:6630: lib/libbison_a-strverscmp.o] Error 1

comment:31 Changed 7 months ago by akimd (Akim Demaille)

Sorry about the yyscan_t failure, I was really stupid. This tarball should really fix it this time.

https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.14-6788.tar.gz https://www.lrde.epita.fr/~akim/private/bison/bison-3.5.3.14-6788.tar.xz

For the other one, this involves gnulib, it would take more time to address it. But it was my understanding that it's not urgent if the stock compiler can be used, right?

comment:32 Changed 7 months ago by kencu (Ken)

Well done. It builds through now with gcc-4.2, thank you. The test suite looks good too.

I also disabled the WORDSIZE patch, and it seems that this no longer causes an error as well.

So it looks GOOD from here. Thanks, Akim.

comment:33 Changed 7 months ago by akimd (Akim Demaille)

Thanks a lot for your help! I'm starting the release process, it should be available on gnu.org in about half an hour. Cheers!

comment:34 Changed 5 months ago by kencu (Ken)

In 421e073d982bbc8461a419183e65a6504dbd6e19/macports-ports (dar, master, py38-reproject, revert-6945-rust-1.43.0, wireshark):

bison: require C11

the build uses C11 features in the test builds
and requires newer gcc versions to support the
pragmas inside functions

closes: #59927

Note: See TracTickets for help on using tickets.