Skip to content

link: embld --help prints the usage on stdout and exits 0 - #201

Merged
teo1747 merged 1 commit into
EmbLinkOs:mainfrom
draarivpatel-ui:embld-help-usage
Nov 9, 2026
Merged

teo1747 merged 1 commit into
EmbLinkOs:mainfrom
draarivpatel-ui:embld-help-usage

Conversation

@draarivpatel-ui

Copy link
Copy Markdown
Contributor

Closes #193.

embld --help is refused today with embld: unknown option '--help' and exit status 2. The other Emb tools that have a usage text answer it (embsim --help, embmap --help).

What changes

  • The usage text moves into one function, usage(FILE *), in tools/embld/embld.c.
  • --help and -h print the usage on stdout and exit 0.
  • A bare embld with no inputs still prints the same usage on stderr and exits 2.
  • No other option or behaviour changes.

Test

tests/golden/embld-help.sh checks the exit status and the stream for each case, not only that the words appear.

Before this change the test fails:

FAIL: --help exited 2, want 0
embld: unknown option '--help'

After it, the test passes for --help, -h and the bare invocation.

What was run

  • make embcc embld builds with -Werror.
  • tests/golden/embld-help.sh passes.
  • The other embld golden tests were run. Several skip on this host (no llvm-readelf, no clang for riscv64, no qemu-system-arm).
  • Not run: make check, make test, make test-arm64. The host is macOS.

tests/golden/embld-doctor.sh fails on this macOS host. The same failure happens with the original tools/embld/embld.c, so it is not caused by this change. It has not been investigated here.

`embld --help` (and `-h`) was refused as "unknown option '--help'" with
exit status 2, while the other Emb tools with a usage text answer it.
The usage text is now one function, usage(FILE *), used by --help (stdout,
exit 0) and by a bare invocation with no inputs (stderr, exit 2, as before).

The test is tests/golden/embld-help.sh. Against the code before this change
it failed with:

    FAIL: --help exited 2, want 0
    embld: unknown option '--help'

After it, the test passes (--help, -h, and the bare invocation are each
checked for exit status and for which stream carries the text).

Also run: make embcc embld, then tests/golden/embld-{help,merge,
defined-wins,bss-align,reloc-range,veneers}.sh with EMBLD and EMBCC set to the
built binaries. Several of them skip on this host (no llvm-readelf, clang
for riscv64, qemu-system-arm). Not run: make check, make test, make test-arm64.
This host is Darwin, not Linux.

embld-doctor.sh fails on this host with "doctor exited 0 with symbols
undefined". The same failure happens with the original tools/embld/embld.c,
so it is not caused by this change; it is not investigated here.
Copilot AI balanced review requested due to automatic review settings November 9, 2026 02:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@teo1747 teo1747 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution, and welcome! The change and the test look great.

@teo1747
teo1747 merged commit de4204b into EmbLinkOs:main Nov 9, 2026
17 checks passed
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.

embld: --help prints the usage

3 participants