Skip to content

Error handling in init submodules #2226

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Error handling in init submodules #2226

wants to merge 5 commits into from

Conversation

Fi50
Copy link
Contributor

@Fi50 Fi50 commented Mar 31, 2025

[Below is the original PR comment - now irrelevant because the new solution is a lot cleaner.]

In some ways not well tested, because that would involve breaking the submodules on purpose to make sure the error handling works well?.. But should work on the basis of git submodule update --init returning a non-zero exit status if the submodule fails to update? (https://phabricator.wikimedia.org/T198980).

A forceful way of providing helpful error messages.
Might be bad timing with the chipyard lite stuff though.
An alternative solution might be something like (untested):

# List of submodules to initialize
submodules=(
    "generators/cva6"
    "generators/ara"
    "generators/nvdla"
    "toolchains/libgloss"
    "generators/gemmini"
    "generators/rocket-chip"
    "generators/compress-acc"
    "generators/vexiiriscv"
    "sims/firesim"
    "tools/rocket-dsp-utils"
    "tools/dsptools"
    "software/firemarshal"
)

# Update submodules
for submodule in "${submodules[@]}"; do
    echo "Initializing submodule: $submodule"
    git submodule update --init "$submodule" || {
        echo "Failed to initialize submodule: $submodule"
        exit 1
    }
done

# Specific submodule updates for nested submodules
git submodule update --init generators/cva6 || { echo "Failed to initialize generators/cva6"; exit 1; }
git -C generators/cva6 submodule update --init src/main/resources/cva6/vsrc/cva6 || { echo "Failed to initialize cva6 submodules"; exit 1; }
git -C generators/cva6/src/main/resources/cva6/vsrc/cva6 submodule update --init src/axi || { echo "Failed to initialize src/axi"; exit 1; }

[...ETC..]

# Non-recursive clone to exclude specific submodules
git submodule update --init generators/gemmini || { echo "Failed to initialize generators/gemmini"; exit 1; }
git -C generators/gemmini/ submodule update --init --recursive software/gemmini-rocc-tests || { echo "Failed to initialize software/gemmini-rocc-tests"; exit 1; }
git submodule update --init generators/rocket-chip || { echo "Failed to initialize generators/rocket-chip"; exit 1; }

[...ETC..]

# Minimal non-recursive clone to initialize sbt dependencies
git submodule update --init sims/firesim || { echo "Failed to initialize sims/firesim"; exit 1; }
git config --local submodule.sims/firesim.update none || { echo "Failed to configure sims/firesim update"; exit 1; }
git submodule update --init tools/rocket-dsp-utils || { echo "Failed to initialize tools/rocket-dsp-utils"; exit 1; }
git submodule update --init tools/dsptools || { echo "Failed to initialize tools/dsptools"; exit 1; }

# Only shallow clone needed for basic SW tests
git submodule update --init software/firemarshal || { echo "Failed to initialize software/firemarshal"; exit 1; }

That is, instead of excluding with git_submodule_exclude(), we can explicitly include. Looks prettier but is probably a bad idea in terms of new module integration? Plus right now it's nice how each module family is separate? Plus might not work with firesim setup?
So kept the code mostly as it was before in the actual PR. But would be nice to have some sort of pretty function and array. Because all the error statements look ugly. I don't know.

Related PRs / Issues:

#1696

Type of change:

  • Bug fix
  • New feature
  • Other enhancement

Impact:

  • RTL change
  • Software change (RISC-V software)
  • Build system change
  • Other

Contributor Checklist:

  • Did you set main as the base branch?
  • Is this PR's title suitable for inclusion in the changelog and have you added a changelog:<topic> label?
  • Did you state the type-of-change/impact?
  • Did you delete any extraneous prints/debugging code?
  • Did you mark the PR with a changelog: label?
  • (If applicable) Did you update the conda .conda-lock.yml file if you updated the conda requirements file?
  • (If applicable) Did you add documentation for the feature?
  • (If applicable) Did you add a test demonstrating the PR?
  • (If applicable) Did you mark the PR as Please Backport?

CI Help:
Add the following labels to modify the CI for a set of features.
Generally, a label added only affect subsequent changes to the PR (i.e. new commits, force pushing, closing/reopening).
See ci:* for full list of labels:

  • ci:fpga-deploy - Run FPGA-based E2E testing
  • ci:local-fpga-buildbitstream-deploy - Build local FPGA bitstreams for platforms that are released
  • ci:disable - Disable CI

@Fi50 Fi50 force-pushed the minor-doc-change branch from b290661 to dd9e80c Compare March 31, 2025 10:03
@Fi50 Fi50 marked this pull request as ready for review March 31, 2025 10:16
@Fi50 Fi50 changed the title Brute force approach to error handling in init submodules Error handling in init submodules Mar 31, 2025
@@ -11,6 +11,22 @@ source $RDIR/scripts/utils.sh

common_setup

# Custom error handler function
error_handler() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is only used in init-submods, I think it should be in that file, not utils.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants