Skip to content

Commit

Permalink
Makefile: fix clang compilation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
masscry committed Jul 28, 2024
1 parent 1f1e327 commit 82df0b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ EXTRA_DIST = \

SUBDIRS = include lib tests

AM_CXXFLAGS = -fcoroutines -std=c++20
AM_CXXFLAGS = -std=c++20

sbin_PROGRAMS = ublk ublk_user_id
noinst_PROGRAMS = demo_null demo_event
Expand Down
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ AX_PTHREAD
dnl Check for C++.
AC_PROG_CXX

AS_CASE([$CXX],
[*clang++*], [ENABLE_CORO_FLAG=""],
[*g++*], [ENABLE_CORO_FLAG="-fcoroutines"],
[ENABLE_CORO_FLAG=""]
)

CXXFLAGS="$CXXFLAGS $ENABLE_CORO_FLAG"


dnl --enable-gcc-warnings to turn on GCC warnings (for developers).
AC_ARG_ENABLE([gcc-warnings],
[AS_HELP_STRING([--enable-gcc-warnings],
Expand Down

0 comments on commit 82df0b4

Please sign in to comment.