Skip to content

CEP-0042: Custom Link-Name Expressions

Draft

Draft proposal for link-name expressions beyond V1 string literals. V1 @link_name uses explicit strings.

Summary

Catalyst should eventually decide whether external link names can be computed from comptime expressions.

V1 keeps @link_name("...") as a literal string attribute argument.

Example

Possible future shape:

const prefix = comptime target_symbol_prefix()

@export(.c)
@link_name(prefix ++ "process")
fn process(input: f32) f32 {
  return input
}

V1 requires the link name to be a literal string.

Motivation

Computed link names can reduce repetition for generated bindings or platform-specific exports. They can also obscure external ABI and complicate diagnostics and reproducible builds.

Proposed Direction

The proposal should cover:

  • allowed comptime expression forms for link names;
  • determinism and caching;
  • diagnostics for invalid external names;
  • reflection and generated header behavior;
  • interaction with generated declarations.

V1 Compatibility

V1 @link_name takes an explicit string and requires @export(.c) or @extern(.c).