./configure fails for clang-14 on Ubuntu 23.10 #29161

issue hebasto openend this issue on January 1, 2024
  1. hebasto commented at 5:08 pm on January 1, 2024: member
    0$ clang-14 -v
    1Ubuntu clang version 14.0.6
    2Target: x86_64-pc-linux-gnu
    3Thread model: posix
    4InstalledDir: /usr/bin
    5Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
    6Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
    7Candidate multilib: .;@m64
    8Selected multilib: .;@m64
    
    0$ ./configure CC=clang-14 CXX=clang++-14
    1...
    2checking whether std::atomic can be used without link library... no
    3checking whether std::atomic needs -latomic... no
    4configure: error: in `/bitcoin':
    5configure: error: cannot figure out how to use std::atomic
    6See `config.log' for more details
    

    Here is an excerpt from the config.log:

     0configure:25695: checking whether std::atomic can be used without link library
     1configure:25722: clang++-14 -std=c++20 -o conftest -g -O2 -pthread   conftest.cpp  >&5
     2In file included from conftest.cpp:32:
     3/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/chrono:2320:48: error: call to consteval function 'std::chrono::hh_mm_ss::_S_fractional_width' is not a constant 
     4expression
     5        static constexpr unsigned fractional_width = {_S_fractional_width()};
     6                                                      ^
     7/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/chrono:2320:48: note: undefined function '_S_fractional_width' cannot be used in a constant expression
     8/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/chrono:2275:2: note: declared here
     9        _S_fractional_width()
    10        ^
    111 error generated.
    
  2. hebasto added the label Build system on Jan 1, 2024
  3. maflcko commented at 10:37 am on January 2, 2024: member

    That is a bug in clang-14, fixed in 15. Reproducer:

    0template <class A>
    1struct ch {
    2    static consteval unsigned w() { return {}; };
    3    static constexpr unsigned bar{w()};
    4};
    5
    6int main() {}
    
  4. maflcko commented at 11:02 am on January 2, 2024: member

    I don’t understand why this isn’t caught by CI. Maybe libc++ somehow works around the bug in the corresponding clang?

    Not sure how to fix it. The easiest would obviously be to bump the minimum required to clang-15. However, I am not sure if that works for macOS users.

  5. hebasto commented at 11:10 am on January 2, 2024: member

    I don’t understand why this isn’t caught by CI. Maybe libc++ somehow works around the bug in the corresponding clang?

    We do not have a combination of clang-14 with libstdc++-13-dev in the CI.

  6. fanquake commented at 11:15 am on January 2, 2024: member

    Maybe libc++ somehow works around the bug in the corresponding clang?

    The issue is only when Clang is being used with libstdc++. i.e:

    0#include <chrono>
    1
    2int main() { return 0;}
    
     0clang-13 test.cpp -O2 -std=c++20
     1...
     2#include <...> search starts here:
     3 /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13
     4 /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/x86_64-linux-gnu/c++/13
     5 /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/backward
     6 /usr/lib/llvm-13/lib/clang/13.0.1/include
     7 /usr/local/include
     8 /usr/include/x86_64-linux-gnu
     9 /usr/include
    10...
    11In file included from test.cpp:1:
    12/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/chrono:2320:48: error: call to consteval function 'std::chrono::hh_mm_ss::_S_fractional_width' is not a constant expression
    13        static constexpr unsigned fractional_width = {_S_fractional_width()};
    14                                                      ^
    15/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/chrono:2320:48: note: undefined function '_S_fractional_width' cannot be used in a constant expression
    16/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/chrono:2275:2: note: declared here
    17        _S_fractional_width()
    18        ^
    191 error generated.
    
    0clang-13 test.cpp -O2 -std=c++20 -stdlib=libc++
    1...
    2#include <...> search starts here:
    3 /usr/lib/llvm-13/bin/../include/c++/v1
    4 /usr/lib/llvm-13/lib/clang/13.0.1/include
    5 /usr/local/include
    6 /usr/include/x86_64-linux-gnu
    7 /usr/include
    8...
    
  7. maflcko commented at 11:24 am on January 2, 2024: member

    I don’t understand why this isn’t caught by CI. Maybe libc++ somehow works around the bug in the corresponding clang?

    Oh, I guess libc++ doesn’t use consteval, but constexpr:

    https://github.com/llvm/llvm-project/blob/9b7cf5bfb08b6e506216ef354dfd61adb15acbff/libcxx/include/__chrono/hh_mm_ss.h#L42

  8. fanquake commented at 11:25 am on January 12, 2024: member
    Going to close this as wontfix. If someone is using an operating system that is modern enough to be shipping GCC 13.2 and Clang 16 as the default compilers, then I’d suggest using either of those as their compiler. Also given that this is a bug in Clang, but only when coupled with a certain version of libstdc++, it’s not easy for us to “fix”. An alternative is to try with libc++. For older systems, clang-14 remains supported (for now).
  9. fanquake closed this on Jan 12, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-05 19:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me