authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-11-30 23:01:50+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-05 14:52:48+01:00
log9f1688653653400b7de3d91cc22dc5036593425a
treea87daadcb5a68b24eed002f1e990943c9da34ac0
parent2c42b85529b0f18ac789c2b5c695d1cedeb9ccde
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

compiler: define ___OpenBSD and OpenBSDX_Y when targeting openbsd libc


1 files changed, 15 insertions(+), 0 deletions(-)

src/Compilation.zig+15
......@@ -6978,6 +6978,21 @@ fn addCommonCCArgs(
69786978 // would be inconsistent with header declarations.
69796979 (min_ver.major * 100_000_000) + (min_ver.minor * 1_000_000),
69806980 }));
6981 } else if (target.isOpenBSDLibC()) {
6982 const min_ver = target.os.version_range.semver.min;
6983 // The macro in sys/param.h doesn't have the leading underscores, but we don't want to pollute the
6984 // global namespace in all compilation units. So we use leading underscores and modify sys/param.h
6985 // to just alias this one.
6986 try argv.append(try std.fmt.allocPrint(arena, "-D___OpenBSD={d}", .{
6987 // Brilliantly, OpenBSD defines this macro to the year and month of the release, so we need to
6988 // maintain a manual mapping here whenever we update the headers.
6989 202510,
6990 }));
6991 // We can't avoid pollution for this one...
6992 try argv.append(try std.fmt.allocPrint(arena, "-DOpenBSD{d}_{d}", .{
6993 min_ver.major,
6994 min_ver.minor,
6995 }));
69816996 }
69826997 }
69836998