driver: an unknown --opt= goal should name the valid goals

未关闭 适合新手
#190 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
83/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
cli

调研方向

阅读src/driver/main.c第8580行附近对--pass=/--no-pass=的处理,以及src/driver/options.def(第114–121行)中的--opt=条目。在tests/golden/options-table.sh或tests/golden/gcc-flags.sh中添加覆盖,检查无效目标会列出有效目标并省略用法文本。消息由选项表生成且测试通过时即完成。

由索引模型根据 Issue 内容生成。

描述

enhancement good first issue

Context. --opt= takes a goal (none, basic, debug, speed, max, size, min-size). A wrong one gets a generic error and the whole usage text:

$ ./embcc --opt=sped -c t.c
embcc: error: unknown argument '--opt=sped'
usage: embcc [-c|-S|-E] SOURCE... [-o FILE] ...

--pass= already does better: embcc: error: --pass=X: no optimizer pass has that name; the passes are a, b and c. --opt= should do the same, and suggest the closest goal.

Where.

  • src/driver/main.c, around line 8580: the --pass= / --no-pass= branch, which is the pattern to follow. The generic unknown argument error comes right after it.
  • src/driver/options.def, lines 114–121: the --opt= goals are entries in the option table, so the list does not need typing in again.
  • Tests: tests/golden/options-table.sh and tests/golden/gcc-flags.sh already check option errors.

Steps.

  1. When opt_typed(argv[i]) starts with --opt= and matched no entry, print embcc: error: --opt=sped: not a goal; the goals are none, basic, debug, speed, max, size and min-size. Build the list from the option table.
  2. Optionally, add did you mean --opt=speed? when one goal is close.
  3. Add a test that checks the message, and that the usage text is no longer printed.

Done when an unknown --opt= names the valid goals, the list comes from options.def (adding a goal there updates the message), and the tests 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

EmbLinkOs/EmbCC 的其他 Issue

查看 EmbLinkOs/EmbCC 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。