Skip to content

Commit 533951a

Browse files
committed
Use -nostdlibinc for non-Apple, non-X86_64 targets when using clang.
1 parent e943bfc commit 533951a

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

build.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const X86: &str = "x86";
4848
const X86_64: &str = "x86_64";
4949
const AARCH64: &str = "aarch64";
5050
const ARM: &str = "arm";
51-
const WASM32: &str = "wasm32";
5251

5352
#[rustfmt::skip]
5453
const RING_SRCS: &[(&[&str], &str)] = &[
@@ -300,8 +299,8 @@ fn ring_build_rs_main(c_root_dir: &Path, core_name_and_version: &str) {
300299
let out_dir = PathBuf::from(out_dir);
301300

302301
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
302+
let vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
303303
let os = env::var("CARGO_CFG_TARGET_OS").unwrap();
304-
let env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
305304

306305
let is_git = fs::metadata(c_root_dir.join(".git")).is_ok();
307306

@@ -316,8 +315,8 @@ fn ring_build_rs_main(c_root_dir: &Path, core_name_and_version: &str) {
316315

317316
let target = Target {
318317
arch,
318+
vendor,
319319
os,
320-
env,
321320
is_debug,
322321
force_warnings_into_errors,
323322
};
@@ -396,8 +395,8 @@ fn generate_sources_and_preassemble<'a>(
396395

397396
struct Target {
398397
arch: String,
398+
vendor: String,
399399
os: String,
400-
env: String,
401400

402401
/// Is this a debug build? This affects whether assertions might be enabled
403402
/// in the C code. For packaged builds, this should always be `false`.
@@ -576,14 +575,10 @@ fn configure_cc(c: &mut cc::Build, target: &Target, c_root_dir: &Path, include_d
576575
// Allow cross-compiling without a target sysroot for these targets.
577576
//
578577
// poly1305_vec.c requires <emmintrin.h> which requires <stdlib.h>.
579-
if (target.arch == WASM32)
580-
|| (target.os == "linux" && target.env == "musl" && target.arch != X86_64)
581-
{
582-
// TODO: Expand this to non-clang compilers in 0.17.0 if practical.
583-
if compiler.is_like_clang() {
584-
let _ = c.flag("-nostdlibinc");
585-
let _ = c.define("RING_CORE_NOSTDLIBINC", "1");
586-
}
578+
// TODO: Expand this to non-clang compilers in 0.17.0 if practical.
579+
if target.vendor != "apple" && target.arch != X86_64 && compiler.is_like_clang() {
580+
let _ = c.flag("-nostdlibinc");
581+
let _ = c.define("RING_CORE_NOSTDLIBINC", "1");
587582
}
588583

589584
if target.force_warnings_into_errors {

crypto/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static inline crypto_word_t constant_time_declassify_w(crypto_word_t v) {
374374

375375
// Endianness conversions.
376376

377-
#if defined(__GNUC__) && __GNUC__ >= 2
377+
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 2)
378378
static inline uint32_t CRYPTO_bswap4(uint32_t x) {
379379
return __builtin_bswap32(x);
380380
}

0 commit comments

Comments
 (0)