Skip to content

Commit c95f5e3

Browse files
bootstrap: Don't add LLVM's bin directory to the PATH for tool invocations.
1 parent 29cf3f5 commit c95f5e3

File tree

5 files changed

+11
-62
lines changed

5 files changed

+11
-62
lines changed

src/bootstrap/tool.rs

-51
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::Compiler;
99
use crate::builder::{Step, RunConfig, ShouldRun, Builder};
1010
use crate::util::{exe, add_lib_path};
1111
use crate::compile;
12-
use crate::native;
1312
use crate::channel::GitInfo;
1413
use crate::channel;
1514
use crate::cache::Interned;
@@ -698,56 +697,6 @@ impl<'a> Builder<'a> {
698697
}
699698
}
700699

701-
// Add the llvm/bin directory to PATH since it contains lots of
702-
// useful, platform-independent tools
703-
if tool.uses_llvm_tools() && !self.config.dry_run {
704-
let mut additional_paths = vec![];
705-
706-
if let Some(llvm_bin_path) = self.llvm_bin_path() {
707-
additional_paths.push(llvm_bin_path);
708-
}
709-
710-
// If LLD is available, add that too.
711-
if self.config.lld_enabled {
712-
let lld_install_root = self.ensure(native::Lld {
713-
target: self.config.build,
714-
});
715-
716-
let lld_bin_path = lld_install_root.join("bin");
717-
additional_paths.push(lld_bin_path);
718-
}
719-
720-
if host.contains("windows") {
721-
// On Windows, PATH and the dynamic library path are the same,
722-
// so we just add the LLVM bin path to lib_path
723-
lib_paths.extend(additional_paths);
724-
} else {
725-
let old_path = env::var_os("PATH").unwrap_or_default();
726-
let new_path = env::join_paths(additional_paths.into_iter()
727-
.chain(env::split_paths(&old_path)))
728-
.expect("Could not add LLVM bin path to PATH");
729-
cmd.env("PATH", new_path);
730-
}
731-
}
732-
733700
add_lib_path(lib_paths, cmd);
734701
}
735-
736-
fn llvm_bin_path(&self) -> Option<PathBuf> {
737-
if self.config.llvm_enabled() {
738-
let llvm_config = self.ensure(native::Llvm {
739-
target: self.config.build,
740-
emscripten: false,
741-
});
742-
743-
// Add the llvm/bin directory to PATH since it contains lots of
744-
// useful, platform-independent tools
745-
let llvm_bin_path = llvm_config.parent()
746-
.expect("Expected llvm-config to be contained in directory");
747-
assert!(llvm_bin_path.is_dir());
748-
Some(llvm_bin_path.to_path_buf())
749-
} else {
750-
None
751-
}
752-
}
753702
}

src/test/run-make-fulldeps/cross-lang-lto-clang/Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ all: cpp-executable rust-executable
99

1010
cpp-executable:
1111
$(RUSTC) -Clinker-plugin-lto=on -o $(TMPDIR)/librustlib-xlto.a -Copt-level=2 -Ccodegen-units=1 ./rustlib.rs
12-
$(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) $(CLANG) -flto=thin -fuse-ld=lld -L $(TMPDIR) -lrustlib-xlto -o $(TMPDIR)/cmain ./cmain.c -O3
12+
$(CLANG) -flto=thin -fuse-ld=lld -L $(TMPDIR) -lrustlib-xlto -o $(TMPDIR)/cmain ./cmain.c -O3
1313
# Make sure we don't find a call instruction to the function we expect to
1414
# always be inlined.
15-
$(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -v -e "call.*rust_always_inlined"
15+
"$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -v -e "call.*rust_always_inlined"
1616
# As a sanity check, make sure we do find a call instruction to a
1717
# non-inlined function
18-
$(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -e "call.*rust_never_inlined"
18+
"$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -e "call.*rust_never_inlined"
1919

2020
rust-executable:
21-
$(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) $(CLANG) ./clib.c -flto=thin -c -o $(TMPDIR)/clib.o -O2
21+
$(CLANG) ./clib.c -flto=thin -c -o $(TMPDIR)/clib.o -O2
2222
(cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
2323
$(RUSTC) -Clinker-plugin-lto=on -L$(TMPDIR) -Copt-level=2 -Clinker=$(CLANG) -Clink-arg=-fuse-ld=lld ./main.rs -o $(TMPDIR)/rsmain
24-
$(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -e "call.*c_never_inlined"
25-
$(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -v -e "call.*c_always_inlined"
24+
"$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -e "call.*c_never_inlined"
25+
"$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -v -e "call.*c_always_inlined"

src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ all: staticlib.rs upstream.rs
1212

1313
# Check No LTO
1414
$(RUSTC) staticlib.rs -C linker-plugin-lto -Ccodegen-units=1 -L. -o $(TMPDIR)/staticlib.a
15-
(cd $(TMPDIR); $(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-ar x ./staticlib.a)
15+
(cd $(TMPDIR); "$(LLVM_BIN_DIR)"/llvm-ar x ./staticlib.a)
1616
# Make sure the upstream object file was included
1717
ls $(TMPDIR)/upstream.*.rcgu.o
1818

@@ -22,7 +22,7 @@ all: staticlib.rs upstream.rs
2222
# Check ThinLTO
2323
$(RUSTC) upstream.rs -C linker-plugin-lto -Ccodegen-units=1 -Clto=thin
2424
$(RUSTC) staticlib.rs -C linker-plugin-lto -Ccodegen-units=1 -Clto=thin -L. -o $(TMPDIR)/staticlib.a
25-
(cd $(TMPDIR); $(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-ar x ./staticlib.a)
25+
(cd $(TMPDIR); "$(LLVM_BIN_DIR)"/llvm-ar x ./staticlib.a)
2626
ls $(TMPDIR)/upstream.*.rcgu.o
2727

2828
else

src/test/run-make-fulldeps/cross-lang-lto/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ ifndef IS_WINDOWS
1010
# -Clinker-plugin-lto.
1111

1212
# this only succeeds for bitcode files
13-
ASSERT_IS_BITCODE_OBJ=($(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-bcanalyzer $(1))
14-
EXTRACT_OBJS=(cd $(TMPDIR); rm -f ./*.o; $(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-ar x $(1))
13+
ASSERT_IS_BITCODE_OBJ=("$(LLVM_BIN_DIR)"/llvm-bcanalyzer $(1))
14+
EXTRACT_OBJS=(cd $(TMPDIR); rm -f ./*.o; "$(LLVM_BIN_DIR)"/llvm-ar x $(1))
1515

1616
BUILD_LIB=$(RUSTC) lib.rs -Copt-level=2 -Clinker-plugin-lto -Ccodegen-units=1
1717
BUILD_EXE=$(RUSTC) main.rs -Copt-level=2 -Clinker-plugin-lto -Ccodegen-units=1 --emit=obj

src/test/run-make-fulldeps/pgo-use/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ all:
2929
# Run it in order to generate some profiling data
3030
$(call RUN,main some-argument) || exit 1
3131
# Postprocess the profiling data so it can be used by the compiler
32-
$(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-profdata merge \
32+
"$(LLVM_BIN_DIR)"/llvm-profdata merge \
3333
-o "$(TMPDIR)"/merged.profdata \
3434
"$(TMPDIR)"/default_*.profraw
3535
# Compile the test program again, making use of the profiling data

0 commit comments

Comments
 (0)