[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: HEAD build failure with OpenBSD yacc
From: |
Lennart Jablonka |
Subject: |
Re: HEAD build failure with OpenBSD yacc |
Date: |
Wed, 6 Mar 2024 14:33:48 +0000 |
Quoth G. Branden Robinson:
Thanks for the report. I confess I have no clear idea how to address
this problem. Is OpenBSD's yacc the same as byacc (with which I've had
many successful builds, including one of HEAD just now), or different?
OpenBSD’s yacc is indeed Berkeley yacc, byacc. It is not,
however, Thomas Dickey’s version exactly.
Let’s look at the history a little bit, starting with the BSD SCCS
repository.
bsd/usr.bin/yacc$ sccs prs -l -r5.7 skeleton.c
SCCS/s.skeleton.c:
D 5.8 95/04/29 10:30:57 bostic 8 7 00039/00008/00312
MRs:
COMMENTS:
changes to byacc 1.9 for dynamic stack expansion
From: Chris Torek <torek@BSDI.COM>
D 5.7 93/05/24 21:29:30 bostic 7 6 00046/00030/00274
MRs:
COMMENTS:
revision 1.9 from Bob Corbett
bsd/usr.bin/yacc$ sccs sccsdiff -u -r5.7 -r5.8 skeleton.c
------- skeleton.c -------
--- /tmp/geta77835 Wed Mar 6 13:35:40 2024
+++ /tmp/getb77835 Wed Mar 6 13:35:40 2024
@@ -31,6 +31,7 @@
"#ifndef lint",
"static char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley)
02/21/93\";",
"#endif",
+ "#include <stdlib.h>",
"#define YYBYACC 1",
"#define YYMAJOR 1",
"#define YYMINOR 9",
[…]
Huh, BSD gained that #include directive between 1993 and 1995. It
spread thither to NetBSD, whither it continued for OpenBSD. The
interested reader can consult the CVS repositories.
Thomas Dickey makes available the byacc 1.9 they started with,
which is almost identical to the 1993-05-24 version in BSD’s SCCS,
and thus doesn’t yet contain the #include directive in the
skeleton. It’s added later, though:
byacc-snapshots$ git show ae6c95191373
commit ae6c951913731170b194aae4bdeed7ff68ebdc4f
Author: Thomas E. Dickey <dickey@invisible-island.net>
Date: Fri May 6 00:46:50 2005 -0400
snapshot of project "byacc", label t20050505
diff --git a/CHANGES b/CHANGES
index e64d5f5..6417777 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,140 @@
[…]
+2004-03-28 Thomas E. Dickey <dickey@invisible-island.net>
+
[…]
+
+ * skeleton.c: fix a couple of minor compiler-warnings in the
skeleton
+
[…]
2004-02-23 Thomas E. Dickey <dickey@invisible-island.net>
* config.sub: RCS_BASE
[…]
diff --git a/skeleton.c b/skeleton.c
index 65d46a8..d46d001 100644
--- a/skeleton.c
+++ b/skeleton.c
@@ -1,3 +1,5 @@
+/* $Id: skeleton.c,v 1.9 2005/05/04 23:39:36 tom Exp $ */
+
#include "defs.h"
/* The definition of yysccsid in the banner should be replaced with
*/
@@ -17,17 +19,27 @@ char *banner[] =
"#ifndef lint",
"static const char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley)
02/21/93\";",
"#endif",
+ "",
+ "#include <stdlib.h>",
+ "",
"#define YYBYACC 1",
[…]
And it seems someone else has run into an issue somewhat similar
to ours before:
byacc-snapshots$ git show 534de7284cfc
commit 534de7284cfcc098ef9d403b8ddbb9eb1b8e4396
Author: Thomas E. Dickey <dickey@invisible-island.net>
Date: Tue Jun 8 00:21:39 2010 -0400
snapshot of project "byacc", label t20100606
diff --git a/CHANGES b/CHANGES
index 587b1c3..de0ec21 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,81 @@
[…]
+2010-06-06 Thomas E. Dickey <dickey@invisible-island.net>
+
[…]
+
+ * skeleton.c:
+ move #include's down into the generated code, to allow
user-defined code
+ to override feature definitions, particularly with stdlib.h
(request by
+ Marcus Kool).
+
[…]
+
2010-02-16 Thomas E. Dickey <dickey@invisible-island.net>
* yacc.1: document -P and bison-extensions
[…]
diff --git a/skeleton.c b/skeleton.c
index 2203de6..d2c7d56 100644
--- a/skeleton.c
+++ b/skeleton.c
@@ -1,4 +1,4 @@
-/* $Id: skeleton.c,v 1.23 2010/02/17 01:44:23 tom Exp $ */
+/* $Id: skeleton.c,v 1.24 2010/06/07 00:17:44 tom Exp $ */
#include "defs.h"
@@ -20,9 +20,6 @@ const char *banner[] =
"static const char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley)
02/21/93\";",
"#endif",
"",
- "#include <stdlib.h>",
- "#include <string.h>",
- "",
"#define YYBYACC 1",
CONCAT1("#define YYMAJOR ", YYMAJOR),
CONCAT1("#define YYMINOR ", YYMINOR),
@@ -79,10 +76,6 @@ const char *tables[] =
const char *hdr_defs[] =
{
- "#if YYDEBUG",
- "#include <stdio.h>",
- "#endif",
- "",
"/* define the initial stack-sizes */",
"#ifdef YYSTACKSIZE",
"#undef YYMAXDEPTH",
@@ -138,6 +131,14 @@ const char *body_vars[] =
const char *body_1[] =
{
+ "",
+ "#if YYDEBUG",
+ "#include <stdio.h> /* needed for printf */",
+ "#endif",
+ "",
+ "#include <stdlib.h> /* needed for malloc, etc */",
+ "#include <string.h> /* needed for memset */",
+ "",
"/* allocate initial stack or double stack size, up to YYMAXDEPTH
*/",
"static int yygrowstack(YYSTACKDATA *data)",
"{",
[…]
Does the problem go away if you build with GNU Bison instead?
Yes, well. First, the compiler complained that
src/preproc/refer/label.cpp uses ptrdiff_t without that being
declared. <stddef.h> isn’t included anywhere there.
Turns out, the build system doesn’t track dependences on the
gnulib header files, so my naïve ./configure && gmake refer
failed.
Turns out further, gnulib’s stdlib.h #includes <stddef.h>, because
“NetBSD 5.0 mis-defines NULL.” So yeah, that’s a missing #include
directive in label.ypp and a gnulib header non-conforming to ISO C.
Then, generating the gnulib headers first, I got a linker error.
Duplicate symbol. fprintf.
Right, you can’t simply override symbols from the standard
library. It’s brittle. And here, it doesn’t work when trying to
link statically. Which is a totally fine and respectable thing to
do. And it worked before, I think, somehow. But no: Only dynamic
linking allowed here.
Then it worked. I don’t like gnulib.
Is it fair to say that yacc/bison/byacc should not be producing
gnulib-dependent output?
Yes.
If not, how do we prevent that?
I haven’t looked very much at the gnulib stuff, but the first idea
is to simply #include config.h in the gnulib headers that need it.
Is this a
known issue others have encountered?
I don’t know; I haven’t looked.