Skip to content

Compile for the host when no target is named, as GCC and clang do - #198

Merged
teo1747 merged 1 commit into
mainfrom
hostdefault
Nov 9, 2026
Merged

teo1747 merged 1 commit into
mainfrom
hostdefault

Conversation

@teo1747

@teo1747 teo1747 commented Nov 8, 2026

Copy link
Copy Markdown
Member

embcc with no --target= now compiles for the machine it runs on, as GCC and clang do. It used to build for x86_64-elf, a freestanding kernel target, so embcc hello.c -o hello failed to link on a Mac.

Host Default
arm64 Mac aarch64-apple-darwin
Intel Mac x86_64-apple-darwin
Linux x86-64 / arm64 x86_64-linux-gnu / aarch64-linux-gnu
Windows x86_64-windows-gnu
EmbLinkOS (the on-OS compiler) x86_64-emblink
  • The host is read from the compiler that builds EmbCC, so it is baked in, as GCC's is.
  • EMBCC_DEFAULT_TARGET, make DEFAULT_TARGET= and --target= still win, in that order.
  • On a host with no hosted target, or in a build without its family (make TARGETS=), the old fallback applies.
  • What relied on the old default now names --target=x86_64-elf: check-self, libcxx-x86_64, gen-selfhost-ref.sh and os-stage.sh.
  • tests/run.sh pins the suite to x86_64-elf, as its tests were written against it. default-target.sh checks the new rule.

EmbLinkOS needs one change before this merges: its mathself recipe (Makefile lines 1616–1618) calls $(HOST_EMBCC) -c … with no --target= and must add --target=x86_64-elf.

`embcc hello.c -o hello` built for x86_64-elf, a freestanding kernel
target, whatever the machine was. On a Mac it then failed to link
("entry symbol '_start' is undefined"). GCC and clang build for the host
when nothing names a target, and EmbCC now does too: aarch64-apple-darwin
on an arm64 Mac, x86_64-apple-darwin on an Intel one, x86_64-linux-gnu
or aarch64-linux-gnu on Linux, x86_64-windows-gnu on Windows, and
x86_64-emblink for the compiler EmbCC builds for EmbLinkOS. The host is
read from the compiler that built EmbCC, so the default is baked in, as
GCC's is. On a host with no hosted target, or in a compiler built
without that host's family (make TARGETS=), it is x86_64-elf or the
first family built, as before. EMBCC_DEFAULT_TARGET, a compiled-in
DEFAULT_TARGET and --target= still win, in that order.

What relied on the old default now names it: check-self, libcxx-x86_64,
tools/gen-selfhost-ref.sh and tools/os-stage.sh. tests/run.sh exports
EMBCC_DEFAULT_TARGET=x86_64-elf, because the suite's tests were written
against x86_64-elf as the target nothing names, and name every other
one. default-target.sh unsets it and expects the host. The manual, the
README and the roadmap say so, and the roadmap's open decision is
closed.

EmbLinkOS's mathself recipe calls embcc with no --target= and needs
--target=x86_64-elf (its Makefile, lines 1616-1618).
@teo1747
teo1747 marked this pull request as ready for review November 8, 2026 23:49
@teo1747
teo1747 merged commit 81dba95 into main Nov 9, 2026
21 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.

1 participant