Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates flow/util/makeIssue.sh to correctly handle relative and absolute WORK_HOME paths when generating the run-me script in a make <step>_issue archive. It dynamically calculates the relative path back to the archive's root and adjusts the sourcing of the variables file accordingly. Additionally, a new Python test suite flow/test/test_make_issue_run_me.py is introduced to verify this behavior across default, relative, and absolute WORK_HOME configurations. I have no feedback to provide as the changes are well-implemented and accompanied by comprehensive tests.
043e737 to
87109ac
Compare
`make <step>_issue` archives a step as a reproducible: its inputs, a vars file with every flow variable and a run-me script. makeIssue.sh has grown with the flow and been fixed many times since 2022; in Python its parts are functions a unit test can call with the tools mocked, so each of those fixes can be pinned down by a test. makeIssue.py does what makeIssue.sh did, step by step: the same file variables, the same run-me scripts, generate-vars.sh for the vars files, and tar itself with the same --transform expressions, so the archive's member names are those GNU tar gives (tarfile has no --transform and no --ignore-failed-read, and reimplementing them would be a second thing to keep right). Run on the same stub flows, makeIssue.sh and makeIssue.py give the same archive members, run-me and vars files with WORK_HOME ".", relative, absolute and absolute with a trailing slash, for an openroad and a yosys step, and with FULL_ISSUE, EXCLUDE_PLATFORM, COPY_ISSUE and NUM_CORES set. utils.mk runs it with $(PYTHON_EXE), as it runs the other utilities. flow/test/test_make_issue.py is picked up by the util test workflow with the other flow/test/test_*.py. It runs makeIssue.py on a stub flow, unpacks the archive elsewhere and runs its run-me with a stub openroad, and tests the options and the choice of compressor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
generate-vars.sh writes the flow's variables into the vars files that `make vars` and `make <step>_issue` leave for bash, Tcl and gdb. It is now generate_vars.py, so that it can be tested like makeIssue.py, and makeIssue.py calls it as a function instead of running a script. The files are the same byte for byte. Run against master's script on the variables of nangate45 and asap7 gcd and on hand-written edge cases (quotes, $, spaces, '=' in a value, empty values, excluded names, paths under FLOW_HOME, the ORFS root, an absolute, relative, symlinked or trailing-slash WORK_HOME, /workspace and /platforms, PRESERVE_PATHS), 20 cases, the .sh, .tcl and .gdb files were identical. A path is now matched as written; sed read the dots in FLOW_HOME, the ORFS root and WORK_HOME as any character. test_generate_vars.py writes the files in a temporary directory and checks what they hold, and runs the script as the Makefile does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
The-OpenROAD-Project#914 fixed DFF_LIB_FILE and LIB_FILES running together into one file name, so neither was archived. The-OpenROAD-Project#2060 added ADDITIONAL_FILES, which may list several files or a glob. The tests give every design and platform file variable a value and check each file is in the issue's file list, check that two adjacent variables and a variable with several files give a file each, that a glob gives the files it matches, that the issue's own run-me and vars files are archived, and that EXCLUDE_PLATFORM leaves the platform's variables out. One runs makeIssue.py and finds DFF_LIB_FILE's and LIB_FILES's files in the archive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Renaming or retiring a flow variable has meant remembering makeIssue's list too: SYNTH_NETLIST_FILES (The-OpenROAD-Project#2899), PRE_GLOBAL_ROUTE_TCL (The-OpenROAD-Project#3333), MACRO_PLACEMENT_TCL (The-OpenROAD-Project#3469) and GLOBAL_CONNECT_TCL (The-OpenROAD-Project#4785) each updated it by hand. A name left behind archives nothing and says so nowhere. The test looks each file variable up in the flow's scripts, utilities, platforms and Makefile. It found RTLMP_CONFIG_FILE, whose last reader went with rtl_macro_placer's -config_file in The-OpenROAD-Project#2581; it is dropped from the list here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
The run-me script has been fixed for each of these: it finds the step's script through the unpacked archive's SCRIPTS_DIR, not the path of the flow that made it (The-OpenROAD-Project#1410); the script is named after the step, not the WORK_HOME path makeIssue is given (The-OpenROAD-Project#3466); openroad gets the flow's thread count (The-OpenROAD-Project#3870); a synthesis step runs yosys, not openroad (The-OpenROAD-Project#4129). The tests check each in run-me's text, check that the flow's own synthesis scripts are recognised as yosys steps and the others as openroad steps, and run an archive's run-me to see that it starts the step's script under ./scripts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Files under FLOW_HOME lose its path in the archive, so a design outside the ORFS checkout gives a working archive (The-OpenROAD-Project#1410). Files under an absolute WORK_HOME, such as a CI workspace, lose its path too, through a symlink and with a trailing slash, while a directory that only starts with WORK_HOME's name keeps its path (The-OpenROAD-Project#4274). The tests make archives with WORK_HOME ".", absolute, absolute with a trailing slash and through a symlink, and check the logs, results, scripts, design, platform, run-me and vars files are at the archive's root and no absolute path is recreated. Without the --transform expressions four of the five fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
generate_vars.py writes the archive's vars files, and they have been fixed for running somewhere else: python3 is the default PYTHON_EXE in both the shell and the Tcl vars (The-OpenROAD-Project#4792), paths under an absolute WORK_HOME are relative to the archive's root while a directory that only starts with WORK_HOME's name keeps its path (The-OpenROAD-Project#4274), and paths under a docker image's /workspace and /platforms are relative (The-OpenROAD-Project#3870). PRESERVE_PATHS keeps every path as it is. The tests make an archive and read its vars files. The stub flow moves one level down, so that the stub's WORK_HOME, like a CI workspace, is outside the ORFS root the vars files spell ${FLOW_HOME}/... Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
The platform's Tcl, SDC and .cfg files are archived, and only those it has (The-OpenROAD-Project#2222). Of the design and platform directories only the config files are archived, every platform config*.mk among them (The-OpenROAD-Project#3870), unless FULL_ISSUE asks for the whole directories (The-OpenROAD-Project#1771). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
The vars files have been taught, one fix at a time, which variables mean nothing on another machine: make's step and copy macros (The-OpenROAD-Project#1240, The-OpenROAD-Project#1231) and its other internals, commands, executables, the shell and search paths, and names that are not shell names (The-OpenROAD-Project#1303, The-OpenROAD-Project#1331), FLOW_HOME, which the shell file sets once from where it is sourced (The-OpenROAD-Project#1380), make's newline macro (The-OpenROAD-Project#1386), and CURDIR and the GUI switches (The-OpenROAD-Project#1410). A variable named *_DIR stays (The-OpenROAD-Project#1331). TestLeftOut checks each of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
A value is written as make holds it: an empty one too, which make spells '' (The-OpenROAD-Project#1336), one with '=' in it (The-OpenROAD-Project#3292), and a list such as GND_NETS_VOLTAGES, one quoted value in every file now that its special case is retired (The-OpenROAD-Project#2673). The blanks make's foreach puts around each line are not part of the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
The vars spell the flow's paths through FLOW_HOME, so that they work wherever the flow is: a path under FLOW_HOME and one under the ORFS root above it (The-OpenROAD-Project#1331), wherever in the value it is (The-OpenROAD-Project#1976), and each one of several (The-OpenROAD-Project#2673). The Tcl and gdb files read FLOW_HOME from the environment (The-OpenROAD-Project#1386). SCRIPTS_DIR is the scripts next to the vars files, which an issue archive carries (The-OpenROAD-Project#2012). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
makeIssue.py kept its own two lists of the variables that name files, design and platform. variables.yaml, which already describes every flow variable, now says it once: `type: file`. makeIssue reads it, and a new file variable needs only its entry there. EXCLUDE_PLATFORM now leaves out the files under PLATFORM_DIR, whichever variable names them, instead of the variables on the platform list: a macro's LEF in ADDITIONAL_LEFS is the design's own and is archived, and a platform library named by a design variable is left out. SIG_MAP_FILE, read by floorplan.tcl and the floorplan step, gets its entry in variables.yaml and in the generated FlowVariables.md. PDN_CFG, which the flow stopped reading when it became PDN_TCL (The-OpenROAD-Project#1062), is no longer archived. The test that the file variables are ones the flow reads now reads them from variables.yaml, counts the hooks source_step_tcl composes, and leaves variables.yaml out of the text it searches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
`make vars` wrote the .sh and .tcl files afresh and appended to the .gdb file, so after a few runs it held every earlier run's variables too and gdb set each one again, from the oldest value to the newest. All three are written afresh now; makeIssue.py no longer removes them first. TestWrittenAfresh writes the files twice and finds only the second value; the .gdb file held both before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
EXCLUDE_PLATFORM drops the liberty and LEF files from the archive by decompressing it, deleting them and compressing it again. Since the archive moved into WORK_HOME (The-OpenROAD-Project#3466), the decompression has found it there and the deletion and compression have looked for it in the current directory, where it is only when WORK_HOME is ".": tar: detail_place_test.tar: Cannot open: No such file or directory All three now use the archive's path. The test makes archives with WORK_HOME ".", relative and absolute; the last two failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
The run-me script changes to its own directory and sources the vars file from there, and the vars' paths are relative to the archive's root. An absolute WORK_HOME is stripped from the archive's member names and WORK_HOME=. is the root, so run-me is at the root in both. A relative WORK_HOME such as work/gcd keeps its place under the root, and run-me then failed: couldn't read file "./scripts/detail_place.tcl" run-me now climbs from its directory back to the archive's root and sources the vars file by its path from there. An absolute WORK_HOME and WORK_HOME=. give the same run-me as before. TestRunMe runs the run-me of an archive made with a relative WORK_HOME from elsewhere; it failed before this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
87109ac to
ba028ea
Compare
🔍 QoR checkMetrics reflect the PR merge build — i.e. what will land on the target branch. Commit 62 design(s) checked — 0 with regression(s), 0 without a comparable baseline. |
vvbandeira
left a comment
There was a problem hiding this comment.
A couple of considerations:
make <step>_issuefails in a bazel-orfs deployed tree withModuleNotFoundErrorforgenerate_vars. bazel-orfs runs$(PYTHON_EXE)through a wrapper that callsrunpy.run_path, which does not add the script's folder tosys.path. Addsys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))before the import, and a test that runsmakeIssue.pythroughrunpy.run_path.- With
EXCLUDE_PLATFORM, platform files can now go into the archive.makeIssue.shdropped the platform variables by name, butmakeIssue.pydrops only files whoserealpathis underPLATFORM_DIR. So a file outsidePLATFORM_DIR, or a symlink in it that points elsewhere, is kept unless its name ends in.lib,.lefor.tlef(for example.lib.gz, CDL or RCX files). Keep dropping the platform variables by name, also compare withabspath, and add a test with a platform file outsidePLATFORM_DIR. - With
EXCLUDE_PLATFORM, design LEFs are still removed.ADDITIONAL_LEFSis now selected, butexclude_platform_librarythen deletes every*.lefmember, and the test stops before that step. Delete only the selected platform members, and check the final archive in the test. - CI can be fixed by a merge or rebase on master.
…-work-home Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
makeIssue.sh left the platform's files out of an EXCLUDE_PLATFORM archive by the variable that names them. makeIssue.py left out the files whose resolved path is under PLATFORM_DIR instead, so a PDK installed elsewhere was archived: LIB_FILES naming a .lib.gz, CDL_FILE and RCX_RULES outside PLATFORM_DIR, and a file in PLATFORM_DIR that is a link to somewhere else, all of which makeIssue.sh left out. variables.yaml now marks the variables that name the platform's files with `platform: true`, makeIssue.sh's platform list without the unread PDN_CFG and without ADDITIONAL_LEFS, which names the design's macros. EXCLUDE_PLATFORM leaves those variables out by name, and still leaves out a file under PLATFORM_DIR whichever variable names it, as the path is written or through a symlink. The tests name platform files outside PLATFORM_DIR and a link in each direction, in the file list and in the finished archive; they failed before this change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
EXCLUDE_PLATFORM deletes every member that ends in lib, lef or tlef from the finished archive, which is how the platform's files under FULL_ISSUE and the copies among the flow's objects go. It also deleted a macro's LEF that ADDITIONAL_LEFS names, although the file list had selected it, so the reproducible could not link the design's macros. The files a variable names and the file list kept are now put back after the deletion. DFF_LIB_FILE names a liberty file of the platform's, and only that deletion kept it out of the archive. It is marked `platform: true`, so it stays out wherever the platform keeps it. A file archived twice, in the design directory under FULL_ISSUE and through a variable, is listed twice and was given to tar --delete twice, which stopped makeIssue, as it did makeIssue.sh: tar: .../macro.lef: Not found in archive Each member is now deleted once. The test checks the finished archive of a flow with a design LEF, a platform LEF and a merged liberty file among the objects; it failed before this change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
Thanks. I ran each point against the PR head on a stub flow, next to
|
make <step>_issueis how a flow problem becomes a reproducible someone else can run, andmake varsis how a step is run by hand or under gdb. Since 2022, seven pull requests have fixedmakeIssue.sh, more than twenty commits have shapedgenerate-vars.sh, and four variable renames have each updated makeIssue's list by hand. This PR ports both scripts to Python, so their parts are functions a unit test can call, adds a test for each of those fixes so each one stays fixed, and makesvariables.yamlthe one place that says which variables name files. Writing the tests turned up cases that still failed; the commits after the tests fix them.Covered by a test, makeIssue:
DFF_LIB_FILEandLIB_FILESran together)SCRIPTS_DIR; files underFLOW_HOMEland at the archive's rootconfig*.mkamong them, unlessFULL_ISSUEis setADDITIONAL_FILESmay name several files or a globRTLMP_CONFIG_FILE, unread since #2581, andPDN_CFG, unread since #1062WORK_HOMEpath makeIssue is given/workspaceand/platformsare relative in the vars filesWORK_HOMEland at the archive's root, through a symlink and with a trailing slash; a sibling directory whose name starts withWORK_HOME's is left alonePYTHON_EXEto python3Covered by a test, the vars files:
FLOW_HOME, the newline macro,CURDIRand the GUI switches stay out;*_DIRvariables stay in;FLOW_HOMEis set once=, and lists such asGND_NETS_VOLTAGESare written as make holds themFLOW_HOMEand the ORFS root are spelled through${FLOW_HOME}, wherever in a value and each of several; Tcl and gdb read it from the environment;SCRIPTS_DIRis the archive's ownFixed here:
make varsappended to the.gdbfile, so it held every earlier run's variables and gdb set each one again from oldest to newest. All three files are now written afresh.EXCLUDE_PLATFORMwith aWORK_HOMEother than.: since util: makeIssue.sh considers WORK_HOME #3466 the archive is inWORK_HOME, but dropping the liberty and LEF files looked for it in the current directory.WORK_HOME: it started from the wrong directory and could not read./scripts/detail_place.tcl.EXCLUDE_PLATFORMwith a file archived twice, in the design directory underFULL_ISSUEand through a variable:tar --deletewas given the member twice and stopped withNot found in archive.EXCLUDE_PLATFORMdeleted a macro's LEF thatADDITIONAL_LEFSnames along with the platform's; the design's LEF files a variable names now stay.Commits:
makeIssue: in Python, with unit tests: same archive members, run-me and vars files as makeIssue.sh on stub flows acrossWORK_HOME., relative, absolute and trailing-slash, openroad and yosys steps,FULL_ISSUE,EXCLUDE_PLATFORM,COPY_ISSUEandNUM_CORES.generate_vars: in Python, with unit tests: byte-identical.sh,.tcland.gdbfiles to generate-vars.sh in 20 cases, the nangate45 and asap7 gcd variables and edge cases; makeIssue calls it as a function.test:commits for makeIssue and three for the vars files, one per row group above.makeIssue: the file variables are the ones variables.yaml marks:type: fileinvariables.yamlreplaces makeIssue's two lists.SIG_MAP_FILEgets itsvariables.yamlentry.generate_vars: the vars files are written afresh,makeIssue: EXCLUDE_PLATFORM with any WORK_HOME,makeIssue: run-me finds the archive's root from a relative WORK_HOME: each with a test that failed before it.makeIssue: EXCLUDE_PLATFORM drops the platform variables by name:platform: trueinvariables.yamlmarks the variables that name the platform's files, as makeIssue.sh's platform list did.EXCLUDE_PLATFORMleaves those out by name, so a PDK installed outsidePLATFORM_DIRstays out, and also leaves out any file underPLATFORM_DIR, as its path is written or through a symlink.makeIssue: EXCLUDE_PLATFORM keeps the design's LEF files: the twoEXCLUDE_PLATFORMfixes above, checked in the finished archive.DFF_LIB_FILEis marked as the platform's.Tests:
flow/test/test_make_issue.pyandflow/test/test_generate_vars.py, run by the util test workflow, a few seconds, nothing beyond bash, tar and gzip installed.make floorplan_issueandmake varson nangate45 gcd were also run end to end.Under bazel-orfs, whose Python wrapper did not put a script's directory on
sys.path,makeIssue.pycould not importgenerate_vars; that is fixed there, in The-OpenROAD-Project/bazel-orfs#1645.Found in bazel-orfs, which gives each package a relative
WORK_HOME.🤖 Generated with Claude Code