Skip to content
Adam
Build and run

Targets

Windows and Linux on x86_64, from either host.

The targets

Adam has two targets, each named by its triple only: x86_64-windows-gnu and x86_64-linux-gnu. The std, the runtime and the vendored libraries are there for both targets: a target-neutral unit picks its platform part by the target, so one import serves both (One import for both targets).

Picking one

A build's target is the triple an importing module hands down, else -t, else the main module's @target, else the host adam's own triple. @target stands in the main module's prologue, outside any branch, before the first conditional directive, once, and names a supported triple; an import built for another triple than the main module's is an error.

One adam builds for both targets: the Windows adam builds a x86_64-linux-gnu program and -r runs it through WSL; the Linux adam runs its own.

Target defines

Every file is compiled with the target's defines: TARGET_<ARCH>, TARGET_<OS>, TARGET_<ABI>, the whole triple (TARGET_X86_64_LINUX_GNU: - as _, upper case) and TARGET_64BIT.

directives_target.adam
module exe directives_target;

begin
  // The branch for the build's own target is compiled; the other is left out
@ifdef TARGET_X86_64_WINDOWS_GNU
  println("Built for x86_64-windows-gnu");
@else
  println("Built for x86_64-linux-gnu");
@endif
end.
output on x86_64-windows-gnu
Built for x86_64-windows-gnu
↑ ↓ moveEnter openEsc close