1
0
mirror of https://github.com/skeeto/w64devkit.git synced 2026-10-23 06:08:56 +03:00

Overload C functions on argument type with gnu::overloadable

Clang has an "overloadable" attribute that lets several C functions
share a name, chosen between by argument type, with C++ name mangling
applied so that the symbols stay distinct. GCC rejected the idea
upstream, so carry it here for the shipped compiler. The patch header
explains the implementation; in short, overload sets reuse the binding
chain pushdecl already maintains, a call is resolved beside the
type-directed overloading GCC does for the __atomic builtins, and
mangling is a new C-subset Itanium writer, since cp/mangle.cc is a
cc1plus object that would silently mangle C function types wrong.

Mangling matches g++ byte for byte across the types C can express, at
both -m32 and -m64, substitution compression and stdcall decoration
included. Dispatch agrees with Clang 23 on every case tried. The C
testsuite passes 42100 tests with no failures, the patched compiler
still builds libgcc and libstdc++, and the gcc.exe from a full kit
build passes the whole test corpus.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Christopher Wellons
2026-09-19 11:39:07 -04:00
parent 16ed33fa2d
commit f28b0d02f9
2 changed files with 1442 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2,5 +2,6 @@ Os-no-declone-ctor-dtor.patch
driver-self-locate.patch
i686-dumpmachine.patch
libgomp-gfortran-path.patch
overloadable.patch
relocatable.patch
static-complit-flex-array.patch