Skip to content

Commit

Permalink
[stdlib] Use the single-header Glibc modulemap.
Browse files Browse the repository at this point in the history
This migrates OpenBSD to use the single-header Glibc modulemap proposed
and implemented in #32404, and necessitates introducing some missing
headers for building Foundation added in #38341.

Additionally, incorporate nullability annotations in SwiftShims per
  • Loading branch information
3405691582 committed Feb 11, 2022
1 parent a7c698c commit 600d500
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 336 deletions.
6 changes: 1 addition & 5 deletions stdlib/public/Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,7 @@ foreach(sdk ${SWIFT_SDKS})
set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}")
set(module_dir_static "${SWIFTSTATICLIB_DIR}/${arch_subdir}")

if(${sdk} STREQUAL OPENBSD)
set(glibc_modulemap_source "libc-openbsd.modulemap.gyb")
else()
set(glibc_modulemap_source "glibc.modulemap.gyb")
endif()
set(glibc_modulemap_source "glibc.modulemap.gyb")
set(glibc_modulemap_out "${module_dir}/glibc.modulemap")
set(glibc_modulemap_out_static "${module_dir_static}/glibc.modulemap")

Expand Down
2 changes: 2 additions & 0 deletions stdlib/public/Platform/SwiftGlibc.h.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ headers = [
'string.h',
'tgmath.h',
'time.h',
'util.h',
'utmp.h',

# POSIX
Expand Down Expand Up @@ -69,6 +70,7 @@ headers = [
'sys/ioctl.h',
'sys/ipc.h',
'sys/mman.h',
'sys/mount.h',
'sys/msg.h',
'sys/resource.h',
'sys/select.h',
Expand Down
8 changes: 5 additions & 3 deletions stdlib/public/Platform/glibc.modulemap.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@
/// It's not named just Glibc so that it doesn't conflict in the event of a
/// future official glibc modulemap.
module SwiftGlibc [system] {
% if CMAKE_SDK in ["LINUX", "ANDROID"]:
% if CMAKE_SDK in ["LINUX", "ANDROID", "OPENBSD"]:
link "m"
% end
% if CMAKE_SDK in ["LINUX", "FREEBSD", "CYGWIN"]:
% if CMAKE_SDK in ["LINUX", "FREEBSD", "OPENBSD", "CYGWIN"]:
link "pthread"
// FIXME: util contains rarely used functions and not usually needed. Unfortunately
// link directive doesn't work in the submodule yet.
% if CMAKE_SDK != "OPENBSD":
link "util"
% end
% end

% if CMAKE_SDK != "FREEBSD" and CMAKE_SDK != "HAIKU":
% if CMAKE_SDK not in ["FREEBSD", "OPENBSD", "HAIKU"]:
link "dl"
% end

Expand Down
327 changes: 0 additions & 327 deletions stdlib/public/Platform/libc-openbsd.modulemap.gyb

This file was deleted.

2 changes: 1 addition & 1 deletion stdlib/public/SwiftShims/LibcShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static inline __swift_size_t _swift_stdlib_strlen_unsigned(const unsigned char *
SWIFT_READONLY
static inline int _swift_stdlib_memcmp(const void *s1, const void *s2,
__swift_size_t n) {
#if defined(__APPLE__) || defined(__ANDROID__)
#if defined(__APPLE__) || defined(__ANDROID__) || defined(__OpenBSD__)
extern int memcmp(const void * _Nullable, const void * _Nullable, __swift_size_t);
#else
extern int memcmp(const void *, const void *, __swift_size_t);
Expand Down

0 comments on commit 600d500

Please sign in to comment.