Skip to content

std::tm type needs to be mangled as "::tm" on Solaris for g++ binary compat #33114

@Theodor

Description

@Theodor
Bugzilla Link 33767
Version unspecified
OS Solaris

Extended Description

g++ on Solaris has special mangling twist that makes it generate non-standard mangling for std::tm, std::div_t, std::ldiv_t, std::lconv types.

W/o this twist clang fails to link with libstdc++ on testcases like this:

] cat no-tm.cc
#include
struct D : std::time_get {};

int main() {
D var;
var.date_order();
}
] clang no-tm.cc
Undefined first referenced
symbol in file
_ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE11do_get_timeES3_S3_RSt8ios_baseRSt12_Ios_IostatePSt2tm /var/tmp/no-tm-e5c67b.o
_ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE11do_get_dateES3_S3_RSt8ios_baseRSt12_Ios_IostatePSt2tm /var/tmp/no-tm-e5c67b.o
_ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14do_get_weekdayES3_S3_RSt8ios_baseRSt12_Ios_IostatePSt2tm /var/tmp/no-tm-e5c67b.o
_ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE11do_get_yearES3_S3_RSt8ios_baseRSt12_Ios_IostatePSt2tm /var/tmp/no-tm-e5c67b.o
_ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE16do_get_monthnameES3_S3_RSt8ios_baseRSt12_Ios_IostatePSt2tm /var/tmp/no-tm-e5c67b.o
ld: fatal: symbol referencing errors
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
]

Basically any signature that includes either of the aforementioned types is mangled differently than whats in libstdc++.

Namely, clang mangles std::tm as std::tm (surpise! :), while gcc does it as ::tm.

Say, first undefined symbol above:

] nm /usr/lib/libstdc++.so | grep _ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE11do_get_timeES3_S3_RSt8ios_baseRSt12_Ios_Iostate
[6646] | 533632| 276|FUNC |WEAK #0 #1182 |_ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE11do_get_timeES3_S3_RSt8ios_baseRSt12_Ios_IostateP2tm
]

Notice 2tm vs St2tm difference at the tail of the mangled name.

Metadata

Metadata

Assignees

Labels

ABIApplication Binary InterfacebugzillaIssues migrated from bugzillaclang:codegenIR generation bugs: mangling, exceptions, etc.confirmedVerified by a second partyplatform:solaris

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions