Skip to content

Releases

dartc 0.5.0

Choose a tag to compare

@medz medz released this 30 Oct 17:17

dartc 0.5.0 adds generic classes, automatic memory reclamation, Intel Mac support, and native-library exports with generated C/C++ headers. Native compiler downloads now contain a self-contained executable.

This remains an early preview. Complete Dart language and standard-library compatibility is the goal; current behavior and gaps are recorded in the 0.5 specification tracker.

Upgrading from 0.4: replace the previous native installation with the 0.5.0 archive. Its bin/dartc can be copied anywhere on PATH, without an adjacent lib/ directory. Native-library exports now use @Export<T> instead of --export or Pointer.fromFunction. The Dart package requires SDK ^3.13.7.

🧩 Generic Dart classes

Generic instances and const objects retain their type arguments, with constructor inference, runtime type checks and generic object patterns:

class Box<T>(final T value);

void main() {
  final box = Box(42);
  print(box.value);
}

This release also adds class modifiers, sealed-class exhaustiveness checks, covariant members, abstract instance fields and broader field/callback inference. See the changelog for the full list.

📦 Standalone native compilers

Extract the archive for your platform and add its bin directory to PATH. The compiler includes its required library sources, so it can be moved as a single executable. Generated programs also run without an installed Dart SDK.

Managed objects can now be reclaimed instead of being retained until process exit. Code generation also improves polymorphic calls, ARM64 double arithmetic and common string operations.

Supported runtime failures, including invalid numeric parsing and integer division by zero, now throw catchable Dart errors or exceptions. Diagnostics include source locations and are written to stderr.

🔗 Native libraries and C/C++ headers

Declare exports in Dart using FFI types:

import 'dart:ffi';
import 'package:dartc/export.dart';

@Export<Int64 Function(Int64, Int64)>()
int add(int a, int b) => a + b;

@Export<Int64>()
const int answer = 42;
dartc math.dart --emit static -o libmath.a --header math.h

Object, static-library and shared-library outputs are available for macOS and Linux on ARM64 and x86-64. Exports currently cover C-ABI-safe functions and scalar read-only data; managed-runtime exports remain a gap. See supported FFI declarations.

Downloads

Platform Archive
macOS ARM64 dartc-0.5.0-macos-arm64.tar.gz
macOS Intel dartc-0.5.0-macos-x64.tar.gz
Linux ARM64 dartc-0.5.0-linux-arm64.tar.gz
Linux x86-64 dartc-0.5.0-linux-x64.tar.gz

Archive checksums are listed in SHA256SUMS.

Dart package

With Dart SDK ^3.13.7 installed:

dart pub global activate dartc 0.5.0

Full changelog · Changes since 0.4 · Language support

v0.4.0 — Classes, exceptions and Linux x86-64

Choose a tag to compare

@medz medz released this 29 Oct 05:25

dartc 0.4.0 brings class hierarchies, enums, custom operators, native doubles and synchronous exceptions to the native compiler. It also adds a Linux x86-64 archive alongside macOS ARM64 and Linux ARM64.

Upgrading from 0.3: replace the whole native archive, including lib/. The internal runtime ABI moves from 14 to 17. Use a 0.4.0 native seed when rebuilding the compiler from source; the compiler now uses syntax that 0.3 cannot compile. See the upgrade steps below.

🧩 Use richer Dart classes and function values

Combine primary constructors, enums, constructor values, operators and contextual dot shorthands in ordinary Dart code:

enum Axis { x, y }

class Vector(final double x, final double y) {
  Vector operator +(Vector other) => Vector(x + other.x, y + other.y);

  double component(Axis axis) => switch (axis) {
    .x => x,
    .y => y,
  };
}

void main() {
  final create = Vector.new;
  final sum = create(1.5, 2.0) + create(2.0, 4.0);
  print(sum.component(.x)); // 3.5
}

Non-generic classes also gain abstract declarations, inheritance, interfaces, super parameters and factory constructors. Enums provide values, index and name; their switches are checked for exhaustiveness. Custom indexing operators work with compound assignment and increments, preserving evaluation order and separate read/write conversions.

Function values now accept optional and named arguments, including the target's defaults:

String decorate(String value, {String prefix = 'dartc'}) => '$prefix: $value';

void main() {
  final format = decorate;
  print(format('hello', prefix: 'native')); // native: hello
}

Non-generic closures inside generic functions can also retain enclosing type arguments after the outer call returns.

Classes and constructors · Function values and captures

🧹 Handle synchronous failures and cleanup

throw, typed catches, finally and rethrow now work across native call frames. finally runs on normal completion, exceptions, returns and jumps:

double positive(String input) {
  final value = double.parse(input);
  if (value < 0) throw 'negative value';
  return value;
}

void main() {
  try {
    print(positive('-1.5'));
  } on String catch (message) {
    print(message); // negative value
  } finally {
    print('done');
  }
}

