Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dynamically-linked and/or native musl targets #40113

Merged
merged 14 commits into from
Aug 23, 2017

Commits on Aug 22, 2017

  1. Remove incorrect special case of mips-musl

    The libdl/librt/libpthread provided by musl are no-op (empty static
    libraries) on all architectures, mips included.
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    15c141c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1757a87 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8606782 View commit details
    Browse the repository at this point in the history
  4. Copy musl startup objects before building std

    They are required for linking it, even though it is a library, because
    crtn.o in post_link_objects, as hardcoded in src/librustc_back/target/
    linux_musl_base.rs, is added to the linker command line for both
    executables and libraries.
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    0c7a0e9 View commit details
    Browse the repository at this point in the history
  5. Introduce crt_static target option in config.toml

    This controls the value of the crt-static feature used when building the
    standard library for a target, as well as the compiler itself when that
    target is the host.
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    4b09dc6 View commit details
    Browse the repository at this point in the history
  6. Inline crt-static choice for pc-windows-msvc

    This avoids the possibility of a duplicate or conflicting crt-static
    command line option sent to rustc.
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    5283243 View commit details
    Browse the repository at this point in the history
  7. Factor out a helper for the getting C runtime linkage

    This commit makes no functional changes.
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    3cb9878 View commit details
    Browse the repository at this point in the history
  8. Introduce temporary target feature crt_static_respected

    This feature allows targets to opt in to full support of the crt-static
    feature. Currently, crt-static is allowed on all targets, even those
    that really can't or really shouldn't support it. This works because it
    is very loose in the specification of its effects. Changing the behavior
    of crt-static to be more strict in how it chooses libraries and links
    executables would likely cause compilation to fail on these platforms.
    
    To avoid breaking existing uses of crt-static, whitelist targets that
    support the new, stricter behavior. For all other targets, this changes
    crt-static from being "mostly a no-op" to "explicitly a no-op".
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    beb8abe View commit details
    Browse the repository at this point in the history
  9. Introduce target feature crt_static_allows_dylibs

    Most UNIX-like platforms do not allow shared libraries to statically
    link their own libc, as libc expects to have consistent process-global
    state. On those platforms, when we do not have a shared libc available,
    we must not attempt to link dylibs or cdylibs. On Windows, however, it
    is expected to statically link the CRT into dynamic libraries.
    
    This feature is only relevant for targets that support both fully-static
    and fully-dynamic linkage, such as musl on Linux.
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    12ceed0 View commit details
    Browse the repository at this point in the history
  10. Disable PIE when linking statically

    Static PIE support, while supported on musl, requires a patch to GCC.
    Until/unless it is merged, adding '-pie' to the linker command line will
    override '-static' and create a binary that requires a dynamic
    interpreter (ld.so).
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    054f310 View commit details
    Browse the repository at this point in the history
  11. Tell the linker when we want to link a static executable

    If the C runtime is linked statically, explicitly tell the linker that
    the executable should be static.
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    bab6911 View commit details
    Browse the repository at this point in the history
  12. Update libunwind dependencies for musl

    Use libgcc_s when linking dynamically. Convert the static libunwind to
    static-nobundle, as libunwind.a is copied from musl_root and available
    in the library search path.
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    c964567 View commit details
    Browse the repository at this point in the history
  13. Support dynamic linking for musl-based targets

    Note that this commit does not affect mips-musl targets, as they do not
    inherit from linux_musl_base.
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    565a863 View commit details
    Browse the repository at this point in the history
  14. Update ignored tests for dynamic musl

    Now that musl supports dynamic libraries (although not by default)
    enable the tests that now pass. Additional currently-ignored tests
    will pass if rustc is built with crt_static=false in config.toml.
    smaeul committed Aug 22, 2017
    Configuration menu
    Copy the full SHA
    e6cd941 View commit details
    Browse the repository at this point in the history