Skip to content

Commit ee1ce9d

Browse files
authored
Rollup merge of rust-lang#47846 - roblabla:bugfix-ocaml, r=kennytm
Work around LLVM OCAML binding installation failure Hello, I have OCaml installed on my machine, and compiling rust systematically fails when LLVM attempts installing the OCaml bindings in `/usr/lib/ocaml`, which is write-protected. Here are the logs: https://gist.github.com/roblabla/3f147914c5df627c9d97ab311ba133ad Some digging around the issue reveals: - The code that finds if OCaml is installed, and sets the bindings to be compiled/installed: https://github.com/llvm-mirror/llvm/blob/b24a45d2e9f4fc10c3f9e16172104910b38637f2/cmake/config-ix.cmake#L612 - https://github.com/llvm-mirror/llvm/blob/b24a45d2e9f4fc10c3f9e16172104910b38637f2/bindings/ocaml/llvm/CMakeLists.txt Some code that does the installation. The problem seems to be that `LLVM_OCAML_INSTALL_PATH` is set to `OCAML_STDLIB_PATH` by default, which is in `/usr/lib/ocaml`, instead of the prefix. This PR "fixes" the issue by setting `LLVM_OCAML_INSTALL_PATH` to `usr/lib/ocaml`. I haven't found a way to make LLVM not build OCaml, which would probably be a superior fix.
2 parents b54f27b + 3c01dea commit ee1ce9d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/bootstrap/native.rs

+8
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ impl Step for Llvm {
159159
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
160160
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);
161161

162+
// By default, LLVM will automatically find OCaml and, if it finds it,
163+
// install the LLVM bindings in LLVM_OCAML_INSTALL_PATH, which defaults
164+
// to /usr/bin/ocaml.
165+
// This causes problem for non-root builds of Rust. Side-step the issue
166+
// by setting LLVM_OCAML_INSTALL_PATH to a relative path, so it installs
167+
// in the prefix.
168+
cfg.define("LLVM_OCAML_INSTALL_PATH",
169+
env::var_os("LLVM_OCAML_INSTALL_PATH").unwrap_or_else(|| "usr/lib/ocaml".into()));
162170

163171
// This setting makes the LLVM tools link to the dynamic LLVM library,
164172
// which saves both memory during parallel links and overall disk space

0 commit comments

Comments
 (0)