-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
aarch64-pc-windows-gnullvm
and x86_64-pc-windows-gnullvm
targ…
…ets (#1883)
- Loading branch information
Showing
19 changed files
with
239 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "windows_aarch64_gnullvm" | ||
version = "0.39.0" | ||
authors = ["Microsoft"] | ||
edition = "2018" | ||
license = "MIT OR Apache-2.0" | ||
description = "Code gen support for the windows crate" | ||
repository = "https://github.com/microsoft/windows-rs" | ||
|
||
[package.metadata.docs.rs] | ||
default-target = "x86_64-pc-windows-msvc" | ||
targets = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
fn main() { | ||
let target = std::env::var("TARGET").unwrap(); | ||
if target != "aarch64-pc-windows-gnullvm" { | ||
return; | ||
} | ||
|
||
let dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); | ||
|
||
println!("cargo:rustc-link-search=native={}", std::path::Path::new(&dir).join("lib").display()); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#![no_std] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "windows_x86_64_gnullvm" | ||
version = "0.39.0" | ||
authors = ["Microsoft"] | ||
edition = "2018" | ||
license = "MIT OR Apache-2.0" | ||
description = "Code gen support for the windows crate" | ||
repository = "https://github.com/microsoft/windows-rs" | ||
|
||
[package.metadata.docs.rs] | ||
default-target = "x86_64-pc-windows-msvc" | ||
targets = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
fn main() { | ||
let target = std::env::var("TARGET").unwrap(); | ||
if target != "x86_64-pc-windows-gnullvm" { | ||
return; | ||
} | ||
|
||
let dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); | ||
|
||
println!("cargo:rustc-link-search=native={}", std::path::Path::new(&dir).join("lib").display()); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#![no_std] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "tool_gnullvm" | ||
version = "0.0.0" | ||
edition = "2018" | ||
publish = false | ||
|
||
[dependencies] | ||
lib = { package = "tool_lib", path = "../lib" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The Windows umbrella lib (targeting mingw-w64 LLVM tooling) is generated using the following steps: | ||
|
||
0. Ensure MSYS2 MinGW environment is installed (https://www.mingw-w64.org/downloads/) | ||
1. Execute: `C:\msys64\clang64.exe` | ||
2. Execute: `pacman -Syuu --noconfirm` (repeat until no further updates available) | ||
3. Execute `pacman --needed -S mingw-w64-clang-x86_64-toolchain` | ||
4. Navigate to crate root | ||
5. Execute: `PATH=$(cygpath -u $USERPROFILE)/.cargo/bin:$PATH cargo +nightly run -p tool_gnullvm --target x86_64-pc-windows-gnullvm -Z build-std -- all` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
use std::collections::BTreeMap; | ||
use std::io::prelude::*; | ||
|
||
fn main() { | ||
let mut cmd = std::process::Command::new("where"); | ||
cmd.arg("llvm-dlltool.exe"); | ||
|
||
let output = cmd.output().unwrap(); | ||
|
||
if !output.status.success() { | ||
println!("llvm-dlltool.exe not found"); | ||
return; | ||
} | ||
|
||
let target = std::env::args().collect::<Vec<_>>(); | ||
let mut platform_and_target = vec![]; | ||
if target.iter().any(|x| x == "x86_64") || target.iter().any(|x| x == "all") { | ||
platform_and_target.push(("x86_64_gnullvm", "i386:x86-64")); | ||
} | ||
if target.iter().any(|x| x == "aarch64") || target.iter().any(|x| x == "all") { | ||
platform_and_target.push(("aarch64_gnullvm", "arm64")); | ||
} | ||
if platform_and_target.is_empty() { | ||
println!("Please specify at least one architecture or use 'all' argument"); | ||
return; | ||
}; | ||
|
||
let libraries = lib::libraries(); | ||
|
||
for (platform, dlltool_target) in platform_and_target { | ||
let output = std::path::PathBuf::from(format!("crates/targets/{}/lib", platform)); | ||
let _ = std::fs::remove_dir_all(&output); | ||
std::fs::create_dir_all(&output).unwrap(); | ||
|
||
for (library, functions) in &libraries { | ||
build_library(&output, library, functions, dlltool_target); | ||
} | ||
|
||
build_mri(&output, &libraries); | ||
|
||
for library in libraries.keys() { | ||
std::fs::remove_file(output.join(format!("lib{}.a", library))).unwrap(); | ||
} | ||
} | ||
} | ||
|
||
fn build_library(output: &std::path::Path, library: &str, functions: &BTreeMap<String, usize>, dlltool_target: &str) { | ||
println!("{}", library); | ||
|
||
// Note that we don't use set_extension as it confuses PathBuf when the library name includes a period. | ||
let def_path = output.join(format!("{}.def", library)); | ||
let mut def = std::fs::File::create(&def_path).unwrap(); | ||
|
||
def.write_all( | ||
format!( | ||
r#" | ||
LIBRARY {} | ||
EXPORTS | ||
"#, | ||
library | ||
) | ||
.as_bytes(), | ||
) | ||
.unwrap(); | ||
|
||
for function in functions.keys() { | ||
def.write_all(format!("{}\n", function).as_bytes()).unwrap(); | ||
} | ||
|
||
drop(def); | ||
|
||
let mut cmd = std::process::Command::new("llvm-dlltool"); | ||
cmd.current_dir(&output); | ||
|
||
cmd.arg("-m"); | ||
cmd.arg(dlltool_target); | ||
cmd.arg("-d"); | ||
cmd.arg(format!("{}.def", library)); | ||
cmd.arg("-l"); | ||
cmd.arg(format!("lib{}.a", library)); | ||
cmd.output().unwrap(); | ||
|
||
std::fs::remove_file(output.join(format!("{}.def", library))).unwrap(); | ||
} | ||
|
||
fn build_mri(output: &std::path::Path, libraries: &BTreeMap<String, BTreeMap<String, usize>>) { | ||
let mri_path = output.join("unified.mri"); | ||
let mut mri = std::fs::File::create(&mri_path).unwrap(); | ||
println!("Generating {}", mri_path.to_string_lossy()); | ||
|
||
mri.write_all(b"CREATE libwindows.a\n").unwrap(); | ||
|
||
for library in libraries.keys() { | ||
mri.write_all(format!("ADDLIB lib{}.a\n", library).as_bytes()).unwrap(); | ||
} | ||
|
||
mri.write_all(b"SAVE\nEND\n").unwrap(); | ||
|
||
let mut cmd = std::process::Command::new("llvm-ar"); | ||
cmd.current_dir(&output); | ||
cmd.arg("-M"); | ||
cmd.stdin(std::fs::File::open(&mri_path).unwrap()); | ||
cmd.output().unwrap(); | ||
|
||
std::fs::remove_file(&mri_path).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters