Skip to content

Tracking issue for customizing CRT linkage #37406

Closed

Description

@alexcrichton

Tracking issue for rust-lang/rfcs#1721

Be aware that "lazy link attributes" (#[link(name = "foo", cfg(foo))]) will never be stable.

Activity

  1. added a commit that references this issue on Nov 11, 2016
  2. 47 remaining items

  3. clarfonthey commented on Jul 20, 2017

    @clarfonthey
    Contributor

    So apparently, libc fails to compile on MUSL for me because of this feature:

    error: is feature gated (see issue #37406)
       --> /home/clar/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.26/src/unix/mod.rs:227:9
        |
    227 |         #[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))]
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: add #![feature(link_cfg)] to the crate attributes to enable
    
    error: is feature gated (see issue #37406)
       --> /home/clar/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.26/src/unix/mod.rs:228:9
        |
    228 |         #[link(name = "c", cfg(not(target_feature = "crt-static")))]
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: add #![feature(link_cfg)] to the crate attributes to enable
    

    But this appears to be stabilised? Am I missing something?

    (note: this is via cargo build --release --target x86_64-unknown-linux-musl)

  4. steveklabnik commented on Jul 20, 2017

    @steveklabnik
    Contributor

    @clarcharr I believe that's because it's stable in 1.19, which is gonna get released in like 45 minutes.

  5. clarfonthey commented on Jul 20, 2017

    @clarfonthey
    Contributor

    @steveklabnik sorry, I should have clarified that this is on nightly.

  6. QuietMisdreavus commented on Jul 20, 2017

    @QuietMisdreavus
    Contributor

    It looks like the issue is more about using the cfg(target_feature), rather than crt-static itself? Since #29717 is still open, i bet that's what's going on.

  7. retep998 commented on Jul 20, 2017

    @retep998
    Contributor

    libc should not be relying on the link_cfg feature except when built as part of the standard library. When built as a normal crates.io crate that attribute should not exist, which means it is likely a bug in libc.

  8. jirutka commented on Jul 20, 2017

    @jirutka
  9. clarfonthey commented on Jul 20, 2017

    @clarfonthey
    Contributor

    @retep998 I'm having trouble imagining this as a bug in libc considering how musl is a tested target; maybe a recent change triggered this?

  10. retep998 commented on Jul 20, 2017

    @retep998
    Contributor

    The syntax #[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))] is intended to be an unstable detail only used for libc when built as part of the standard library because the standard library is compiled at a point where it does not know whether the user wants a static CRT or dynamic CRT.

    As far as I can tell by looking at the code, that attribute should only even be activated during a cargo build when you've opted out of the use_std default feature. However I see that CI does test cargo build --no-default-features which makes me wonder whether it is testing that target. Because it doesn't explicitly specify --target that means.... it isn't actually testing that target until it does the docker tests, which never build the crate with --no-default-features!

  11. clarfonthey commented on Jul 20, 2017

    @clarfonthey
    Contributor

    aha!

    I'll link this in a comment on libc to point out that the musl build is indeed failing.

  12. varkor commented on Apr 3, 2020

    @varkor
    Contributor

    This issue is still linked to in errors for #[link(cfg(foo))], so shouldn't it still be open?

  13. petrochenkov commented on May 9, 2020

    @petrochenkov
    Contributor

    @varkor

    This issue is still linked to in errors for #[link(cfg(foo))], so shouldn't it still be open?

    It's better to make a new issue (or remove reference to this issue from the feature gate).

  14. varkor commented on May 9, 2020

    @varkor
    Contributor

    I've opened #72059, though I haven't had time to look into the state of this feature.

  15. added a commit that references this issue on Mar 23, 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

    B-unstableBlocker: Implemented in the nightly compiler and unstable.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions