mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-13 18:51:05 +00:00
revive llvm builder utility (#154)
Pre-eliminary support for LLVM releases and resolc binary releases by streamlining the build process for all supported hosts platforms. - Introduce the revive-llvm-builder crate with the revive-llvm builder utilty. - Do not rely on the LLVM dependency in $PATH to decouple the system LLVM installation from the LLVM host dependency. - Fix the emscripten build by decoupling the host and native LLVM dependencies. Thus allowing a single LLVM emscripten release that can be used on any host platform. - An example Dockerfile building an alpine container with a fully statically linked resolc ELF binary. - Remove the Debian builder utilities and workflow.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# IDE
|
||||
/.idea/
|
||||
/.vscode/
|
||||
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "revive-build-utils"
|
||||
version.workspace = true
|
||||
license.workspace = true
|
||||
edition.workspace = true
|
||||
repository.workspace = true
|
||||
authors = [
|
||||
"Cyrill Leutwiler <cyrill@parity.io>",
|
||||
]
|
||||
description = "Shared build utilities of the revive compiler"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
@@ -0,0 +1,10 @@
|
||||
# revive: Compiler Common
|
||||
|
||||
## License
|
||||
|
||||
This library is distributed under the terms of either
|
||||
|
||||
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
|
||||
- MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
|
||||
|
||||
at your option.
|
||||
@@ -0,0 +1,48 @@
|
||||
//! The compiler build utilities library.
|
||||
|
||||
/// The revive LLVM host dependency directory prefix environment variable.
|
||||
pub const REVIVE_LLVM_HOST_PREFIX: &str = "LLVM_SYS_181_PREFIX";
|
||||
|
||||
/// The revive LLVM target dependency directory prefix environment variable.
|
||||
pub const REVIVE_LLVM_TARGET_PREFIX: &str = "REVIVE_LLVM_TARGET_PREFIX";
|
||||
|
||||
/// Constructs a path to the LLVM tool `name`.
|
||||
///
|
||||
/// Respects the [`REVIVE_LLVM_HOST_PREFIX`] environment variable.
|
||||
pub fn llvm_host_tool(name: &str) -> std::path::PathBuf {
|
||||
std::env::var_os(REVIVE_LLVM_HOST_PREFIX)
|
||||
.map(Into::<std::path::PathBuf>::into)
|
||||
.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"install LLVM using the revive-llvm builder and export {REVIVE_LLVM_HOST_PREFIX}",
|
||||
)
|
||||
})
|
||||
.join("bin")
|
||||
.join(name)
|
||||
}
|
||||
|
||||
/// Returns the LLVM lib dir.
|
||||
///
|
||||
/// Respects the [`REVIVE_LLVM_HOST_PREFIX`] environment variable.
|
||||
pub fn llvm_lib_dir() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(llvm_config("--libdir").trim())
|
||||
}
|
||||
|
||||
/// Returns the LLVM CXX compiler flags.
|
||||
///
|
||||
/// Respects the [`REVIVE_LLVM_HOST_PREFIX`] environment variable.
|
||||
pub fn llvm_cxx_flags() -> String {
|
||||
llvm_config("--cxxflags")
|
||||
}
|
||||
|
||||
/// Execute the `llvm-config` utility respecting the [`REVIVE_LLVM_HOST_PREFIX`] environment variable.
|
||||
fn llvm_config(arg: &str) -> String {
|
||||
let llvm_config = llvm_host_tool("llvm-config");
|
||||
let output = std::process::Command::new(&llvm_config)
|
||||
.arg(arg)
|
||||
.output()
|
||||
.unwrap_or_else(|error| panic!("`{} {arg}` failed: {error}", llvm_config.display()));
|
||||
|
||||
String::from_utf8(output.stdout)
|
||||
.unwrap_or_else(|_| panic!("output of `{} {arg}` should be utf8", llvm_config.display()))
|
||||
}
|
||||
Reference in New Issue
Block a user