Skip to content

Conversation

luismgsilva
Copy link
Member

@luismgsilva luismgsilva commented Sep 3, 2025

Add a python script that extracts the ARC CPU name and XLEN from
an ELF file by parsing the .ARC.attributes section. The script
maps CPU names to simulator options. Currently only NSIM options
are supported, but the design allows for future expansion to
other simulators.

This PR improves the current handler so that tests can be run locally
for CPUs beyond just archs, hs5x, and hs6x.

The motivation is to make local testing practical: when debugging
regressions, it is far more convenient to have an automated way to
run a specific test (or a set of tests) for any supported CPU, rather
than digging through CI logs to extract the correct execution
command for each CPU.

This does not replace CI but complements it. CI remains the
source of truth, but with this addition developers can quickly
reproduce issues locally and validate fixes before pushing.
Without this functionality, reproducing regressions is tedious
and error-prone, which slows down debugging and development.

@luismgsilva
Copy link
Member Author

Not sure if QEMU supports all CPUs but I think it makes sense to adapt this approach for it too.

Add a python script that extracts the ARC CPU name and XLEN from
an ELF file by parsing the .ARC.attributes section.  The script
maps CPU names to simulator options.  Currently only NSIM options
are supported, but the design allows for future expansion to
other simulators.

Signed-off-by: Luis Silva <[email protected]>
Updated arc64-elf-run to dynamically obtain NSIM options using
mcpu-to-cpu-opts instead of hardcoded CPU configuration while
keeping common NSIM runtime options.

Replaced arc-elf32-run and arc32-elf-run with a symlink to
arc64-elf-run.

Signed-off-by: Luis Silva <[email protected]>
Remove hardcoded QEMU CPU selection logic and instead
use "mcpu-to-cpu-opts" to dynamically determine the
appropriate CPU and XLEN from the ELF file in simulator
wrappers.

Signed-off-by: Luis Silva <[email protected]>
@luismgsilva luismgsilva marked this pull request as ready for review September 3, 2025 20:30
Comment on lines +5 to +6
import elftools.elf.elffile
import elftools.elf.sections

Choose a reason for hiding this comment

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

Should we handle the 3rd party dependency somehow?
Install in a venv in the makefile? Or at least print an error with instructions if its not found.

@abrodkin
Copy link
Member

abrodkin commented Sep 5, 2025

@luismgsilva thanks for this work but would be really nice to add a motivational part to the PR description. I.e. why do we need that functionality at all? What if we don't need that?

"-p nsim_isa_code_density_option=2",
"-p nsim_isa_mpy_option=2"
],
"hs38_linux": [
Copy link
Member

Choose a reason for hiding this comment

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

That's a very fragile approach. See, what you have here I guess is ARCv2 -mcpu value used for building a particular elf. But what if in addition to that somebody added more options like -mmpy-option={none|plus_qmacw} or -m{no-}ll64, which will disable or enable use of a certain HW features by emitting certain instructions? That's more of a guess work here and it will bite you later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, there are cases where additional options (-mmpy-option, -m{no-}ll64, etc.) affect the generated code and should be reflected in the execution command.

The intention of this PR, though, is not to cover every possible configuration detail upfront, but to provide a baseline: a generic execution command per CPU which was extracted from the Jenkins dejagnu logs. This already saves developers from having to manually search CI logs when reproducing regressions.

The script can definitely be extended in the future to handle specific feature options or more complex configurations, but even in its current form it significantly reduces the manual effort of local testing.

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.

3 participants