Skip to content

Merge compiler-builtins into core #49380

Description

@japaric

This is a P-high embedded-WG issue that needs to be fixed to make embedded Rust work on stable.

Background:

The compiler-builtins crate contains compiler intrinsics that LLVM may call when lowering operations like i64 multiplication to machine code. This crate currently is its own crate due to these requirements: its object file needs to appear at the end of the linker argument list and it needs be marked with the #![compiler_builtins] attribute (symbol visibility, etc.).

On #![no_std] compiler-builtins needs to appear in the dependency graph to avoid linker errors but that requires the #[feature(compiler_builtins_lib)] feature gate because the crate is unstable -- it's a compiler implementation detail.

The fix is to put the compiler intrinsics into core and eliminate the compiler-builtins crate from the std facade. This has become possible thanks to recent progress in multiple codegen units.

What roughly needs to be done

  • Include compiler-builtins as source code into core using something like #[path = "../compiler-builtins/src/lib.rs"] mod intrinsics.

  • Create some attribute to mark the whole intrinsics module as #![compiler_builtins] and to force the whole module to be into its own codegen unit so it gets its own object file.

cc @michaelwoerister @eddyb @alexcrichton

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions