我试图为Linux主机和QNX目标编译一个交叉编译器。
从foundry27站点获得5.1版本。
因此,现在我暂停编译目标libstdc++,由刚刚编译的中间xgcc编译。当它试图编译libstdc++/src/c++11/条件_variable.cc时发生错误,错误消息是:
In file included from /home/kovtyukhrd/toolchain/builds/gcc_5_1_branch/linux-x86-o-ntox86/i486-pc-nto-qnx8.0.0/libstdc++-v3/include/condition_variable:39:0,
from ../../../../../libstdc++-v3/src/c++11/condition_variable.cc:25:
/home/kovtyukhrd/toolchain/builds/gcc_5_1_branch/linux-x86-o-ntox86/i486-pc-nto-qnx8.0.0/libstdc++-v3/include/mutex:126:5: error: explicitly defaulted function 'constexpr std::mutex::mutex()' cannot be declared as constexpr because the implicit declaration is not constexpr:
mutex() noexcept = default;
^
/home/kovtyukhrd/toolchain/builds/gcc_5_1_branch/linux-x86-o-ntox86/i486-pc-nto-qnx8.0.0/libstdc++-v3/include/mutex:118:9: error: use of deleted function 'constexpr std::__mutex_base::__mutex_base()'
class mutex : private __mutex_base
^
/home/kovtyukhrd/toolchain/builds/gcc_5_1_branch/linux-x86-o-ntox86/i486-pc-nto-qnx8.0.0/libstdc++-v3/include/mutex:65:15: note: 'constexpr std::__mutex_base::__mutex_base() noexcept' is implicitly deleted because its exception-specification does not match the implicit exception-specification 'noexcept (false)'
constexpr __mutex_base() noexcept = default;
^所以现在我可以看到,编译器试图隐式删除__mutex_base构造函数,而当我们试图在继承类(mutex)中使用它时,编译失败了。这里我们可以读到关于带有显式异常规范的函数的隐式删除,这与隐式异常规范不兼容(获得了这个链接这里)。
现在,我们应该考虑__mutex_base()的“隐式异常规范‘Now以外(False)”。如果要调用一个函数,则可以将其隐式指定为‘to以外(false)’,该函数具有‘to以外(false)’规范。但是在预处理之后,我们有了以下代码:
...
typedef struct _sync { int __count; unsigned __owner; } sync_t;
...
typedef struct _sync pthread_mutex_t;
...
typedef pthread_mutex_t __gthread_mutex_t;
...
class __mutex_base
{
protected:
typedef __gthread_mutex_t __native_type;
__native_type _M_mutex = { 0x80000000, 0xffffffff };
constexpr __mutex_base() noexcept = default;
# 78 "/home/kovtyukhrd/toolchain/builds/gcc_5_1_branch/linux-x86-o-ntox86/i486-pc-nto-qnx8.0.0/libstdc++-v3/include/mutex" 3
__mutex_base(const __mutex_base&) = delete;
__mutex_base& operator=(const __mutex_base&) = delete;
};现在--问题是:“为什么__mutex_base()有隐式异常--规范‘now以外(false)'?”
另一个问题是,我应该如何正确编译这个库而不修改源代码?
发布于 2016-05-18 15:46:54
这是GCC 5.1中的一个问题,这项问题已经在GCC 5.2中解决了。问题是0x80000000不是_sync结构的int成员的有效初始化器,因为它超出了int的范围,类型为无符号的值也是如此。将其转换为int需要收缩转换,这在常量表达式中是不允许的。这就使得构造函数不受约束(提到noexcept(false)似乎是一条红鲱鱼)。
https://stackoverflow.com/questions/37300917
复制相似问题