driver: suggest the closest triple for an unknown --target=
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 85/100
Research direction
Read src/driver/main.c around the unknown-target error and src/sema/sema.c around edit_distance() to understand the existing suggestion logic. Share that helper for the driver, then update tests/golden/triple.sh to cover a one-letter typo and a distant target such as banana. Done when the typo suggests the closest built triple, the distant target gets no suggestion, and the listed checks pass.
Written by the indexing model from the issue text.
Description
Context. A mistyped triple gets the whole list of targets EmbCC knows, with no hint about which one was meant:
$ ./embcc --target=thumbv7m-none-eab -c t.c
embcc: error: unknown target 'thumbv7m-none-eab'
embcc: the targets it emits for are:
embcc: x86_64-elf
...
clang and GCC users expect did you mean 'thumbv7m-none-eabi'?.
Where.
src/driver/main.c, around line 7091: theunknown targeterror, which walkstarget_triple_count()/target_triple_name().src/sema/sema.c, line 2108:edit_distance(), a bounded Levenshtein distance that already powers "did you mean" for undeclared names. It isstaticthere. Move it somewhere the driver can share (for examplesrc/driver/util.candutil.h), rather than copying it.- Tests:
tests/golden/triple.shalready checks the unknown-target error.
Steps.
- Make
edit_distanceshareable, and keep sema's use of it unchanged. - In the unknown-target branch, find the built triple (
target_triple_built(t)) closest to what was typed. If it is within a few edits (sema usesmax(2, len / 3)), printembcc: note: did you mean 'X'?before the list. - Add cases to
tests/golden/triple.sh: a one-letter typo gets the suggestion, and something far from every triple (--target=banana) gets none.
Done when --target=thumbv7m-none-eab suggests thumbv7m-none-eabi, a nonsense triple suggests nothing, the test covers both, and make check and sh tests/golden/triple.sh pass.
Before you start: the contributor's guide has the rules. A new test counts only after it has failed against the code before your change, and a commit subject reads area: summary. Questions are welcome in the comments or in Discussions.
- Dominant language
- C
- Stars
- 1
- Forks
- 2
- Avg merge
- 20h 55m
- Merged PRs (30d)
- 73
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from EmbLinkOs/EmbCC
-
avr: errno does not link: __errno_location is not in the C libraryPossibly taken @Firat17aze claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 50/100
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
SPIDevice selects an active-high device as soon as it is createdPossibly taken @mikeysklar claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
adafruit/circuitpython#11869 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
gnif/LookingGlass#1352 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100