Merge pull request #506 from nicholasbishop/bishop-fix-stdlib-inc

This commit is contained in:
Amanieu d'Antras 2022-11-18 02:57:21 +00:00 committed by GitHub
commit 96bfaa2e09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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"),