Skip to content

#![no_builtins] should prevent a crate from participating in LTO #35540

Description

@Amanieu

This attribute is needed to prevent LLVM from optimizing a memcpy implementation into a recursive call. However this attribute is not preserved in LTO builds: the attribute only works if it is set at the top-level crate.

Since crates containing implementations of built-in functions aren't meant to be called directly, they don't benefit from LTO and should be linked as a separate object.

One workaround (using rlibc as an example) is to first compile a rlibc_inner crate as a staticlib with #![no_builtins], and then compile the rlibc crate as a rlib which links to rlibc_inner.a.

cc #31544 @alexcrichton @japaric

Activity

  1. japaric commented on Aug 13, 2016

    @japaric
    Contributor

    OK, I looked at the code around LTO and I think I know how to implement this. Will implement it and report back.

  2. japaric commented on Aug 13, 2016

    @japaric
    Contributor

    It works! I'll send a PR.

  3. added a commit that references this issue on Aug 16, 2016
    db7300d
  4. added 2 commits that reference this issue on Jul 18, 2023
  5. added a commit that references this issue on Jul 18, 2023
  6. added a commit that references this issue on Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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