Skip to content

Commit

Permalink
build: Add stage2scan.c and byte comparison check for bootstrap.
Browse files Browse the repository at this point in the history
With stage1scan.c being deterministic, it's possible to add a bootstrap
check that ensures the generated flex program can build the scanner of
itself flawlessly. The check is performed on native build only.

Signed-off-by: Kang-Che Sung <[email protected]>
  • Loading branch information
Explorer09 committed Feb 15, 2020
1 parent 4c8b757 commit 5e34608
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ parse.c
parse.h
scan.c
skel.c
stage1scan.[cl]
stage1scan.c
stage1flex
stage2scan.c
9 changes: 9 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ m4 = @M4@
bin_PROGRAMS = flex
if ENABLE_BOOTSTRAP
noinst_PROGRAMS = stage1flex
if !CROSS
noinst_DATA = stage2scan.c
endif
endif

if ENABLE_LIBFL
Expand Down Expand Up @@ -110,6 +113,12 @@ stage1scan.c: scan.l stage1flex$(EXEEXT)
( cd $(srcdir) && $(abs_builddir)/stage1flex$(EXEEXT) \
$(AM_LFLAGS) -o scan.c -t $(LFLAGS) scan.l ) >$@

stage2scan.c: scan.l flex$(EXEEXT) stage1scan.c
@echo "Checking if flex produces bit-for-bit identical scanner of itself..."
( cd $(srcdir) && $(abs_builddir)/flex$(EXEEXT) \
$(AM_LFLAGS) -o scan.c -t $(LFLAGS) scan.l ) >$@ && \
cmp stage1scan.c $@

dist-hook: scan.l flex$(EXEEXT)
chmod u+w $(distdir) && \
( cd $(srcdir) && $(abs_builddir)/flex$(EXEEXT) \
Expand Down

0 comments on commit 5e34608

Please sign in to comment.