diff --git a/config.toml.example b/config.toml.example index 3159c19528a..66eaab236f7 100644 --- a/config.toml.example +++ b/config.toml.example @@ -322,6 +322,7 @@ # Flag indicating whether codegen tests will be run or not. If you get an error # saying that the FileCheck executable is missing, you may want to disable this. +# Also see the target's llvm-filecheck option. #codegen-tests = true # Flag indicating whether git info will be retrieved from .git automatically. @@ -416,6 +417,10 @@ # target. #llvm-config = "../path/to/llvm/root/bin/llvm-config" +# Normally the build system can find LLVM's FileCheck utility, but if +# not, you can specify an explicit file name for it. +#llvm-filecheck = "/path/to/FileCheck" + # Path to the custom jemalloc static library to link into the standard library # by default. This is only used if jemalloc is still enabled above #jemalloc = "/path/to/jemalloc/libjemalloc_pic.a" diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index cc6d76c76f2..3a4bc526d03 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -162,6 +162,8 @@ pub struct Config { pub struct Target { /// Some(path to llvm-config) if using an external LLVM. pub llvm_config: Option, + /// Some(path to FileCheck) if one was specified. + pub llvm_filecheck: Option, pub jemalloc: Option, pub cc: Option, pub cxx: Option, @@ -330,6 +332,7 @@ struct Rust { #[serde(deny_unknown_fields, rename_all = "kebab-case")] struct TomlTarget { llvm_config: Option, + llvm_filecheck: Option, jemalloc: Option, cc: Option, cxx: Option, @@ -583,6 +586,9 @@ impl Config { if let Some(ref s) = cfg.llvm_config { target.llvm_config = Some(config.src.join(s)); } + if let Some(ref s) = cfg.llvm_filecheck { + target.llvm_filecheck = Some(config.src.join(s)); + } if let Some(ref s) = cfg.jemalloc { target.jemalloc = Some(config.src.join(s)); } diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index cf7f78eeba0..75831dbe262 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -95,6 +95,8 @@ v("docdir", "install.docdir", "install documentation in PATH") v("bindir", "install.bindir", "install binaries") v("llvm-root", None, "set LLVM root") +v("llvm-config", None, "set path to llvm-config") +v("llvm-filecheck", None, "set path to LLVM's FileCheck utility") v("python", "build.python", "set path to python") v("jemalloc-root", None, "set directory where libjemalloc_pic.a is located") v("android-cross-path", "target.arm-linux-androideabi.android-ndk", @@ -323,6 +325,10 @@ for key in known_args: set('build.cargo', value + '/bin/cargo') elif option.name == 'llvm-root': set('target.{}.llvm-config'.format(build()), value + '/bin/llvm-config') + elif option.name == 'llvm-config': + set('target.{}.llvm-config'.format(build()), value) + elif option.name == 'llvm-filecheck': + set('target.{}.llvm-filecheck'.format(build()), value) elif option.name == 'jemalloc-root': set('target.{}.jemalloc'.format(build()), value + '/libjemalloc_pic.a') elif option.name == 'tools': diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 6b88516bacd..75c18cd2dd4 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -641,9 +641,28 @@ impl Build { /// Returns the path to `FileCheck` binary for the specified target fn llvm_filecheck(&self, target: Interned) -> PathBuf { let target_config = self.config.target_config.get(&target); - if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { + if let Some(s) = target_config.and_then(|c| c.llvm_filecheck.as_ref()) { + s.to_path_buf() + } else if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { let llvm_bindir = output(Command::new(s).arg("--bindir")); - Path::new(llvm_bindir.trim()).join(exe("FileCheck", &*target)) + let filecheck = Path::new(llvm_bindir.trim()).join(exe("FileCheck", &*target)); + if filecheck.exists() { + filecheck + } else { + // On Fedora the system LLVM installs FileCheck in the + // llvm subdirectory of the libdir. + let llvm_libdir = output(Command::new(s).arg("--libdir")); + let lib_filecheck = Path::new(llvm_libdir.trim()) + .join("llvm").join(exe("FileCheck", &*target)); + if lib_filecheck.exists() { + lib_filecheck + } else { + // Return the most normal file name, even though + // it doesn't exist, so that any error message + // refers to that. + filecheck + } + } } else { let base = self.llvm_out(self.config.build).join("build"); let base = if !self.config.ninja && self.config.build.contains("msvc") {