Bug 429952

Summary: Errors when building regtest with clang
Product: [Developer tools] valgrind Reporter: Paul Floyd <pjfloyd>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: minor CC: mark
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Suggested patch
Update patch with lambda filter

Description Paul Floyd 2020-12-03 07:46:48 UTC
Created attachment 133826 [details]
Suggested patch

Tested with
Fedora 33 amd64
clang version 11.0.0 (Fedora 11.0.0-2.fc33)


When building the regression tests with clang, drd/tests/std_thread fails to compile as follows:

std_thread.cpp:31:16: error: no type named '_Impl_base' in 'std::thread'
  std::thread::_Impl_base* __t = static_cast<std::thread::_Impl_base*>(__p);

[plus more errors]

The reason is that this test uses "_Impl_base", which as the name implies is an internal implementation-specific name used in libstdc++, GCC's default C++ library implementation. clang++ can either use libc++, which does not have _Impl_base, or it can use libstdc++. In the case of libstdc++, std_thread.cpp contains the macro check

#if defined(__GNUC__) && __GNUC__ -0 < 6

which is true with clang++ which sets __GNUC__ to 4.

However, the libstdc++ protects _Impl_base with

#if _GLIBCXX_THREAD_ABI_COMPAT

The same problem applies to std_thread2.cpp

Build can be fixed with the attached patch.
Comment 1 Paul Floyd 2020-12-03 08:09:15 UTC
In addition, std_thread2 could probably do with a filter as I get this diff

paulf> diff std_thread2.stderr.out std_thread2.stderr.exp
4c4
<    at 0x........: main::$_0::operator()() const (std_thread2.cpp:21)
---
>    at 0x........: main::{lambda()#1}::operator()() const (std_thread2.cpp:21)
Comment 2 Paul Floyd 2020-12-05 15:33:35 UTC
Created attachment 133891 [details]
Update patch with lambda filter
Comment 3 Mark Wielaard 2020-12-08 11:14:52 UTC
If this helps your build then I think this is fine. But note that your patch doesn't actually include the new filter_lambda file. Please add it before committing.
Comment 4 Mark Wielaard 2021-02-20 15:48:54 UTC
commit af0a901b4ed8625afd26891b4c91d7dd9ea6ba45
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Tue Dec 8 14:59:49 2020 +0100

    Bug 429952 - Errors when building regtest with clang