Repository navigation
[types] Take libSystem's types from Apple's headers; MinGW's runtime stays its own - #1352
Merged
Merged
Conversation
…stays its own #1348 took glibc's, bionic's and musl's types from the system's headers. A macOS or iOS program's header defined libSystem's types everywhere, which collided with Apple's own headers on macOS. The Darwin libraries are systems now: <TargetConditionals.h> tells macOS from iOS, the regenerated libraries name each type's header, and elsewhere the header defines them itself, every file-scope name that begins with an underscore taking another name there. The fetch script clones Apple's projects at the libraries' tags and installs their headers, on which the checker compiles the Darwin libraries' own systems. A Windows program's records of the C runtime, which the Windows libraries define and MinGW's <stdint.h> declares too, took no other name under MinGW, which redefined them: a program's own types take the compiler's prelude names now as a system's do, and the table gains the Windows C runtimes' names. In C++ a record a routine shares the name of goes by its tag, as stat() hides struct stat. Rust names the setter of a bit-field called type set_type, and Go names every parameter where C names some.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This follows #1348, which made C and C++ headers take glibc's, bionic's and musl's types from the system's own headers where the compiler has them. It does the same for Apple's libSystem, and stops headers of Windows programs from colliding with MinGW's C runtime.
macOS and iOS programs
The Darwin libraries are systems too (
HeaderLibrarySystems.def). The probe includes<TargetConditionals.h>, which clang's ownTARGET_OS_*definitions answer as well, and testsTARGET_OS_OSXfor macOS, orTARGET_OS_IOSwithout Mac Catalyst for iOS and its simulator.On macOS or iOS, a macOS or iOS program's header takes libSystem's types from Apple's headers. Everywhere else it defines them itself. Before, it defined them everywhere, which collided with Apple's own headers on macOS: 22 errors.
generate_darwin_types.pynow writes#pragma neverd_headerbefore each type, as the Linux generator does. MacOSX64, MacOSARM64 and IOSARM64 are regenerated.fetch_render_toolchains.pynow also:check_type_renders.py --system-library macos-x64|macos-arm64|ios-arm64compiles on those installed headers.Windows programs
<stdint.h>declares the C runtime's records,tagLC_ID,threadlocaleinfostructandlocaleinfo_struct, which the Windows user libraries a program joins also define: the header redefined them under MinGW.PreludeNames.def) the way the system's types do: another name for the header's own definitions, which leaves the compiler's name after it._WIN32and MinGW's own under__MINGW32__.Also
_opaque_pthread_tamong them. A system's such types take another name on other compilers.struct stat), asstat()hides it.Verification
A macOS program's header (
safety_cases_macho_arm64, which joins libSystem's library), with checks and prototypes:check_type_renders.pyWindowsUserX64,WindowsUserX86andWindowsKernelX64have no failures. The MinGW compile of their Windows spelling failed 3 checks before.--system-library:MacOSX64,MacOSARM64,IOSARM64,LinuxX64,LinuxX86andMuslX64fail only MSVC's GNU bit-fields;AndroidX64has no failures;vm_statistics64, which the checks report. The checker compiles macOS's own system on the installed headers, and leaves zig's macOS of the same architecture out of the other systems.Tests
SessionCAPITest.LibSystemsTypesComeFromApplesHeaders,TypeRender.TheWindowsRuntimesRecordsStayMinGWsUnderMinGW,TypeRender.KeywordBitfieldsAndPartlyNamedParametersRender.Generation
NEVERD_GNU_STRUCT.Limitations
_locale_tand the other names Microsoft's runtime declares are taken from its documented<corecrt.h>, untested against it.