Repository navigation
[types] Keep MinGW's x87 long double and spell it exactly in exported C - #1332
Merged
Merged
Conversation
A MinGW program's long double is the x87's, 16 bytes on x64 and on x86 12 aligned to four, which Microsoft's ABI, under which every Windows program's types read, does not hold: its DWARF's long double members read as bytes, and a declared long double was eight. The record ABIs gain MinGW's, with a column for x86's alignment and one naming the ABI whose header libraries a program joins. A Windows program whose own sections hold DWARF, which MinGW's compilers write, takes them unless the DWARF's long double is a double, as clang-cl's is; its types read from that DWARF where no PDB describes it. C spells no long double every compiler makes as large. Outside signatures, the portable and Windows spellings name the program's neverd_long_double_<n>, which the prelude declares as the compiler's long double where it is as large and elsewhere as bytes aligned as the program's, and which the C parser reads back. The checker compiles the Windows spelling with both Windows compilers, and MinGW's rows with MSVC's too.
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
A MinGW program's
long doubleis the x87's: 16 bytes on x64, and on x86 12 bytes aligned to four, where a double aligns to eight. Local types read every Windows program under Microsoft's ABI, whose long double is a double. Such members were kept as raw bytes, and a declaredlong doublewas 8 bytes.MinGW's record ABIs (
RecordABIs.def)mingw-x64andmingw-x86: Microsoft's records with the x87's long double.LongDoubleAligncolumn gives x86's alignment of four.Librarycolumn names the ABI whose header libraries a program joins, so MinGW programs still join the Windows libraries.Which programs get it (
recordABIOf, one place)long doublebase type is 8 bytes, the program stays Microsoft's. clang-cl with-gdwarfis such a case (dwarfLongDoubleBytes).Local types read that DWARF where no PDB describes the program; before, such a program had no types of its own (
"none").Exported C has the same layout on every compiler
long doublethat every compiler makes the same size. Outside signatures, the portable and Windows spellings now name the program's long doubleneverd_long_double_<n>.__SIZEOF_LONG_DOUBLE__is<n>. Elsewhere it is that many bytes, aligned as the program aligns them; for 8 bytes it is a double, which MSVC's long double is.long double, which the target's convention passes. The keywords spelling is the target's own.The checker's new
mingw-x64andmingw-x86rows compile the program's C with MinGW's compiler, and the portable and Windows spellings with MSVC's too. The Windows spelling of every Windows row is now compiled by both Windows compilers. Rust runs forx86_64-pc-windows-gnuandi686-pc-windows-gnu, which the fetch script now installs.Verification
SessionCAPITest.MinGWProgramsKeepTheX87LongDoubleloads three images of the newmingw_types.cfixture, built as it says:mingw-x64): member at 16, 16 bytes;mingw-x86): member at 4, 12 bytes, the double at 16;-gdwarf(microsoft): member at 8, 8 bytes.Each reads its types from its DWARF and joins the Windows libraries.
check_type_renders.pyover records and a typedef holding long doubles, beside a double, a long long and a function pointer taking one, under every data model and record ABI pair: microsoft LLP64 and ILP32, mingw-x64, mingw-x86, itanium, apple-arm64, i386-sysv, android-i386 and aapcs32. None fails; Lua is skipped, as it is not installed here.x86_64-pc-windows-gnuandi686-pc-windows-gnu.Each fixture's header compiles with its size and offset checks under clang for MSVC x86 and x64, MinGW x86 and x64, Linux i686, x86-64 and AArch64, and macOS arm64, in both spellings. 64-bit layouts were compiled for 64-bit targets only.
Tests:
TypeParse.ExactLongDoublesReadBackAsTheProgramsOwn,TypeRender.RecordLongDoublesAreAsLargeOnEveryCompilerand the MinGW layouts inTypeParse/LocalTypes. NeverDTypesTests (123) and NeverDSessionCAPITests (172) pass, with the kernel inputs.The style check passes.
Known failures and limitations
redefinition of 'tagLC_ID','threadlocaleinfostruct'and'localeinfo_struct'.<stdint.h>brings in its CRT'scorecrt.h, which defines these records. The header defines them again.