]> git.lizzy.rs Git - rust.git/commitdiff
Stabilise link-self-contained option
authorMateusz Mikuła <mati865@gmail.com>
Thu, 30 Jul 2020 20:10:48 +0000 (22:10 +0200)
committerMateusz Mikuła <mati865@gmail.com>
Mon, 31 Aug 2020 13:13:31 +0000 (15:13 +0200)
compiler/rustc_codegen_ssa/src/back/link.rs
compiler/rustc_interface/src/tests.rs
compiler/rustc_session/src/options.rs
src/doc/rustc/src/codegen-options/index.md

index bfcf979d1254865292d66958bcb165a9635f4719..8e272282f40f96b819182003a69cc9c5db4bb88c 100644 (file)
@@ -1084,7 +1084,7 @@ fn probe(sess: &Session) -> Option<PathBuf> {
 
 fn get_object_file_path(sess: &Session, name: &str, self_contained: bool) -> PathBuf {
     // prefer system {,dll}crt2.o libs, see get_crt_libs_path comment for more details
-    if sess.opts.debugging_opts.link_self_contained.is_none()
+    if sess.opts.cg.link_self_contained.is_none()
         && sess.target.target.llvm_target.contains("windows-gnu")
     {
         if let Some(compiler_libs_path) = get_crt_libs_path(sess) {
@@ -1289,7 +1289,7 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
 /// Whether we link to our own CRT objects instead of relying on gcc to pull them.
 /// We only provide such support for a very limited number of targets.
 fn crt_objects_fallback(sess: &Session, crate_type: CrateType) -> bool {
-    if let Some(self_contained) = sess.opts.debugging_opts.link_self_contained {
+    if let Some(self_contained) = sess.opts.cg.link_self_contained {
         return self_contained;
     }
 
@@ -1499,7 +1499,7 @@ fn link_local_crate_native_libs_and_dependent_crate_libs<'a, B: ArchiveBuilder<'
 /// Add sysroot and other globally set directories to the directory search list.
 fn add_library_search_dirs(cmd: &mut dyn Linker, sess: &Session, self_contained: bool) {
     // Prefer system mingw-w64 libs, see get_crt_libs_path comment for more details.
-    if sess.opts.debugging_opts.link_self_contained.is_none()
+    if sess.opts.cg.link_self_contained.is_none()
         && cfg!(windows)
         && sess.target.target.llvm_target.contains("windows-gnu")
     {
index cb906b3d911640bbe01605a3c5f1fab9698ecd50..ada8dc90494bc1194c77d5707149022d2028c890 100644 (file)
@@ -402,6 +402,7 @@ macro_rules! untracked {
     // `link_arg` is omitted because it just forwards to `link_args`.
     untracked!(link_args, vec![String::from("abc"), String::from("def")]);
     untracked!(link_dead_code, Some(true));
+    untracked!(link_self_contained, Some(true));
     untracked!(linker, Some(PathBuf::from("linker")));
     untracked!(linker_flavor, Some(LinkerFlavor::Gcc));
     untracked!(no_stack_check, true);
index 82330d9a5331ab579646280a8584c60ebe6e69fa..25d988e87fddecfdf489ddb65da30786d3fc4641 100644 (file)
@@ -719,6 +719,9 @@ fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
         "extra arguments to append to the linker invocation (space separated)"),
     link_dead_code: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
         "keep dead code at link time (useful for code coverage) (default: no)"),
+    link_self_contained: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
+        "control whether to link Rust provided C objects/libraries or rely
+        on C toolchain installed in the system"),
     linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
         "system linker to link outputs with"),
     linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
@@ -894,9 +897,6 @@ fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
         "keep hygiene data after analysis (default: no)"),
     link_native_libraries: bool = (true, parse_bool, [UNTRACKED],
         "link native libraries in the linker invocation (default: yes)"),
-    link_self_contained: Option<bool> = (None, parse_opt_bool, [TRACKED],
-        "control whether to link Rust provided C objects/libraries or rely
-         on C toolchain installed in the system"),
     link_only: bool = (false, parse_bool, [TRACKED],
         "link the `.rlink` file generated by `-Z no-link` (default: no)"),
     llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
index 7b0280d5b78a74bc2b014782e1e113aebd11ae86..bed10ca16d326aec62183dbacfd96bbf7a32630c 100644 (file)
@@ -44,13 +44,13 @@ incremental builds the default is 256 which allows caching to be more granular.
 
 ## control-flow-guard
 
-This flag controls whether LLVM enables the Windows [Control Flow 
-Guard](https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard) 
-platform security feature. This flag is currently ignored for non-Windows targets. 
+This flag controls whether LLVM enables the Windows [Control Flow
+Guard](https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard)
+platform security feature. This flag is currently ignored for non-Windows targets.
 It takes one of the following values:
 
 * `y`, `yes`, `on`, `checks`, or no value: enable Control Flow Guard.
-* `nochecks`: emit Control Flow Guard metadata without runtime enforcement checks (this 
+* `nochecks`: emit Control Flow Guard metadata without runtime enforcement checks (this
 should only be used for testing purposes as it does not provide security enforcement).
 * `n`, `no`, `off`: do not enable Control Flow Guard (the default).
 
@@ -200,6 +200,18 @@ the following values:
 An example of when this flag might be useful is when trying to construct code coverage
 metrics.
 
+## link-self-contained
+
+On targets that support it this flag controls whether the linker will use libraries and objects
+shipped with Rust instead or those in the system.
+It takes one of the following values:
+
+* no value: rustc will use heuristic to disable self-contained mode if system has necessary tools.
+* `y`, `yes`, `on`: use only libraries/objects shipped with Rust.
+* `n`, `no`, or `off`: rely on the user or the linker to provide non-Rust libraries/objects.
+
+This allows overriding cases when detection fails or user wants to use shipped libraries.
+
 ## linker
 
 This flag controls which linker `rustc` invokes to link your code. It takes a