Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with libstdc++13 std::format (and, related, unable to locate LLVM libcxx headers) #188

Open
johnsonjh opened this issue Sep 13, 2023 · 3 comments

Comments

@johnsonjh
Copy link

Hi @seanbaxter

  • Related to Circle is incompatible with GCC's stdatomic.h #183 ... I can't seem to get std::format to work (with libstdc++13) ...
    Screenshot from 2023-09-13 15-34-53
    ... and I cannot use LLVM's libcxx instead of libstdc++ (which I expect would work), because Circle cannot locate the headers, and I can't seem to discern where it would be looking for them.

    $ circle --stdlib=libc++ -std=c++20 test.cc
    error: could not find clang-headers
    • Tested on RHEL 9 and Fedora 38, which is likely considerably newer and different to the platform that Circle Build 200 was compiled on.
  • FWIW, the location of the headers has changed recently - they now reside in ...
    /usr/lib/clang/${VER_MAJOR}/include
          ... where ${VER_MAJOR} is the LLVM major version only.

  • Previously, these headers were located in directories with the pattern of ...
    /usr/lib64/llvm${VER_MAJOR}/lib/clang/${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}/share
          ... i.e. /usr/lib64/llvm12/lib/clang/12.0.1/share

@johnsonjh
Copy link
Author

Also, the "--print-paths" option is less than helpful in diagnosing the problem:

$ circle --std=c++20 --stdlib=libstdc++ --print-paths /dev/null
stdlib version:
  13
-isystem:
  /usr/include/c++/13
  /usr/include/c++/13/backward
  /usr/lib/gcc/x86_64-redhat-linux/13
  /usr/include/c++/13/x86_64-redhat-linux
  /usr/lib/gcc/x86_64-redhat-linux/13/include
  /usr/local/include
  /usr/include
  /usr/include/linux
-iquote:
-I:
-ML:
  /usr/lib64/libc.so.6
  /usr/lib64/libm.so.6
  /usr/lib64/libutil.so.1
  /usr/lib64/libpthread.so.0
  /usr/lib64/libstdc++.so.6
  /usr/lib64/libc++.so.1
-L:
  /usr/local/lib64/
  /usr/local/lib/
  /usr/lib64/
  /usr/lib/
  /usr/lib/gcc/x86_64-redhat-linux/13
-rpath:

$ circle --std=c++20 --stdlib=libc++ --print-paths /dev/null   
error: could not find clang-headers

Even trying to look at things with strace (e.g. strace circle --std=c++20 --stdlib=libc++ --print-paths /dev/null 2>&1 hasn't unlocked the secret yet).

@johnsonjh
Copy link
Author

A little more on this ...

On a Ubuntu 20.04 container with appropriate packages installed, it all almost works:

$ circle --stdlib=libc++ --print-paths /dev/null
stdlib version:
  9
-isystem:
  /usr/lib/llvm-10/lib/clang/10.0.0/include
  /usr/local/include
  /usr/include/x86_64-linux-gnu
  /usr/include
  /usr/include/linux
-iquote:
-I:
-ML:
  /usr/lib/x86_64-linux-gnu/libc.so.6
  /usr/lib/x86_64-linux-gnu/libm.so.6
  /usr/lib/x86_64-linux-gnu/libutil.so.1
  /usr/lib/x86_64-linux-gnu/libpthread.so.0
  /usr/lib/x86_64-linux-gnu/libstdc++.so.6
  /usr/lib/x86_64-linux-gnu/libc++.so.1
-L:
  /usr/local/lib/
  /usr/lib64/
  /usr/lib/
  /usr/lib/x86_64-linux-gnu
  /lib/x86_64-linux-gnu
  /usr/lib/gcc/x86_64-linux-gnu/9
-rpath:
preprocessor: include/sir.hh:33:11
... included from tests/tests++.hh:29:11
... included from tests/tests++.cc:26:10
cannot find header type_traits

Seems the logic for finding the correct paths is a somewhat lacking - it's missing the include path /usr/lib/llvm-10/include/c++/v1.

I confirm that specifying -I/usr/lib/llvm-10/include/c++/v1 does work. I also tested using llvm-12, and the result is the same - the v1 directory is not in the default include path.

@johnsonjh
Copy link
Author

johnsonjh commented Sep 13, 2023

@seanbaxter

And, also, trying to use LLVM-12 with Boost format in this application gives me a bizarre error, where llvm-10 works fine:

ODR used by: bool sir::tests::boost_format()
tests/tests++.cc:198:5
    _sir_eqland(pass, log.debug_boost(bf("Testing %1% %2%")  % "boost" % "Howdy")); 
    ^

ODR used by: boost::basic_format<char, std::char_traits<char>, std::allocator<char>>::basic_format(const char*)
/usr/include/boost/format/format_class.hpp:173:32
        internal_streambuf_t   buf_; // the internal stream buffer. 
                               ^

ODR used by: boost::io::basic_altstringbuf<char, std::char_traits<char>, std::allocator<char>>::basic_altstringbuf(unsigned)
/usr/include/boost/format/alt_sstream.hpp:57:40
            explicit basic_altstringbuf(std::ios_base::openmode mode 
                                       ^

  instantiation: /usr/include/boost/format/alt_sstream_impl.hpp:227:9
  during instantiation of function int boost::io::basic_altstringbuf<char, std::char_traits<char>, std::allocator<char>>::overflow(int)
  template arguments: [
    'Ch' = char
    'Tr' = std::char_traits<char>
      class 'char_traits' declared at /usr/lib/llvm-12/include/c++/v1/__string:354:1
    'Alloc' = std::allocator<char>
      class 'allocator' declared at /usr/lib/llvm-12/include/c++/v1/iosfwd:114:25
  ]
          basic_altstringbuf<Ch, Tr, Alloc>::  
          ^
    error: /usr/include/boost/format/alt_sstream_impl.hpp:261:45
    no viable candidates in call to 'allocate'
      object is lvalue std::allocator<char>
      argument 0 is lvalue unsigned long
      argument 1 is prvalue char*
                        newptr = alloc_.allocate(new_size, is_allocated_? oldptr : 0); 
                                                ^
      candidate: char* std::allocator<char>::allocate(unsigned long)
      /usr/lib/llvm-12/include/c++/v1/memory:833:10
          _Tp* allocate(size_t __n) { 
               ^
        error: invalid argument count
        function expects 1 argument, 1 provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant