[][src]Module rustc_ap_rustc_target::spec::crt_objects

Object files providing support for basic runtime facilities and added to the produced binaries at the start and at the end of linking.

Table of CRT objects for popular toolchains. The crtx ones are generally distributed with libc and the begin/end ones with gcc. See https://dev.gentoo.org/~vapier/crt.txt for some more details.

Pre-link CRT objectsglibcmuslbionicmingwwasi
dynamic-nopic-execrt1, crti, crtbegincrt1, crti, crtbegincrtbegin_dynamiccrt2, crtbegincrt1
dynamic-pic-exeScrt1, crti, crtbeginSScrt1, crti, crtbeginScrtbegin_dynamiccrt2, crtbegincrt1
static-nopic-execrt1, crti, crtbeginTcrt1, crti, crtbegincrtbegin_staticcrt2, crtbegincrt1
static-pic-exercrt1, crti, crtbeginSrcrt1, crti, crtbeginScrtbegin_dynamiccrt2, crtbegincrt1
dynamic-dylibcrti, crtbeginScrti, crtbeginScrtbegin_sodllcrt2, crtbegin-
static-dylib (gcc)crti, crtbeginTcrti, crtbeginScrtbegin_sodllcrt2, crtbegin-
static-dylib (clang)crti, crtbeginTN/Acrtbegin_staticdllcrt2, crtbegin-
Post-link CRT objectsglibcmuslbionicmingwwasi
dynamic-nopic-execrtend, crtncrtend, crtncrtend_androidcrtend-
dynamic-pic-execrtendS, crtncrtendS, crtncrtend_androidcrtend-
static-nopic-execrtend, crtncrtend, crtncrtend_androidcrtend-
static-pic-execrtendS, crtncrtendS, crtncrtend_androidcrtend-
dynamic-dylibcrtendS, crtncrtendS, crtncrtend_socrtend-
static-dylib (gcc)crtend, crtncrtendS, crtncrtend_socrtend-
static-dylib (clang)crtendS, crtnN/Acrtend_socrtend-

Use cases for rustc linking the CRT objects explicitly: - rustc needs to add its own Rust-specific objects (mingw is the example) - gcc wrapper cannot be used for some reason and linker like ld or lld is used directly. - gcc wrapper pulls wrong CRT objects (e.g. from glibc when we are targeting musl).

In general it is preferable to rely on the target's native toolchain to pull the objects. However, for some targets (musl, mingw) rustc historically provides a more self-contained installation not requiring users to install the native target's toolchain. In that case rustc distributes the objects as a part of the target's Rust toolchain and falls back to linking with them manually. Unlike native toolchains, rustc only currently adds the libc's objects during linking, but not gcc's. As a result rustc cannot link with C++ static libraries (#36710) when linking in self-contained mode.

Enums

CrtObjectsFallback

Which logic to use to determine whether to fall back to the "self-contained" mode or not.

Type Definitions

CrtObjects