summaryrefslogtreecommitdiffstats
path: root/vendor/compiler_builtins/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/compiler_builtins/build.rs')
-rw-r--r--vendor/compiler_builtins/build.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/vendor/compiler_builtins/build.rs b/vendor/compiler_builtins/build.rs
index 73952bb9f..3f5dbd3ab 100644
--- a/vendor/compiler_builtins/build.rs
+++ b/vendor/compiler_builtins/build.rs
@@ -98,7 +98,7 @@ mod c {
use std::collections::{BTreeMap, HashSet};
use std::env;
- use std::fs::File;
+ use std::fs::{self, File};
use std::io::Write;
use std::path::{Path, PathBuf};
@@ -190,6 +190,21 @@ mod c {
cfg.define("VISIBILITY_HIDDEN", None);
}
+ // int_util.c tries to include stdlib.h if `_WIN32` is defined,
+ // which it is when compiling UEFI targets with clang. This is
+ // at odds with compiling with `-ffreestanding`, as the header
+ // may be incompatible or not present. Create a minimal stub
+ // header to use instead.
+ if target_os == "uefi" {
+ let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
+ let include_dir = out_dir.join("include");
+ if !include_dir.exists() {
+ fs::create_dir(&include_dir).unwrap();
+ }
+ fs::write(include_dir.join("stdlib.h"), "#include <stddef.h>").unwrap();
+ cfg.flag(&format!("-I{}", include_dir.to_str().unwrap()));
+ }
+
let mut sources = Sources::new();
sources.extend(&[
("__absvdi2", "absvdi2.c"),
@@ -465,7 +480,8 @@ mod c {
}
// Remove the assembly implementations that won't compile for the target
- if llvm_target[0] == "thumbv6m" || llvm_target[0] == "thumbv8m.base" {
+ if llvm_target[0] == "thumbv6m" || llvm_target[0] == "thumbv8m.base" || target_os == "uefi"
+ {
let mut to_remove = Vec::new();
for (k, v) in sources.map.iter() {
if v.ends_with(".S") {