1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Build backend/parser/scan.l and interfaces/ecpg/preproc/pgc.l standalone.

Back-patch commit 72b1e3a21 into the pre-9.6 branches.

As noted in the original commit, this has some extra benefits: we can
narrow the scope of the -Wno-error flag that's forced on scan.c.  Also,
since these grammar and lexer files are so large, splitting them into
separate build targets should have some advantages in build speed,
particularly in parallel or ccache'd builds.

However, the real reason for doing this now is that it avoids symbol-
redefinition warnings (or worse) with the latest version of flex.
It's not unreasonable that people would want to compile our old branches
with recent tools.  Per report from Дилян Палаузов.

Discussion: https://postgr.es/m/d845c1af-e18d-6651-178f-9f08cdf37e10@aegee.org
This commit is contained in:
Tom Lane
2016-12-11 17:44:16 -05:00
parent 6f5cb982e7
commit 7192865bdc
6 changed files with 23 additions and 34 deletions

View File

@@ -26,7 +26,7 @@ override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
override CFLAGS += $(PTHREAD_CFLAGS) -DECPG_COMPILE
OBJS= preproc.o type.o ecpg.o output.o parser.o \
OBJS= preproc.o pgc.o type.o ecpg.o output.o parser.o \
keywords.o c_keywords.o ecpg_keywords.o kwlookup.o ../ecpglib/typename.o descriptor.o variable.o \
$(WIN32RES)
@@ -44,9 +44,6 @@ ecpg: $(OBJS) | submake-libpgport
../ecpglib/typename.o: ../ecpglib/typename.c
$(MAKE) -C $(dir $@) $(notdir $@)
# pgc is compiled as part of preproc
preproc.o: pgc.c
preproc.h: preproc.c ;
preproc.c: BISONFLAGS += -d
@@ -54,7 +51,7 @@ preproc.y: ../../../backend/parser/gram.y parse.pl ecpg.addons ecpg.header ecpg.
$(PERL) $(srcdir)/parse.pl $(srcdir) < $< > $@
$(PERL) $(srcdir)/check_rules.pl $(srcdir) $<
ecpg_keywords.o c_keywords.o keywords.o preproc.o parser.o: preproc.h
ecpg_keywords.o c_keywords.o keywords.o preproc.o pgc.o parser.o: preproc.h
kwlookup.c: % : $(top_srcdir)/src/backend/parser/%
rm -f $@ && $(LN_S) $< .

View File

@@ -1917,11 +1917,3 @@ void parser_init(void)
{
/* This function is empty. It only exists for compatibility with the backend parser right now. */
}
/*
* Must undefine base_yylex before including pgc.c, since we want it
* to create the function base_yylex not filtered_base_yylex.
*/
#undef base_yylex
#include "pgc.c"

View File

@@ -1,4 +1,4 @@
%{
%top{
/*-------------------------------------------------------------------------
*
* pgc.l
@@ -23,7 +23,19 @@
#include <limits.h>
#include "extern.h"
#include "preproc.h"
/*
* Change symbol names as expected by preproc.y. It'd be better to do this
* with %option prefix="base_yy", but that affects some other names that
* various files expect *not* to be prefixed with "base_". Cleaning it up
* is not worth the trouble right now.
*/
#define yylex base_yylex
#define yylval base_yylval
}
%{
extern YYSTYPE yylval;
static int xcdepth = 0; /* depth of nesting in slash-star comments */