This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
mangling of real-valued template parameters: inherent ABI instability and cross-compiling nightmare
- From: Joern Rennecke <joern dot rennecke at superh dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 03 Jun 2003 21:33:35 +0100
- Subject: mangling of real-valued template parameters: inherent ABI instability and cross-compiling nightmare
- Organization: SuperH UK Ltd.
When not cross-compiling, cp/mangle.c:write_template_arg_literal
dumps out the bit pattern inside a TREE_REAL_CST in hex - when
cross-compiling, it give a message:
"sorry, unimplemented: real-valued template parameters when cross-compiling"
(which can be observed for the testcase g++.dg/abi/mangle17.C) .
A TREE_REAL_CST is currently implemented as a struct real_value.
Not only does the layout depend on ABI details of the host -
and you will get different mangling you you compile the compiler
binary with a different ABI, which can be quite 'interesting' on
hosts that have more than one, e.g. x86-64 - but the exact value
of the mangled name also depends on what the compiler the compiler
was compiled with deems to stuff into the holes between the structure
members. We make no guarantees that we don't change these gap fillers -
they might even change during the runtime of a program - and neither
do other compiler providers.
Also, 'fixing' the cross-compiling case to output the name as if it
was mangled by a native compiler on the target is just too messy to
contemplate.
I move that we break compatibility once now, to a proper mangling
that depends only on the value, but not on the ABI.
real.c:real_to_hexadecimal seems a good start, then probably replace
the decimal point and the signs with other characters, e.g.:
'.' -> 'p'
'-' -> 'M'
'+' -> 'P'
plus do whatever is needed so that the mangling won't be confused
with another one.
--
--------------------------
SuperH (UK) Ltd.
2410 Aztec West / Almondsbury / BRISTOL / BS32 4QX
T:+44 1454 465658