Build LLVM for Windows (#248)

This PR changes the CI build scripts to also build LLVM for windows.
**It doesn't build `revive` itself for windows**. This will come in a
follow up. But once we have a LLVM binary release the turn around time
will be much quicker for experimenting with the revive windows build.

I manually uploaded the release those changes produce
[here](https://github.com/paritytech/revive-alex-workflowtest/releases/tag/llvm-18.1.8-revive.22f3ceb).
This enables this PR's CI to find the proper release. This is necessary
because I am also making changes to the folder structure and artifact
naming that the other CI jobs are depending on.

Releases generated from this branch can be inspected here:
https://github.com/paritytech/revive-alex-workflowtest/releases/tag/v0.1.0-dev.12

Summary of changes:
- Change `llvm-builder` to use MSVC toolchain on windows
- Fix `llvm-builder` to work with `.exe` files
- Unify the llvm release jobs into a single one. This removed a lot of
copy pasted code and also speeds up the build by giving each their own
runner.
- Use the LLVM target triple to name the binary releases instead of an
ad-hoc naming convention
- Remove the nested folder hierarchy inside the llvm release. Its just
now a single folder `llvm-<target>` that contains the toolchain.
- Give jobs and workflows consistent names
- Replace all runners bei their `*-latest` counterpart
- Only use `parity-large` to build llvm now. All other jobs use github
runners
This commit is contained in:
Alexander Theißen
2025-02-28 15:06:03 +01:00
committed by GitHub
parent 93788e72e9
commit 2fb8beee62
16 changed files with 340 additions and 446 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ pub mod wasm32_emscripten;
pub mod x86_64_linux_gnu;
pub mod x86_64_linux_musl;
pub mod x86_64_macos;
pub mod x86_64_windows_gnu;
pub mod x86_64_windows_msvc;
use std::str::FromStr;
+3 -1
View File
@@ -8,7 +8,7 @@ use std::path::Path;
use std::process::Command;
/// The build options shared by all platforms.
pub const SHARED_BUILD_OPTS: [&str; 19] = [
pub const SHARED_BUILD_OPTS: [&str; 21] = [
"-DPACKAGE_VENDOR='Parity Technologies'",
"-DCMAKE_BUILD_WITH_INSTALL_RPATH=1",
"-DLLVM_BUILD_DOCS='Off'",
@@ -28,6 +28,8 @@ pub const SHARED_BUILD_OPTS: [&str; 19] = [
"-DCMAKE_EXPORT_COMPILE_COMMANDS='On'",
"-DPython3_FIND_REGISTRY='LAST'", // Use Python version from $PATH, not from registry
"-DBUG_REPORT_URL='https://github.com/paritytech/contract-issues/issues/'",
"-DCLANG_ENABLE_ARCMT='Off'",
"-DCLANG_ENABLE_STATIC_ANALYZER='Off'",
];
/// The build options shared by all platforms except MUSL.
@@ -1,7 +1,6 @@
//! The revive LLVM amd64 `windows-gnu` builder.
use std::collections::HashSet;
use std::path::PathBuf;
use std::process::Command;
use crate::build_type::BuildType;
@@ -28,10 +27,6 @@ pub fn build(
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)?;
@@ -48,15 +43,12 @@ pub fn build(
"-B",
llvm_build_final.to_string_lossy().as_ref(),
"-G",
"Ninja",
"Visual Studio 17 2022",
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
@@ -75,7 +67,7 @@ pub fn build(
.join(";")
)
.as_str(),
"-DLLVM_USE_LINKER='lld'",
"-DLLVM_BUILD_LLVM_C_DYLIB=Off",
])
.args(crate::platforms::shared::shared_build_opts_default_target(
default_target,
@@ -107,20 +99,16 @@ pub fn build(
"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(),
crate::utils::command(
Command::new("cmake").args([
"--build",
llvm_build_final.to_string_lossy().as_ref(),
"--target",
"install",
"--config",
build_type.to_string().as_str(),
]),
"Building with msbuild",
)?;
Ok(())