hosseinmoein / DataFrame

C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types and contiguous memory storage
https://hosseinmoein.github.io/DataFrame/
BSD 3-Clause "New" or "Revised" License
2.38k stars 298 forks source link

CLang 16.0.6 fails to build a file including `DataFrame/DataFrame.h` #289

Closed avilleret closed 3 months ago

avilleret commented 3 months ago

Under Linux (Manjaro 6.6.19-1), clang fails to build a simple .cpp file including DataFrame/DataFrame.h. I'm testing with DataFrame version fd56c03 (which builds fine with the same clang btw).

Here is the error I got:

[1/2 0.9/sec] Building CXX object CMakeFiles/database_processor.dir/DatabaseProcessor.cpp.o
FAILED: CMakeFiles/database_processor.dir/DatabaseProcessor.cpp.o 
/usr/bin/clang++   -DQT_QML_DEBUG -g -std=gnu++2b -fcolor-diagnostics -MD -MT CMakeFiles/database_processor.dir/DatabaseProcessor.cpp.o -MF CMakeFiles/database_processor.dir/DatabaseProcessor.cpp.o.d -o CMakeFiles/database_processor.dir/DatabaseProcessor.cpp.o -c /home/antoine/dev/Flir/data/DatabaseProcessor.cpp
In file included from /home/antoine/dev/Flir/data/DatabaseProcessor.cpp:1:
In file included from /usr/local/include/DataFrame/DataFrame.h:32:
In file included from /usr/local/include/DataFrame/DataFrameStatsVisitors.h:33:
In file included from /usr/local/include/DataFrame/Internals/DataFrame_standalone.tcc:33:
In file included from /usr/local/include/DataFrame/Utils/Threads/ThreadGranularity.h:32:
In file included from /usr/local/include/DataFrame/Utils/Threads/ThreadPool.h:42:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:6151:14: error: requires clause differs in template redeclaration
    requires forward_range<_Vp>
             ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:5850:14: note: previous template declaration is here
    requires input_range<_Vp>
             ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:8846:20: error: type-id cannot have a name
    { return (auto(__x) += __y); }
                   ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:8846:25: error: expected ')'
    { return (auto(__x) += __y); }
                        ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:8846:14: note: to match this '('
    { return (auto(__x) += __y); }
             ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:8846:32: error: expected expression
    { return (auto(__x) += __y); }
                               ^
4 errors generated.
ninja: build stopped: subcommand failed.

here is the DatabaseProcessor.cpp :

#include <DataFrame/DataFrame.h>

int main(int argc, char** argv)
{
    return 0;
}

and the CMakeLists.txt I'm using :

cmake_minimum_required(VERSION 3.20)
project(MyProject LANGUAGES CXX)
find_package(DataFrame)
add_executable(database_processor DatabaseProcessor.cpp)
target_link_libraries(database_processor DataFrame::DataFrame tbb)

It seems to be related to this comment in Discussion: https://github.com/hosseinmoein/DataFrame/discussions/189#discussioncomment-8622395

While it looks like a compiler issue, I'm surprised to be able to build the library itself with it. Here the library build's log for the record:

[antoine@Manjaro MetadataExtractor]$ cmake -B build-DataFrame-clang DataFrame/ -DCMAKE_CXX_COMPILER=/usr/bin/clang -DCMAKE_BUILD_TYPE=Release
-- The CXX compiler identification is Clang 16.0.6
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for clock_gettime
-- Looking for clock_gettime - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/antoine/dev/Flir/data/MetadataExtractor/build-DataFrame-clang
[antoine@Manjaro MetadataExtractor]$ cmake --build build-DataFrame-clang/
[ 50%] Building CXX object CMakeFiles/DataFrame.dir/src/Utils/DateTime.cc.o
[100%] Linking CXX static library libDataFrame.a
[100%] Built target DataFrame
[antoine@Manjaro MetadataExtractor]$ 
hosseinmoein commented 3 months ago

Yes, I believe this is a compiler (or C++ library setup) issue just like #189 . If you notice, all the errors come from the C++ library headers. It seems they are not fully conformable with C++20 (in particular concepts). DataFrame requires C++23.

The reason you can compile that DataFrame library is because most of the codebase is header-only. The only source file that is archived into the library is the DateTime source file that doesn't refer to any code in DataFrame.h. If you compile all the test executables, then you are in business