jmillikin / rules_bison Goto Github PK
View Code? Open in Web Editor NEWBazel build rules for GNU Bison
License: Apache License 2.0
Bazel build rules for GNU Bison
License: Apache License 2.0
Bison fails to execute on Windows:
bazel build //tests:hello_c
fails with:
ERROR: D:/rules_bison/tests/BUILD:24:1: Bison //tests:hello_c failed (Exit 1)
bison.exe: bazel-out/host/bin/external/bison_v3.3.2/bin/bison.exe.runfiles/bison_v3.3.2/data/m4sugar/m4sugar.m4: cannot open: No such file or directory
Target //tests:hello_c failed to build
I believe the issue is that on Windows the runfiles are not symlinked but instead bazel put a MANIFEST
file in bazel-out/host/bin/external/bison_v3.3.2/bin/bison.exe.runfiles
with the correct mapping.
Replacing M4
and and BISON_PKGDATADIR
with the mapped values make the execution pass. I am not sure how to do that with the bazel scripts though.
Bison uses a vendored copy of gnulib as a portability layer, which makes it difficult to build on Windows. It'll need its own copies of gnulib.bzl
and vendored config.h
headers that were used for M4 (jmillikin/rules_m4#1).
I'd like to update to a more recent version of Bison (3.8 or later.) I've made a small attempt to update them myself here, but this fails with errors related to gnulib.
~/Workspace/rules_bison$ bazel test //tests:genrule_test
WARNING: Download from https://mirror.bazel.build/github.com/coreutils/gnulib/archive/7818455627c5e54813ac89924b8b67d0bc869146.zip failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
INFO: Analyzed target //tests:genrule_test (0 packages loaded, 0 targets configured).
INFO: Found 1 target and 0 test targets...
ERROR: /private/var/tmp/_bazel_kkiningh/9d4359696dfa5ef018618c8abc478887/external/bison_v3.8.2/gnulib/BUILD.bazel:171:11: Compiling gnulib/lib/asnprintf.c [for host] failed: (Aborted): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 -DNDEBUG '-DNS_BLOCK_ASSERTIONS=1' ... (remaining 35 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
In file included from external/bison_v3.8.2/gnulib/lib/asnprintf.c:17:
external/bison_v3.8.2/gnulib/config-darwin/config.h:2:10: fatal error: 'gnulib/lib/config.in.h' file not found
#include "gnulib/lib/config.in.h"
^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error in child process '/usr/bin/xcrun'. 1
Target //tests:genrule_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.392s, Critical Path: 0.31s
INFO: 11 processes: 11 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
Any chance the rules could be updated? Or guidance on how to fix the gnulib rules?
b3f74fd65c8a/external/parser/BUILD.bazel:10:1: in bison_cc_library rule @parser//:bison_parser:
Traceback (most recent call last):
File "/private/var/tmp/_bazel_dmitry/9878c75bb785aeb934f7b3f74fd65c8a/external/parser/BUILD.bazel", line 10
bison_cc_library(name = 'bison_parser')
File "/private/var/tmp/_bazel_dmitry/9878c75bb785aeb934f7b3f74fd65c8a/external/io_bazel_rules_bison/bison/bison.bzl", line 457, in _bison_cc_library
_build_cc_info(ctx, result.source, result.header)
File "/private/var/tmp/_bazel_dmitry/9878c75bb785aeb934f7b3f74fd65c8a/external/io_bazel_rules_bison/bison/bison.bzl", line 404, in _build_cc_info
cc_toolchain.needs_pic_for_dynamic_libraries(feature_configuration = ld_featu...)
type 'CcToolchainInfo' has no method needs_pic_for_dynamic_libraries(feature_configuration feature_configuration)
Line 70 in 85e9bab
I have a bison ypp that uses both %defines and %locations, thus these files should be generated per https://www.gnu.org/software/bison/manual/html_node/C_002b_002b-Bison-Interface.html. Have you thought about how to handle these files? Otherwise, the compilation process won't work because the output source file contains # include "location.hh"
I tried to use rules_bison/rules_flex on centos-7.9. But this is continuously failing for following errors. same rules compile well for ubuntu-20.04. I tried setting up BAZEL_COPTS="-std=c99", but still same output. I am using bazel-4.0.0
/home/dgautam/.cache/bazel/_bazel_dgautam/install/1a4a2fac02d50c77031d44c0d91b8920/process-wrapper '--timeout=0' '--kill_delay=15' /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections -MD -MF bazel-out/host/bin/external/bison_v3.3.2/_objs/bison_lib/AnnotationList.d '-frandom-seed=bazel-out/host/bin/external/bison_v3.3.2/_objs/bison_lib/AnnotationList.o' -iquote external/bison_v3.3.2 -iquote bazel-out/host/bin/external/bison_v3.3.2 -Ibazel-out/host/bin/external/bison_v3.3.2/_virtual_includes/bison_lib -isystem external/bison_v3.3.2 -isystem bazel-out/host/bin/external/bison_v3.3.2 -isystem external/bison_v3.3.2/bison-lib -isystem bazel-out/host/bin/external/bison_v3.3.2/bison-lib -isystem external/bison_v3.3.2/gnulib/lib -isystem bazel-out/host/bin/external/bison_v3.3.2/gnulib/lib -isystem external/bison_v3.3.2/gnulib/config-linux -isystem bazel-out/host/bin/external/bison_v3.3.2/gnulib/config-linux -g0 -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/bison_v3.3.2/src/AnnotationList.c -o bazel-out/host/bin/external/bison_v3.3.2/_objs/bison_lib/AnnotationList.o)
external/bison_v3.3.2/src/AnnotationList.c: In function 'AnnotationList__compute_conflicted_tokens':
external/bison_v3.3.2/src/AnnotationList.c:173:3: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < reds->num; ++i)
^
external/bison_v3.3.2/src/AnnotationList.c:173:3: note: use option -std=c99 or -std=gnu99 to compile your code
external/bison_v3.3.2/src/AnnotationList.c: In function 'AnnotationList__computePredecessorAnnotations':
external/bison_v3.3.2/src/AnnotationList.c:227:3: error: 'for' loop initial declarations are only allowed in C99 mode
for (state **predecessor = predecessors[s->number]; *predecessor; ++predecessor)
^
external/bison_v3.3.2/src/AnnotationList.c:236:9: error: 'for' loop initial declarations are only allowed in C99 mode
for (ContributionIndex ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
^
external/bison_v3.3.2/src/AnnotationList.c:334:25: error: 'for' loop initial declarations are only allowed in C99 mode
for (size_t j = 0; j < (*predecessor)->nitems; ++j)
^
external/bison_v3.3.2/src/AnnotationList.c:374:13: error: 'for' loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < (*predecessor)->nitems; ++i)
^
external/bison_v3.3.2/src/AnnotationList.c: In function 'AnnotationList__compute_from_inadequacies':
external/bison_v3.3.2/src/AnnotationList.c:436:9: error: 'for' loop initial declarations are only allowed in C99 mode
for (int rule_i = 0; rule_i < s->reductions->num; ++rule_i)
^
external/bison_v3.3.2/src/AnnotationList.c:452:9: error: 'for' loop initial declarations are only allowed in C99 mode
for (int rule_i = 0; rule_i < s->reductions->num; ++rule_i)
^
external/bison_v3.3.2/src/AnnotationList.c: In function 'AnnotationList__debug':
external/bison_v3.3.2/src/AnnotationList.c:574:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int j = 0; j < spaces; ++j)
^
external/bison_v3.3.2/src/AnnotationList.c:581:9: error: 'for' loop initial declarations are only allowed in C99 mode
for (ContributionIndex ci = 0; ci < a->inadequacyNode->contributionCount; ++ci)
^
external/bison_v3.3.2/src/AnnotationList.c:586:13: error: 'for' loop initial declarations are only allowed in C99 mode
for (int j = 0; j < spaces+2; ++j)
^
external/bison_v3.3.2/src/AnnotationList.c: In function 'AnnotationList__computeLookaheadFilter':
external/bison_v3.3.2/src/AnnotationList.c:622:5: error: 'for' loop initial declarations are only allowed in C99 mode
for (ContributionIndex ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
^
external/bison_v3.3.2/src/AnnotationList.c: In function 'AnnotationList__computeDominantContribution':
external/bison_v3.3.2/src/AnnotationList.c:777:3: error: 'for' loop initial declarations are only allowed in C99 mode
for (ContributionIndex ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
^
INFO: Elapsed time: 1.718s, Critical Path: 0.25s
INFO: 13 processes: 10 internal, 3 processwrapper-sandbox.
FAILED: Build did NOT complete successfully
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.