__thread keyword with target: powerpc-unknown-linux

howdy!

Is __thread suppose to work? I got a crash which compiling libkqueue. it is complaining about…

const char *
kevent_dump(const struct kevent *kev)
{
static __thread char buf[1024];

snprintf((char *) &buf[0], sizeof(buf),
“{ ident=%d, filter=%s, %s, %s, data=%d, udata=%p }”,
(u_int) kev->ident,
kevent_filter_dump(kev),
kevent_flags_dump(kev),
kevent_fflags_dump(kev),
(int) kev->data,
kev->udata);

return ((const char *) &buf[0]);
}

I won’t bother submitting a bug report and a test file if __thread isn’t properly implemented (at least on powerpc linux) yet.

crash log if someone is interested….

Assertion failed: ((TLI.getTypeAction(DAG.getContext(), Node->getOperand(i).getValueType()) == TargetLowering::TypeLegal || Node->getOperand(i).getOpcode() == ISD::TargetConstant) && “Unexpected illegal type!”), function LegalizeOp, file /Volumes/storage/clangcrosscompiler/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp, line 1174.
0 clang 0x00000001108104b8 void
llvm::object_creator<llvm::sys::ThreadLocal<llvm::PrettyStackTraceEntry const> >() + 15240
1 clang 0x00000001108109b4 void* llvm::object_creator<llvm::sys::ThreadLocal<llvm::PrettyStackTraceEntry const> >() + 16516
2 libsystem_platform.dylib 0x00007fff91f8e5aa _sigtramp + 26
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 1845959280
4 clang 0x0000000110810766 void* llvm::object_creator<llvm::sys::ThreadLocal<llvm::PrettyStackTraceEntry const> >() + 15926
5 clang 0x0000000110810741 void* llvm::object_creator<llvm::sys::ThreadLocal<llvm::PrettyStackTraceEntry const> >() + 15889
6 clang 0x000000011002428d void std::__1::vector<std::__1::pair<llvm::Type*, llvm::Type* const*>, std::__1::allocator<std::__1::pair<llvm::Type*, llvm::Type* const*> > >::__push_back_slow_path<std::__1::pair<llvm::Type*, llvm::Type* const*> >(std::__1::pair<llvm::Type*, llvm::Type* const*>&&) + 53901
7 clang 0x000000011001cb7b void std::__1::vector<std::__1::pair<llvm::Type*, llvm::Type* const*>, std::__1::allocator<std::__1::pair<llvm::Type*, llvm::Type* const*> > >::__push_back_slow_path<std::__1::pair<llvm::Type*, llvm::Type* const*> >(std::__1::pair<llvm::Type*, llvm::Type* const*>&&) + 23419
8 clang 0x00000001101333f6 llvm::SmallVectorTemplateBase<llvm::MachineModuleInfo::VariableDbgInfo, false>::grow(unsigned long) + 36422
9 clang 0x0000000110131e0e llvm::SmallVectorTemplateBase<llvm::MachineModuleInfo::VariableDbgInfo, false>::grow(unsigned long) + 30814
10 clang 0x000000011012f6fa llvm::SmallVectorTemplateBase<llvm::MachineModuleInfo::VariableDbgInfo, false>::grow(unsigned long) + 20810
11 clang 0x000000010fe1e468 void std::__1::vector<std::__1::pair<llvm::MCSymbol*, llvm::MCSymbol*>, std::__1::allocator<std::__1::pair<llvm::MCSymbol*, llvm::MCSymbol*> > >::__push_back_slow_path<std::__1::pair<llvm::MCSymbol*, llvm::MCSymbol*> >(std::__1::pair<llvm::MCSymbol*, llvm::MCSymbol*>&&) + 115768
12 clang 0x00000001102714cc llvm::raw_ostream& llvm::WriteGraph<llvm::MachineFunction const*>(llvm::raw_ostream&, llvm::MachineFunction const* const&, bool, llvm::Twine const&) + 5916
13 clang 0x00000001107a110d void* llvm::object_creator<llvm::LeakDetectorImpl >() + 25485
14 clang 0x00000001107a139b void* llvm::object_creator<llvm::LeakDetectorImpl >() + 26139
15 clang 0x00000001107a19cc void* llvm::object_creator<llvm::LeakDetectorImpl >() + 27724
16 clang 0x000000010eba4dee void std::__1::vector<clang::serialization::ModuleFile*, std::__1::allocatorclang::serialization::ModuleFile* >::__push_back_slow_path<clang::serialization::ModuleFile* const&>(clang::serialization::ModuleFile* const&&&) + 8590
17 clang 0x000000010eccdcab llvm::SmallVectorTemplateBase<llvm::DenseMap<clang::BaseSubobject, unsigned long long, llvm::DenseMapInfoclang::BaseSubobject >, false>::grow(unsigned long) + 22379
18 clang 0x000000010ed2e7e4 void std::__1::vector<clang::CXXRecordDecl const*, std::__1::allocator<clang::CXXRecordDecl const*> >::__push_back_slow_path<clang::CXXRecordDecl const* const&>(clang::CXXRecordDecl const* const&&&) + 139348
19 clang 0x000000010eccc6c8 llvm::SmallVectorTemplateBase<llvm::DenseMap<clang::BaseSubobject, unsigned long long, llvm::DenseMapInfoclang::BaseSubobject >, false>::grow(unsigned long) + 16776
20 clang 0x000000010ea29443 std::__1::__tree<std::__1::__value_type<clang::edit::FileOffset, clang::edit::EditedSource::FileEdit>, std::__1::__map_value_compare<clang::edit::FileOffset, std::__1::__value_type<clang::edit::FileOffset, clang::edit::EditedSource::FileEdit>, std::__1::lessclang::edit::FileOffset, true>, std::__1::allocator<std::__1::__value_type<clang::edit::FileOffset, clang::edit::EditedSource::FileEdit> > >::destroy(std::__1::__tree_node<std::__1::__value_type<clang::edit::FileOffset, clang::edit::EditedSource::FileEdit>, void*>) + 7571
21 clang 0x000000010ea0167d void std::__1::vector<clang::FrontendInputFile, std::__1::allocatorclang::FrontendInputFile >::__push_back_slow_path<clang::FrontendInputFile const&>(clang::FrontendInputFile const&&&) + 17821
22 clang 0x000000010e9c509a void std::__1::__tree_balance_after_insert<std::__1::__tree_node_base<void
>>(std::__1::__tree_node_base<void>, std::__1::__tree_node_base<void>*) + 4426
23 clang 0x000000010e9bcc9f
24 clang 0x000000010e9c2e2d void std::__1::vector<llvm::SourceMgr::SrcBuffer, std::__1::allocatorllvm::SourceMgr::SrcBuffer >::__push_back_slow_path<llvm::SourceMgr::SrcBuffer const&>(llvm::SourceMgr::SrcBuffer const&&&) + 9181
25 libdyld.dylib 0x00007fff8ec625fd start + 1
26 libdyld.dylib 0x000000000000004a start + 1899616846
Stack dump:
0. Program arguments: /Volumes/dev/devel/comx_p2020_linux_3_8_tools/bin/clang -cc1 -triple powerpc-unknown-linux -S -disable-free -main-file-name kevent.c -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -target-cpu ppc -target-linker-version 136 -g -coverage-file /var/folders/yb/mnfx7n_14xvdwy23w9f_wt9c0000gn/T/kevent-882b66.s -resource-dir /Volumes/dev/devel/comx_p2020_linux_3_8_tools/bin/…/lib/clang/3.5.0 -D HAVE_CONFIG_H -D _XOPEN_SOURCE=600 -D PIC -I . -I ./src/common -I ./include -isysroot /devel/linux_sysroot_3.8 -internal-isystem /devel/linux_sysroot_3.8/usr/local/include -internal-isystem /Volumes/dev/devel/comx_p2020_linux_3_8_tools/bin/…/lib/clang/3.5.0/include -internal-externc-isystem /devel/linux_sysroot_3.8/include -internal-externc-isystem /devel/linux_sysroot_3.8/usr/include -O2 -Wall -Wextra -Wno-missing-field-initializers -Werror -std=c99 -fno-dwarf-directory-asm -fdebug-compilation-dir /Volumes/Old_HD/media_store/Downloads/gcd/libkqueue-2.0.1 -ferror-limit 19 -fmessage-length 316 -fvisibility hidden -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o /var/folders/yb/mnfx7n_14xvdwy23w9f_wt9c0000gn/T/kevent-882b66.s -x c src/common/kevent.c

  1. parser at end of file
  2. Code generation
  3. Running pass ‘Function Pass Manager’ on module ‘src/common/kevent.c’.
  4. Running pass ‘PowerPC DAG->DAG Pattern Instruction Selection’ on function ‘@kevent_dump
    clang: error: unable to execute command: Illegal instruction: 4
    clang: error: clang frontend command failed due to signal (use -v to see invocation)
    clang version 3.5.0 (trunk 205694)
    Target: powerpc-unknown-linux
    Thread model: posix

filed the bug. looks like a crash specific to targeting PPC. crashes 3.5 & 3.4.1

In general, it's always a bug if a compiler crashes. It doesn't matter if a feature is supported or not, it shouldn't crash. If a feature isn't supported it should output an appropriate error message.

True. It was submitted since no one said "don't bother"