Skip to content

Commit a6b0e92

Browse files
committed
[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.
1 parent 2d250bb commit a6b0e92

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

stdlib/public/SwiftShims/LibcOverlayShims.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static inline int _swift_stdlib_fcntlPtr(int fd, int cmd, void* ptr) {
5252
#endif
5353

5454
// Environment
55-
#if defined(__FreeBSD__)
55+
#if defined(__FreeBSD__) || defined(__OpenBSD__)
5656
static inline char * _Nullable * _Null_unspecified _swift_stdlib_getEnviron() {
5757
extern char **environ;
5858
return environ;

0 commit comments

Comments
 (0)