Skip to content

[Build] Check subprocess return codes in synth/HLS launches - #1662

Open
mumallaeng wants to merge 1 commit into
Xilinx:devfrom
mumallaeng:fix-launch-process-returncode
Open

[Build] Check subprocess return codes in synth/HLS launches#1662
mumallaeng wants to merge 1 commit into
Xilinx:devfrom
mumallaeng:fix-launch-process-returncode

Conversation

@mumallaeng

Copy link
Copy Markdown

Fix #52.

Problem

Several build steps launch Vivado, Vitis, vitis_hls, or g++ through subprocess.Popen(bash_command, stdout=subprocess.PIPE); process.communicate() and never check the return code. If the external tool fails, FINN doesn't notice: the build either continues with stale or missing artifacts, or fails later with a confusing error that isn't obviously related to the actual failure upstream.

launch_process_helper in finn/util/basic.py already exists to solve exactly this (it raises CalledProcessError when check=True and the process exits non-zero), but most of these call sites predate it and never got switched over.

Fix

Route every remaining unchecked call site through launch_process_helper(..., check=True):

  • finn/util/basic.py - CppBuilder.build() (g++ compile)
  • finn/util/hls.py - CallHLS.build() (vitis_hls)
  • finn/custom_op/fpgadataflow/hlsbackend.py - exec_precompiled_singlenode_model()
  • finn/custom_op/fpgadataflow/rtl/finn_loop.py - loop IP project build
  • finn/transformation/fpgadataflow/create_stitched_ip.py - stitched IP project build
  • finn/transformation/fpgadataflow/make_zynq_proj.py - Zynq synthesis
  • finn/transformation/fpgadataflow/alveo_build.py - .xo packaging, Vitis link, and report-XML generation (3 call sites)
  • finn/core/rtlsim_exec.py - 2 call sites already using launch_process_helper but not passing check=True

No behavior change on the success path. On failure, these now raise CalledProcessError at the point the tool actually failed, instead of silently proceeding.

Testing

isort/black/ruff (pinned versions from .pre-commit-config.yaml) pass on all changed files, and python -m py_compile passes. I don't have a licensed Vivado/Vitis toolchain in this environment to exercise these paths against a real tool failure; the change is a mechanical swap onto the same helper already used elsewhere in the codebase, e.g. alveo_build.py's SLASH link path already does the equivalent with subprocess.run(..., check=True).

Several build steps launch Vivado, Vitis, or vitis_hls through
subprocess.Popen(...).communicate() and never look at the return
code. A failed synthesis, linking, or HLS run is silently treated
as success, and the build either proceeds with stale or missing
artifacts, or fails later with a confusing, unrelated error.

Route these launches through launch_process_helper(check=True),
which already exists for this purpose and raises
CalledProcessError on a non-zero exit. Also pass check=True on
the two rtlsim_exec.py call sites that already use the helper but
weren't opting into it.

No functional change on success; failures now surface at the
point where the tool actually failed.

Signed-off-by: mumallaeng <mumallaeng@outlook.com>
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.

1 participant