Skip to content

Commit 139569a

Browse files
committed
[clang] Handle tm mangling on Solaris in PPMacroExpansion.cpp
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 llvm#99075, the problem is that GCC mangles `std::tm` as `tm` on Solaris for binary compatility, while `clang` doesn't (Issue 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`.
1 parent ed1c67b commit 139569a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

clang/lib/Lex/PPMacroExpansion.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,16 @@ static bool isTargetVariantEnvironment(const TargetInfo &TI,
16041604
return false;
16051605
}
16061606

1607+
#if defined(__sun__) && defined(__svr4__)
1608+
// GCC mangles std::tm as tm for binary compatibility on Solaris (Issue
1609+
// #33114). We need to match this to allow the std::put_time calls to link
1610+
// (PR #99075).
1611+
asm("_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_"
1612+
"RSt8ios_basecPKSt2tmPKcSB_ = "
1613+
"_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_"
1614+
"RSt8ios_basecPK2tmPKcSB_");
1615+
#endif
1616+
16071617
/// ExpandBuiltinMacro - If an identifier token is read that is to be expanded
16081618
/// as a builtin macro, handle it and return the next token as 'Tok'.
16091619
void Preprocessor::ExpandBuiltinMacro(Token &Tok) {

0 commit comments

Comments
 (0)