Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Theodor opened this issue Jul 13, 2017 · 3 comments
Open
Assignees
Labels
ABI Application Binary Interface bugzilla Issues migrated from bugzilla clang:codegen confirmed Verified by a second party platform:solaris

Comments

@Theodor
Copy link
Collaborator

Theodor commented Jul 13, 2017

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.

@Theodor
Copy link
Collaborator Author

Theodor commented Jul 13, 2017

assigned to @Theodor

@Theodor
Copy link
Collaborator Author

Theodor commented Jul 13, 2017

See gcc mail thread that introduces this hack:
https://gcc.gnu.org/ml/gcc-patches/2011-08/msg00834.html

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@llvmbot llvmbot added the confirmed Verified by a second party label Jan 26, 2022
@AaronBallman AaronBallman added ABI Application Binary Interface platform:solaris labels Jul 25, 2024
@AaronBallman
Copy link
Collaborator

This issue hit our own project in: #99075

rorth added a commit that referenced this issue Jul 26, 2024
The introduction of `std::put_time` in
fad17b4 broke the Solaris build:
```
Undefined			first referenced
 symbol  			    in file
_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPKSt2tmPKcSB_ lib/libclangLex.a(PPMacroExpansion.cpp.o)
ld: fatal: symbol referencing errors
```
As discussed in PR #99075, the problem is that GCC mangles `std::tm` as
`tm` on Solaris for binary compatility, while `clang` doesn't (Issue
#33114).

As a stop-gap measure, this patch introduces an `asm` level alias to the
same effect.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ABI Application Binary Interface bugzilla Issues migrated from bugzilla clang:codegen confirmed Verified by a second party platform:solaris
Projects
None yet
Development

No branches or pull requests

3 participants