ublk-org / ublksrv

ublk: userspace block device driver
MIT License
138 stars 47 forks source link

Makefile: fix clang compilation #69

Closed masscry closed 2 months ago

masscry commented 2 months ago

Hello! I have been testing ublksrv with clang compiler, and lost some time trying to understand how to pass proper flags with autotools. This PR contains small fix for the issue. I have tested changes with g++-10, g++-11, g++-12 and clang++-14 up to clang++-16. Unit tests complete successfully.

I am open to any comments concerning this MR and will fix problems, if any.


clang/clang++ can compile ublksrv sources, but it doesn't support '-fcoroutines' flag, which is mandatory for older versions of g++ to compile sources with c++20 coroutines support.

This commit changes Makefile.am and configure.ac, in such way, one can build ublksrv sources using clang++.

After selecting c++ compiler, configure script will match $CXX with clang++ or g++, flag -fcoroutines will be added to CXXFLAGS only when building with g++. Order of match strings in AS_CASE is important, because *g++* string includes *clang++*, thus we must check with longer string first.