Repository navigation
Fix robustness bugs, harden CI, support python 3.10-3.14, bump to 1.0.1 - #8
Merged
Merged
Conversation
Compiler driver: - Replace os.system + assert with subprocess.run(check=True): the make call no longer disappears under `python -O`, paths with spaces and shell metacharacters are passed safely, and failures raise a RuntimeError instead of an AssertionError. - Stop mutating the module-level C2FJ_MAKE_VARS; build the make vars per call so sequential/concurrent c2fj() calls don't leak state. - Quote the per-file variables in Makefile_single_c_generic so paths with spaces survive the recipe expansion. - Raise a clear ValueError when --finish-after elf/fj/fjm is used without --build-dir (the outputs used to be silently deleted with the temporary build directory). riscv instructions: - Remove the pc_changed global; jal_op now returns whether the pc was changed, and write_op tracks it locally. - Make write_rv32m_op raise InvalidOpcode on unmatched funct3, fix the u_type annotation, and plumb error_on_unimplemented_op through create_fj_files_from_riscv_elf. Linker script: - Also collect plain *(.text) input sections (objects built without -ffunction-sections were placed as orphan sections). Packaging & CI: - Bump version to 1.0.1, fix the license id to the valid SPDX BSD-2-Clause, support exactly python 3.10-3.14, and update the dependency floors (pyelftools>=0.33, pytest^9, pytest-xdist^3.8). - Tests workflow: run on push to main too, test on a 3.10-3.14 matrix, pin all actions to commit SHAs, drop the mutable @main action ref. - Publish workflow: gate publishing on the tests passing, build with poetry and publish with pypa/gh-action-pypi-publish (pinned), with a note about migrating to PyPI Trusted Publishing. - Rename gitattributes.txt to .gitattributes so it takes effect, and remove the stray empty CMakeLists file. Docs & tests: - README: fix the --unify-fj flag name and the c2fj usage line, state the supported python versions, and document the known limitations (no EOF, div-by-zero exits, no fence). - Add unit tests for the riscv instruction encoding (inc_pc behavior, syscall jals, invalid-op fallback) and driver tests for the new error paths, path-with-spaces compilation, and make-vars isolation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Make tests.yml reusable (workflow_call) and call it from the publish workflow, so releases are gated on the full python 3.10-3.14 matrix instead of a duplicated single-version test job. - Cache pip in the tests workflow (keyed on pyproject.toml). - Raise a dedicated MakeFailedError (RuntimeError subclass) instead of a bare RuntimeError when the make step fails. - Plumb error_on_unimplemented_op through compile_riscv_to_fj and c2fj(), completing the previously half-plumbed parameter. - Quote the c2fj-provided paths in the README example Makefile, in line with the generic single-c Makefile. - Extract the duplicated bad-C-file setup in tests into a helper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pre-release hardening pass over the whole codebase, following a full security/bug review.
Compiler driver (
c2fj_main.py)os.system+assertwithsubprocess.run(check=True)— the make invocation no longer vanishes underpython -O(the call lived inside the assert), paths with spaces/shell metacharacters are passed safely (no shell), and failures raiseRuntimeErrorinstead ofAssertionError.c2fj()calls can't leakSINGLE_C_FILE/ELF_OUT_PATHinto each other.--finish-after elf|fj|fjmnow requires--build-dir— previously the outputs were written into a temporary directory and silently deleted.Makefile_single_c_genericso paths with spaces survive recipe expansion (covered by a new integration test).RISC-V translation (
riscv_instructions.py,riscv_to_fj.py)pc_changedglobal;jal_opreturns whether the pc changed andwrite_optracks it locally.write_rv32m_opraisesInvalidOpcodeon unmatched funct3 instead of writing nothing.error_on_unimplemented_opthroughcreate_fj_files_from_riscv_elf(was a dead parameter).u_typereturn annotation.Linker script
*(.text)input sections — objects built without-ffunction-sections(e.g. libgcc) were placed as orphan sections by heuristic.Packaging
BSD-2-Clause(wasBSD-2-Clause-Simplified, so the PyPI license classifier was wrong).>=3.10,<3.15), classifiers updated accordingly.pyelftools>=0.33,pytest^9,pytest-xdist^3.8(all verified compatible with the new python range;flipjump>=1.3.0unchanged — 1.3.0 is the latest).CI
tests.yml: runs on push tomaintoo, tests a 3.10–3.14 matrix, all actions pinned to commit SHAs (the previouspmeier/pytest-results-action@mainwas a mutable-branch supply-chain risk).poetry-publish.yml: publishing is now gated on the tests passing, builds with poetry and publishes via pinnedpypa/gh-action-pypi-publish. A comment notes the recommended follow-up migration to PyPI Trusted Publishing (needs one-time PyPI-side setup).Repo hygiene & docs
gitattributes.txt→.gitattributes(it had no effect under the old name); removed the stray emptyCMakeLists.--unify_fj→--unify-fj, outdatedpython3 c2fj.pyusage →c2fj, stated supported python versions, and added a Known Limitations section (no EOF, div-by-zero exits with an error, no fence support).Tests added
tests/test_riscv_instructions.py— pure-python unit tests for instruction encoding:inc_pcemission for ALU/jump/branch/syscall ops, pc-state isolation between ops, invalid-op fallback vs. raise,sign_extend/fj_hex.tests/test_c2fj.py— new driver tests: failing make raisesRuntimeError, make vars aren't mutated,finish_afterwithoutbuild_dirraises, compiling from a directory with spaces, and two sequential compilations (c-file then Makefile) in one process.Test plan
🤖 Generated with Claude Code