小编Sam*_*m G的帖子

无法更改CMake中的默认链接器

我正在尝试将链接器更改为ld.gold,以便可以更快地构建LLVM和CLANG。我用以下方法更改了环境变量:

export LD=ld.gold
Run Code Online (Sandbox Code Playgroud)

并且我已将ccmake中的CMAKE_LINKER更改为/usr/bin/ld.gold。但是,当我生成文件时,我的链接器被检测为GNU ld。编译过程中的最高运行确认ld正在运行,而不是黄金运行。

当将CMake Link Executable变量编辑为:

cmake -DCMAKE_LINKER=/usr/bin/ld.gold -DCMAKE_CXX_LINK_EXECUTABLE="<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" -G "Unix Makefiles" ../llvm
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

/usr/bin/ld.gold: -Werror=date-time: unknown option
/usr/bin/ld.gold: use the --help option for usage information
utils/PerfectShuffle/CMakeFiles/llvm-PerfectShuffle.dir/build.make:94: recipe for target 'bin/llvm-PerfectShuffle' failed
make[2]: *** [bin/llvm-PerfectShuffle] Error 1
CMakeFiles/Makefile2:13983: recipe for target 'utils/PerfectShuffle/CMakeFiles/llvm-PerfectShuffle.dir/all' failed
Run Code Online (Sandbox Code Playgroud)

我在Ubuntu 16.04上,但是在Arch Linux上也遇到了同样的问题。

谢谢。

c++ linux linker cmake clang

6
推荐指数
1
解决办法
2619
查看次数

C ++中的Constexpr迭代器

我有兴趣为个人项目创建一个非常小的constexpr容器。我需要的最重要的事情是带有真正constexpr迭代器的容器。它们最终将被添加到标准中(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0858r0.html),但是我想知道如何在当前的C ++。

假设我有一个像这样的数据结构:

template <typename T, unsigned N>
struct array {
  const T data[N];

  template<typename... Args>
  constexpr array(const Args&... args) : data{args...} {
}
  struct array_iterator {
    T const* ptr;

    constexpr array_iterator(const T* ptr) : ptr(ptr) {}

    constexpr void operator++() { ++ptr; }
    constexpr void operator--() { --ptr; }
    constexpr T const& operator* () const { return *ptr; }
    constexpr bool operator==(const array_iterator& rhs) const { return *(*this) == *rhs; }
    constexpr bool operator!=(const array_iterator& rhs) const { …
Run Code Online (Sandbox Code Playgroud)

c++ templates template-meta-programming constexpr c++17

3
推荐指数
1
解决办法
416
查看次数