From a6b0e926fd3b5ceceac30220ee9303d5fa279be3 Mon Sep 17 00:00:00 2001 From: 3405691582 Date: Sun, 29 Dec 2019 22:56:03 -0500 Subject: [PATCH] [stdlib] Both FreeBSD and OpenBSD use environ. However, when building Glibc with assertions enabled, LLVM asserts in CodeGenModule::EmitGlobal with "Cannot emit local var decl as global". This assert is _probably_ wrong in LLVM because the local extern reference isn't being handled properly and needs to be addressed there. We could move the declaration to global scope, but that is not ideal because it makes the pointer declaration visible to Swift. OpenBSD needs to implement _swift_stdlib_getEnviron regardless, so let's do so. --- stdlib/public/SwiftShims/LibcOverlayShims.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/SwiftShims/LibcOverlayShims.h b/stdlib/public/SwiftShims/LibcOverlayShims.h index b4c2ba1d0a002..6395656355330 100644 --- a/stdlib/public/SwiftShims/LibcOverlayShims.h +++ b/stdlib/public/SwiftShims/LibcOverlayShims.h @@ -52,7 +52,7 @@ static inline int _swift_stdlib_fcntlPtr(int fd, int cmd, void* ptr) { #endif // Environment -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) static inline char * _Nullable * _Null_unspecified _swift_stdlib_getEnviron() { extern char **environ; return environ;