Catch clauses can receive a stack trace. StackTrace.current, StackTrace.fromString and StackTrace.empty are available too. This covers synchronous Dart throws; failed type, bounds, late and other runtime checks still terminate the process rather than producing catchable exceptions.

Exception behavior and remaining work

🐧 Compile for Linux x86-64

The new linux-x64 target uses the same language implementation as the ARM64 targets. Select it explicitly when cross-compiling:

dartc app.dart --target linux-x64 -o app-linux-x64

Run the resulting executable on Linux x86-64. Native compiler archives include the matching Dart runtime sources; compilation and generated executables need no installed Dart SDK or VM. Linux library output and external FFI remain unimplemented.

Other changes

  • Double arithmetic, decimal parsing, shortest round-trip formatting and numeric conversions are now available, including mixed numeric values and constants.
  • late locals, captures, globals and typed fields initialize lazily and check final writes and recursive initialization.
  • ARM64 integer division and modulo by zero now stop before later side effects. Non-returning calls and missing-return checks also preserve their control-flow behavior through native compilation.

Upgrading and downloads

Download the archive matching your host and verify it against SHA256SUMS:

Platform Download
macOS ARM64 dartc-0.4.0-macos-arm64.tar.gz
Linux ARM64 dartc-0.4.0-linux-arm64.tar.gz
Linux x86-64 dartc-0.4.0-linux-x64.tar.gz

Keep bin/ and lib/ from the same archive. For a source checkout with an older seed, explicitly select the new compiler, for example on macOS ARM64:

dart tool/bootstrap.dart --seed /path/to/dartc-0.4.0-macos-arm64/bin/dartc

The pub package hosts dartc on the official Dart SDK. Update that distribution with:

dart pub global activate dartc 0.4.0

0.4.0 remains an early preview, with Dart SDK 3.13.7 as the behavior reference. Complete Dart language and standard-library implementation remains the goal; specs owns the current support and gaps.

Installation · Changelog · All changes since 0.3.0

v0.3.0 - native compiler preview

Choose a tag to compare

@medz medz released this 28 Oct 03:02

dartc 0.3.0 is an early preview of an independent native Dart compiler written in Dart. The compatibility reference is Dart SDK 3.13.7; complete Dart language and standard-library implementation remains the goal.

This release adds:

  • Capturing local and anonymous functions, bound instance-method values and callable objects.
  • Generic top-level and method calls with bounds, partial inference and runtime type arguments, plus generic aliases and traditional typedefs.
  • Switch expressions, if-case, object/List patterns, destructuring and pattern switch statements.
  • Cascades, null-aware access and List conditional, loop, spread and null-aware elements.
  • Static members, named and const constructors, field initializer lists and generative redirection.
  • Dart implementations of List insertion, removal and slicing, and StringBuffer character writing.
  • SSA contract checks, runtime type-graph root enumeration, reproducible differential cases and compiler/program resource measurements.

Download the macOS ARM64 or Linux ARM64 archive and verify it against SHA256SUMS. Keep its bin/ and lib/ directories together. The native compiler and generated executables run without the official Dart SDK or VM.

The runtime ABI is now 14, up from 11 in 0.2. Use the compiler and runtime sources from the same release.

Inheritance, generic classes, generic function values, exceptions, async code, isolates and most SDK libraries remain incomplete. Failed runtime checks terminate the process, and managed storage is retained until process exit. Self-rebuilds do not establish complete language compatibility.

The pub package provides the SDK-hosted compiler: dart pub global activate dartc 0.3.0.

Installation · Language support and gaps · Changelog

v0.2.0 - native compiler preview

Choose a tag to compare

@medz medz released this 27 Oct 07:50

dartc is an independent native Dart compiler written in Dart, targeting complete Dart language implementation. Its goal is for Dart to bootstrap and evolve its own compiler, runtime and standard libraries through an optimizing native toolchain.

Version 0.2.0 is an early preview for macOS and Linux ARM64. The compatibility baseline is Dart 3.13.5; language implementation is in progress. Native compiler binaries and generated executables run without the Dart SDK, VM or snapshots.

Download the archive for your platform, verify it against SHA256SUMS, extract it, and add its bin/ directory to PATH. Keep bin/ and lib/ together: the archive includes the matching Dart runtime sources.

This version adds simple classes and accessors, nullable and runtime type checks, canonical const instances, lazy globals, noncapturing local and anonymous functions, structural function types, package configuration v2, language version selection, conditional imports, and library parts.

Capturing closures, inheritance, general generics, exceptions, async code, isolates and most SDK libraries remain unsupported. Managed storage is retained until process exit. Self-hosting is a milestone; it does not imply full language compatibility.

The pub package is also available as dart pub global activate dartc; that distribution uses the Dart SDK to host the compiler.

Installation and usage · Language support and gaps · Architecture