Skip to content

[stdlib] Get rid of the single bridging header for ELF platforms like linux #66665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions stdlib/public/Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,33 +229,21 @@ foreach(sdk ${SWIFT_SDKS})

list(APPEND glibc_modulemap_target_list ${glibc_modulemap_target})

set(glibc_header_out "${module_dir}/SwiftGlibc.h")
set(glibc_header_out_static "${module_dir_static}/SwiftGlibc.h")
handle_gyb_source_single(glibc_header_target
SOURCE "SwiftGlibc.h.gyb"
OUTPUT "${glibc_header_out}"
FLAGS "-DCMAKE_SDK=${sdk}")
list(APPEND glibc_modulemap_target_list ${glibc_header_target})

if(SWIFT_BUILD_STATIC_STDLIB)
add_custom_command_target(
copy_glibc_modulemap_header_static
copy_glibc_modulemap_static
COMMAND
"${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir_static}
COMMAND
"${CMAKE_COMMAND}" "-E" "copy"
${glibc_modulemap_out} ${glibc_modulemap_out_static}
COMMAND
"${CMAKE_COMMAND}" "-E" "copy"
${glibc_header_out} ${glibc_header_out_static}
OUTPUT ${glibc_modulemap_out_static} ${glibc_header_out_static}
OUTPUT ${glibc_modulemap_out_static}
DEPENDS
"${glibc_modulemap_target}"
"${glibc_header_target}"
COMMENT "Copying Glibc modulemap and header to static resources")
COMMENT "Copying Glibc modulemap to static resources")

list(APPEND glibc_modulemap_target_list
${copy_glibc_modulemap_header_static})
${copy_glibc_modulemap_static})
endif()

# If this SDK is a target for a non-native host, except if it's for Android
Expand Down
108 changes: 0 additions & 108 deletions stdlib/public/Platform/SwiftGlibc.h.gyb

This file was deleted.

109 changes: 108 additions & 1 deletion stdlib/public/Platform/glibc.modulemap.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,114 @@ module SwiftGlibc [system] {
link "execinfo"
% end

header "SwiftGlibc.h"
% if CMAKE_SDK not in ["ANDROID"]:
header "stdc-predef.h"
header "features.h"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these headers were removed for Android because they don't exist in Bionic, except for features.h, which is only in Bionic for glibc compatibility and is unnecessary plus it causes build issues in C++ Interop.

% end

// C standard library
header "complex.h"
header "ctype.h"
header "errno.h"
header "fenv.h"
header "inttypes.h"
% if CMAKE_SDK not in ["LINUX", "ANDROID"]:
header "libutil.h"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked all these headers in glibc too, and both Bionic and glibc don't have this. I only see a bsd/libutil.h from the libbsd-dev Ubuntu package, which I don't think the compiler finds.

If this header is wanted on linux, I can change this to bsd/libutil.h instead, so that the compiler will find it.

% end
header "locale.h"
header "math.h"
header "pty.h"
header "setjmp.h"
header "signal.h"
header "stdio.h"
header "stdlib.h"
header "string.h"
header "time.h"
% if CMAKE_SDK in ["OPENBSD"]:
header "util.h"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3405691582 added this for his OpenBSD port, and neither glibc nor Bionic have it.

% end
header "utmp.h"

// POSIX
% if CMAKE_SDK not in ["ANDROID"]:
header "aio.h"
% end
header "arpa/inet.h"
% if CMAKE_SDK not in ["LINUX", "ANDROID"]:
header "bsd/ifaddrs.h"
header "bsd/pty.h"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see either of these in any Ubuntu packages, nor in Bionic.

% end
header "cpio.h"
header "dirent.h"
header "dlfcn.h"
header "fcntl.h"
% if CMAKE_SDK not in ["ANDROID"]:
header "fmtmsg.h"
% end
header "fnmatch.h"
header "ftw.h"
header "glob.h"
header "grp.h"
header "iconv.h"
header "ifaddrs.h"
header "langinfo.h"
header "libgen.h"
header "link.h"
% if CMAKE_SDK not in ["ANDROID"]:
header "monetary.h"
% end
header "net/if.h"
header "netdb.h"
header "netinet/in.h"
header "netinet/tcp.h"
header "nl_types.h"
header "poll.h"
header "pthread.h"
header "pwd.h"
header "regex.h"
header "sched.h"
header "search.h"
header "semaphore.h"
header "spawn.h"
header "strings.h"
% if CMAKE_SDK not in ["LINUX", "ANDROID"]:
header "sys/event.h"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one Ubuntu package, libkqueue-dev, installs this, but in a different directory so the compiler won't find it even if it happens to be installed. It isn't in Bionic either.

% end
header "x86_64-linux-gnu/sys/file.h"
header "x86_64-linux-gnu/sys/inotify.h"
header "x86_64-linux-gnu/sys/ioctl.h"
header "x86_64-linux-gnu/sys/ipc.h"
header "x86_64-linux-gnu/sys/mman.h"
header "x86_64-linux-gnu/sys/mount.h"
header "x86_64-linux-gnu/sys/msg.h"
header "x86_64-linux-gnu/sys/resource.h"
header "x86_64-linux-gnu/sys/select.h"
header "x86_64-linux-gnu/sys/sem.h"
header "x86_64-linux-gnu/sys/sendfile.h"
header "x86_64-linux-gnu/sys/shm.h"
header "x86_64-linux-gnu/sys/socket.h"
header "x86_64-linux-gnu/sys/stat.h"
header "x86_64-linux-gnu/sys/statvfs.h"
header "x86_64-linux-gnu/sys/time.h"
header "x86_64-linux-gnu/sys/times.h"
header "x86_64-linux-gnu/sys/types.h"
header "x86_64-linux-gnu/sys/uio.h"
header "x86_64-linux-gnu/sys/un.h"
header "x86_64-linux-gnu/sys/user.h"
header "x86_64-linux-gnu/sys/utsname.h"
header "x86_64-linux-gnu/sys/wait.h"
header "sysexits.h"
header "syslog.h"
header "tar.h"
header "termios.h"
header "unistd.h"
header "utime.h"
header "wait.h"
% if CMAKE_SDK not in ["ANDROID"]:
header "ulimit.h"
header "utmpx.h"
header "wordexp.h"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to keep the ordering of headers the same throughout, in case that matters, but shifted these last two. I can keep them separately above if the order matters.

% end

// <assert.h>'s use of NDEBUG requires textual inclusion.
textual header "assert.h"
Expand Down