Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rules flex/bison to latest. #385

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

hzeller
Copy link
Collaborator

@hzeller hzeller commented Feb 28, 2025

No description provided.

@hzeller hzeller marked this pull request as draft February 28, 2025 02:22
@hzeller hzeller force-pushed the feature-20250227-update-bison branch from 89936b9 to 468ad4c Compare February 28, 2025 03:58
@hzeller
Copy link
Collaborator Author

hzeller commented Feb 28, 2025

Not sure what is going on; apparently it can't find v3.3.2

bazel: ~/.cache/bazel/somethingsomething/bin/dependency_support/verilator/private/verilator_bisonpre.runfiles/bison_v3.3.2/data/m4sugar/m4sugar.m4: cannot open: Unknown system error

Just looking at the regular bison, there is such a file in the source:

bison-3.3.2/data/m4sugar/m4sugar.m4

There is probably some implicit assumption in the verilator dependency to access it, but unclear where.

@hzeller hzeller requested a review from abrisco February 28, 2025 04:05
@hzeller
Copy link
Collaborator Author

hzeller commented Feb 28, 2025

So to reproduce

bazel-6.5.0 build -c opt @verilator//:verilator_bison

will fail with this.

@hzeller
Copy link
Collaborator Author

hzeller commented Feb 28, 2025

Adding @abrisco who probably knows what is going on.

@hovind
Copy link
Collaborator

hovind commented Feb 28, 2025

Not sure what is going on; apparently it can't find v3.3.2

bazel: ~/.cache/bazel/somethingsomething/bin/dependency_support/verilator/private/verilator_bisonpre.runfiles/bison_v3.3.2/data/m4sugar/m4sugar.m4: cannot open: Unknown system error

Just looking at the regular bison, there is such a file in the source:

bison-3.3.2/data/m4sugar/m4sugar.m4

There is probably some implicit assumption in the verilator dependency to access it, but unclear where.

I ran into the same when I tried to upgrade to bazel 8. In case it is helpful to anyone looking into this issue, I ended up skipping the process wrapper to work around the issue: main...hovind:bazel_rules_hdl:bzlmod/bazel-8#diff-8a3e3b3cc164ce2b3a9e29b66f4c9d7040780f79e4b0acc070134d6a1b64c6f6

@mikesinouye
Copy link
Collaborator

mikesinouye commented Feb 28, 2025

Found this when searching for the error online, found something that may be related. It's worth a try setting this envvar: conan-io/conan-center-index#1498 (comment). Although was this an error from bazel or bison?

@abrisco
Copy link
Collaborator

abrisco commented Feb 28, 2025

bazel: ~/.cache/bazel/somethingsomething/bin/dependency_support/verilator/private/verilator_bisonpre.runfiles/bison_v3.3.2/data/m4sugar/m4sugar.m4

I wouldn't expect this to be in runfiles. What is causing it to look there? As you can see there's no data dependencies on the target and thus there would be no runfiles

py_binary(
name = "verilator_bisonpre",
srcs = ["verilator_bisonpre.py"],
visibility = ["@verilator//:__pkg__"],
)

What is the full error Bazel spits out?

I would also advise moving away from Bazel 6. I don't know why it was pinned back but the last PR I made (using Bazel ~7.3) everything worked just fine.

@hzeller
Copy link
Collaborator Author

hzeller commented Feb 28, 2025

Full error message is the following. It happens in verilator which seems to attempt to access bison data:

$ bazel-6.5.0 build -c opt @verilator//:verilator_bison
INFO: Invocation ID: 40fac713-1f3e-46b8-bf98-3a38d782f15e
INFO: Analyzed target @verilator//:verilator_bison (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/hzeller/.cache/bazel/_bazel_hzeller/93037ab3fc33a56824a47b83bb7a7ab5/external/verilator/BUILD.bazel:186:19: VerilatorBisonPre external/verilator/V3ParseBison.c failed: (Exit 1): verilator_bisonpre failed: error executing command (from target @verilator//:verilator_bison) bazel-out/k8-opt-exec-2B5CBBC6/bin/dependency_support/verilator/private/verilator_bisonpre external/verilator/src/bisonpre --yacc bazel-out/k8-opt-exec-2B5CBBC6/bin/external/bison_v3.3.2/bin/bison -d ... (remaining 4 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
bison: /home/hzeller/.cache/bazel/_bazel_hzeller/93037ab3fc33a56824a47b83bb7a7ab5/sandbox/linux-sandbox/12837/execroot/rules_hdl/bazel-out/k8-opt-exec-2B5CBBC6/bin/dependency_support/verilator/private/verilator_bisonpre.runfiles/bison_v3.3.2/data/m4sugar/m4sugar.m4: cannot open: Unknown system error
  edit external/verilator/src/verilog.y bazel-out/k8-opt/bin/external/verilator/V3ParseBison_pretmp.y
  bazel-out/k8-opt-exec-2B5CBBC6/bin/external/bison_v3.3.2/bin/bison -d -v --report=itemset --report=lookahead -b bazel-out/k8-opt/bin/external/verilator/V3ParseBison_pretmp -o bazel-out/k8-opt/bin/external/verilator/V3ParseBison_pretmp.c bazel-out/k8-opt/bin/external/verilator/V3ParseBison_pretmp.y
bisonpre: %Error: bazel-out/k8-opt-exec-2B5CBBC6/bin/external/bison_v3.3.2/bin/bison version 3.3 run failed due to errors


Target @verilator//:verilator_bison failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.910s, Critical Path: 1.58s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully

(And I agree, bazel 6 support should be phased out for this repo. I am currently working on lining up all the things for this to happen)

@hovind
Copy link
Collaborator

hovind commented Feb 28, 2025

I think this comes down to jmillikin/rules_bison@ce9ddfd.

@abrisco
Copy link
Collaborator

abrisco commented Feb 28, 2025

I think this comes down to jmillikin/rules_bison@ce9ddfd.

If this is the case then probably deleting RUNFILES_DIR from the environment might help? Assuming there's actually a runfiles directory for the bison binary. But using runfiles for this in actions doesn't feel appropriate IMO. It should use execpath.

--- a/dependency_support/verilator/private/verilator_bisonpre.py
+++ b/dependency_support/verilator/private/verilator_bisonpre.py
@@ -1,13 +1,20 @@
 """A wrapper for bisonpre that reduces noise in console logs."""

+import os
 import subprocess
 import sys


 def main() -> None:
     """The main entrypoint"""
+
+    env = dict(os.environ)
+    if "RUNFILES_DIR" in env:
+        del env["RUNFILES_DIR"]
+
     result = subprocess.run(
         [sys.executable] + sys.argv[1:],
+        env=env,
         check=False,
         stderr=subprocess.STDOUT,
         stdout=subprocess.PIPE,

Co-authored-by: Andre Brisco <andre.brisco@protonmail.com
@hzeller hzeller force-pushed the feature-20250227-update-bison branch from 468ad4c to d72d5e2 Compare February 28, 2025 22:17
@hzeller hzeller marked this pull request as ready for review February 28, 2025 22:22
@hzeller
Copy link
Collaborator Author

hzeller commented Feb 28, 2025

Applied @abrisco 's patch, works for me locally now. Let's see what the CI thinks.

@hzeller hzeller requested a review from mikesinouye February 28, 2025 23:31
@hzeller
Copy link
Collaborator Author

hzeller commented Feb 28, 2025

Adding @mikesinouye to review; looks like the last change fixed it.

@mikesinouye
Copy link
Collaborator

Very nice!!

@mikesinouye mikesinouye merged commit b3ade33 into hdl:main Feb 28, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants