driver: suggest the closest triple for an unknown --target=
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- C
- 星标
- 1
- 派生
- 2
- 平均合并
- 20 小时 55 分钟
- 30 天内合并 PR
- 73
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
EmbLinkOs/EmbCC 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
enhancement
难度 4/5 3-5 天 新手友好度 50/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
area: test kind: bug preview-effort: small priority: low
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
libsdl-org/SDL#16684 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
-
Issue-Bug Needs-Triage
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复