mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-30 09:27:56 +00:00
7f81f37e0c
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.
128 lines
4.6 KiB
Rust
128 lines
4.6 KiB
Rust
//! The revive LLVM amd64 `windows-gnu` builder.
|
|
|
|
use std::collections::HashSet;
|
|
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
use crate::build_type::BuildType;
|
|
use crate::ccache_variant::CcacheVariant;
|
|
use crate::llvm_path::LLVMPath;
|
|
use crate::llvm_project::LLVMProject;
|
|
use crate::platforms::Platform;
|
|
use crate::sanitizer::Sanitizer;
|
|
use crate::target_triple::TargetTriple;
|
|
|
|
/// The building sequence.
|
|
#[allow(clippy::too_many_arguments)]
|
|
pub fn build(
|
|
build_type: BuildType,
|
|
targets: HashSet<Platform>,
|
|
llvm_projects: HashSet<LLVMProject>,
|
|
enable_rtti: bool,
|
|
default_target: Option<TargetTriple>,
|
|
enable_tests: bool,
|
|
enable_coverage: bool,
|
|
extra_args: &[String],
|
|
ccache_variant: Option<CcacheVariant>,
|
|
enable_assertions: bool,
|
|
sanitizer: Option<Sanitizer>,
|
|
) -> anyhow::Result<()> {
|
|
crate::utils::check_presence("cmake")?;
|
|
crate::utils::check_presence("clang")?;
|
|
crate::utils::check_presence("clang++")?;
|
|
crate::utils::check_presence("lld")?;
|
|
crate::utils::check_presence("ninja")?;
|
|
|
|
let llvm_module_llvm =
|
|
LLVMPath::llvm_module_llvm().and_then(crate::utils::path_windows_to_unix)?;
|
|
let llvm_build_final =
|
|
LLVMPath::llvm_build_final().and_then(crate::utils::path_windows_to_unix)?;
|
|
let llvm_target_final =
|
|
LLVMPath::llvm_target_final().and_then(crate::utils::path_windows_to_unix)?;
|
|
|
|
crate::utils::command(
|
|
Command::new("cmake")
|
|
.args([
|
|
"-S",
|
|
llvm_module_llvm.to_string_lossy().as_ref(),
|
|
"-B",
|
|
llvm_build_final.to_string_lossy().as_ref(),
|
|
"-G",
|
|
"Ninja",
|
|
format!(
|
|
"-DCMAKE_INSTALL_PREFIX='{}'",
|
|
llvm_target_final.to_string_lossy().as_ref(),
|
|
)
|
|
.as_str(),
|
|
format!("-DCMAKE_BUILD_TYPE='{build_type}'").as_str(),
|
|
"-DCMAKE_C_COMPILER='clang'",
|
|
"-DCMAKE_CXX_COMPILER='clang++'",
|
|
format!(
|
|
"-DLLVM_TARGETS_TO_BUILD='{}'",
|
|
targets
|
|
.into_iter()
|
|
.map(|platform| platform.to_string())
|
|
.collect::<Vec<String>>()
|
|
.join(";")
|
|
)
|
|
.as_str(),
|
|
format!(
|
|
"-DLLVM_ENABLE_PROJECTS='{}'",
|
|
llvm_projects
|
|
.into_iter()
|
|
.map(|project| project.to_string())
|
|
.collect::<Vec<String>>()
|
|
.join(";")
|
|
)
|
|
.as_str(),
|
|
"-DLLVM_USE_LINKER='lld'",
|
|
])
|
|
.args(crate::platforms::shared::shared_build_opts_default_target(
|
|
default_target,
|
|
))
|
|
.args(crate::platforms::shared::shared_build_opts_tests(
|
|
enable_tests,
|
|
))
|
|
.args(crate::platforms::shared::shared_build_opts_coverage(
|
|
enable_coverage,
|
|
))
|
|
.args(crate::platforms::shared::SHARED_BUILD_OPTS)
|
|
.args(crate::platforms::shared::SHARED_BUILD_OPTS_NOT_MUSL)
|
|
.args(crate::platforms::shared::shared_build_opts_werror(
|
|
crate::target_env::TargetEnv::GNU,
|
|
))
|
|
.args(extra_args)
|
|
.args(crate::platforms::shared::shared_build_opts_ccache(
|
|
ccache_variant,
|
|
))
|
|
.args(crate::platforms::shared::shared_build_opts_assertions(
|
|
enable_assertions,
|
|
))
|
|
.args(crate::platforms::shared::shared_build_opts_rtti(
|
|
enable_rtti,
|
|
))
|
|
.args(crate::platforms::shared::shared_build_opts_sanitizers(
|
|
sanitizer,
|
|
)),
|
|
"LLVM building cmake",
|
|
)?;
|
|
|
|
crate::utils::ninja(llvm_build_final.as_ref())?;
|
|
|
|
let libstdcpp_source_path = match std::env::var("LIBSTDCPP_SOURCE_PATH") {
|
|
Ok(libstdcpp_source_path) => PathBuf::from(libstdcpp_source_path),
|
|
Err(error) => anyhow::bail!(
|
|
"The `LIBSTDCPP_SOURCE_PATH` must be set to the path to the libstdc++.a static library: {}", error
|
|
),
|
|
};
|
|
let mut libstdcpp_destination_path = llvm_target_final;
|
|
libstdcpp_destination_path.push("./lib/libstdc++.a");
|
|
fs_extra::file::copy(
|
|
crate::utils::path_windows_to_unix(libstdcpp_source_path)?,
|
|
crate::utils::path_windows_to_unix(libstdcpp_destination_path)?,
|
|
&fs_extra::file::CopyOptions::default(),
|
|
)?;
|
|
|
|
Ok(())
|
|
}
|