diff --git a/build.rs b/build.rs index 2851fafdb8..9304bf12c4 100644 --- a/build.rs +++ b/build.rs @@ -284,6 +284,7 @@ const HURD: &str = "hurd"; const ILLUMOS: &str = "illumos"; const LINUX: &str = "linux"; const NETBSD: &str = "netbsd"; +const NONE: &str = "none"; const NTO: &str = "nto"; const OPENBSD: &str = "openbsd"; const REDOX: &str = "redox"; @@ -605,6 +606,12 @@ fn configure_cc(c: &mut cc::Build, target: &Target, c_root_dir: &Path, include_d let _ = c.flag(f); } + if target.os == NONE { + let _ = c.flag("-ffreestanding"); + let _ = c.flag("-nostdlib"); + let _ = c.define("RING_CORE_NOSTDLIBINC", "1"); + } + if APPLE_ABI.contains(&target.os.as_str()) { // ``-gfull`` is required for Darwin's |-dead_strip|. let _ = c.flag("-gfull"); diff --git a/include/ring-core/target.h b/include/ring-core/target.h index fe40db7722..10ff27a4bc 100644 --- a/include/ring-core/target.h +++ b/include/ring-core/target.h @@ -49,6 +49,9 @@ // Versions of GCC before 10.0 didn't define `__ILP32__` for all 32-bit targets. #elif defined(__MIPSEL__) || defined(__MIPSEB__) || defined(__PPC__) || defined(__powerpc__) || defined(__csky__) || defined(__XTENSA__) #define OPENSSL_32_BIT +#elif defined(__riscv) && __riscv_xlen == 32 +#define OPENSSL_32_BIT +#define OPENSSL_RISCV32 #else #error "Unknown target CPU" #endif