Skip to content

Commit 3f5f110

Browse files
Fix Darwin builds for non-standard environments (e.g. Nix) (#941)
* Fix Darwin builds for non-standard environments (e.g. Nix) * Conditionally add _DARWIN_C_SOURCE define * Also for darwin OS --------- Co-authored-by: Justin Smith <justsmth@amazon.com> Co-authored-by: Justin W Smith <103147162+justsmth@users.noreply.github.com>
1 parent 7625b53 commit 3f5f110

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

aws-lc-sys/builder/cc_builder.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ impl CcBuilder {
222222
}
223223
}
224224

225+
if target_os() == "macos" || target_os() == "darwin" {
226+
// Certain MacOS system headers are guarded by _POSIX_C_SOURCE and _DARWIN_C_SOURCE
227+
build_options.push(BuildOption::define("_DARWIN_C_SOURCE", "1"));
228+
}
229+
225230
let opt_level = cargo_env("OPT_LEVEL");
226231
match opt_level.as_str() {
227232
"0" | "1" | "2" => {
@@ -403,6 +408,10 @@ impl CcBuilder {
403408
};
404409

405410
je_builder.define("AWSLC", "1");
411+
if target_os() == "macos" || target_os() == "darwin" {
412+
// Certain MacOS system headers are guarded by _POSIX_C_SOURCE and _DARWIN_C_SOURCE
413+
je_builder.define("_DARWIN_C_SOURCE", "1");
414+
}
406415
je_builder.pic(true);
407416
if target_os() == "windows" && compiler.is_like_msvc() {
408417
je_builder.flag("/Od").flag("/W4").flag("/DYNAMICBASE");

0 commit comments

Comments
 (0)