summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-04-30 19:52:13 +0000
committerbors <bors@rust-lang.org>2019-04-30 19:52:13 +0000
commit7c71bc3208031b1307573de45a3b3e18fa45787a (patch)
tree1f1e41b0a19c54a794d95435c77f352ca18ae1e4 /src/bootstrap
parent5b7baa53c91d7c33b925fc8aec553e3521548a07 (diff)
parent7c4cc01f7900f66be8bc939ddb4fb15636f598f1 (diff)
downloadrust-7c71bc3208031b1307573de45a3b3e18fa45787a.tar.gz
rust-7c71bc3208031b1307573de45a3b3e18fa45787a.zip
Auto merge of #60262 - michaelwoerister:pgo-preinlining-pass, r=alexcrichton
 PGO: Add a run-make test that makes sure that PGO profiling data is used by the compiler during optimizations.

From the tests comment section:
```
# This test makes sure that PGO profiling data leads to cold functions being
# marked as `cold` and hot functions with `inlinehint`.
# The test program contains an `if` were actual execution only ever takes the
# `else` branch. Accordingly, we expect the function that is never called to
# be marked as cold.
```

r? @alexcrichton
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/test.rs22
-rw-r--r--src/bootstrap/tool.rs51
2 files changed, 22 insertions, 51 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index a443b7b5863..38027aded9c 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -1231,6 +1231,28 @@ impl Step for Compiletest {
                 if let Some(ar) = builder.ar(target) {
                     cmd.arg("--ar").arg(ar);
                 }
+
+                // The llvm/bin directory contains many useful cross-platform
+                // tools. Pass the path to run-make tests so they can use them.
+                let llvm_bin_path = llvm_config.parent()
+                    .expect("Expected llvm-config to be contained in directory");
+                assert!(llvm_bin_path.is_dir());
+                cmd.arg("--llvm-bin-dir").arg(llvm_bin_path);
+
+                // If LLD is available, add it to the PATH
+                if builder.config.lld_enabled {
+                    let lld_install_root = builder.ensure(native::Lld {
+                        target: builder.config.build,
+                    });
+
+                    let lld_bin_path = lld_install_root.join("bin");
+
+                    let old_path = env::var_os("PATH").unwrap_or_default();
+                    let new_path = env::join_paths(std::iter::once(lld_bin_path)
+                        .chain(env::split_paths(&old_path)))
+                        .expect("Could not add LLD bin path to PATH");
+                    cmd.env("PATH", new_path);
+                }
             }
         }
 
diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
index 23775a91e4c..c23ddbdbc68 100644
--- a/src/bootstrap/tool.rs
+++ b/src/bootstrap/tool.rs
@@ -9,7 +9,6 @@ use crate::Compiler;
 use crate::builder::{Step, RunConfig, ShouldRun, Builder};
 use crate::util::{exe, add_lib_path};
 use crate::compile;
-use crate::native;
 use crate::channel::GitInfo;
 use crate::channel;
 use crate::cache::Interned;
@@ -698,56 +697,6 @@ impl<'a> Builder<'a> {
             }
         }
 
-        // Add the llvm/bin directory to PATH since it contains lots of
-        // useful, platform-independent tools
-        if tool.uses_llvm_tools() && !self.config.dry_run {
-            let mut additional_paths = vec![];
-
-            if let Some(llvm_bin_path) = self.llvm_bin_path() {
-                additional_paths.push(llvm_bin_path);
-            }
-
-            // If LLD is available, add that too.
-            if self.config.lld_enabled {
-                let lld_install_root = self.ensure(native::Lld {
-                    target: self.config.build,
-                });
-
-                let lld_bin_path = lld_install_root.join("bin");
-                additional_paths.push(lld_bin_path);
-            }
-
-            if host.contains("windows") {
-                // On Windows, PATH and the dynamic library path are the same,
-                // so we just add the LLVM bin path to lib_path
-                lib_paths.extend(additional_paths);
-            } else {
-                let old_path = env::var_os("PATH").unwrap_or_default();
-                let new_path = env::join_paths(additional_paths.into_iter()
-                        .chain(env::split_paths(&old_path)))
-                    .expect("Could not add LLVM bin path to PATH");
-                cmd.env("PATH", new_path);
-            }
-        }
-
         add_lib_path(lib_paths, cmd);
     }
-
-    fn llvm_bin_path(&self) -> Option<PathBuf> {
-        if self.config.llvm_enabled() {
-            let llvm_config = self.ensure(native::Llvm {
-                target: self.config.build,
-                emscripten: false,
-            });
-
-            // Add the llvm/bin directory to PATH since it contains lots of
-            // useful, platform-independent tools
-            let llvm_bin_path = llvm_config.parent()
-                .expect("Expected llvm-config to be contained in directory");
-            assert!(llvm_bin_path.is_dir());
-            Some(llvm_bin_path.to_path_buf())
-        } else {
-            None
-        }
-    }
 }