Skip to content

Commit

Permalink
make: silence clang complaining of -pthread
Browse files Browse the repository at this point in the history
The clang linker doesn't need -pthread and
warns of unknown command-line option.

This detects clang and forgoes the -pthread
flag to the linker.

Change-Id: I658cd887c567a5beeeae0e6e1b6d596231894c1b
Signed-off-by: Ashod Nakashian <[email protected]>
  • Loading branch information
Ashod authored and mmeeks committed May 15, 2023
1 parent fd87ab6 commit c6dd263
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ if !ENABLE_DEBUG
AM_CPPFLAGS += -DNDEBUG
endif

AM_LDFLAGS = -pthread -Wl,-E -lpam $(ZLIB_LIBS) $(ZSTD_LIBS) ${PNG_LIBS}
AM_LDFLAGS = -Wl,-E -lpam $(ZLIB_LIBS) $(ZSTD_LIBS) ${PNG_LIBS}

# Clang's linker doesn't like -pthread.
if !HAVE_CLANG
AM_LDFLAGS += -pthread
endif

if ENABLE_SSL
AM_LDFLAGS += ${OPENSSL_LIBS}
Expand Down
14 changes: 14 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,20 @@ else
AC_MSG_ERROR(Compiler doesn't support C++17)
fi

# Check if we have clang, rather than gcc, which
# doesn't like -pthread on the linker command-line.
AC_MSG_CHECKING([whether the compiler is clang])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#if !defined(__clang__)
#error not clang
#endif
])],
[AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_CLANG],1,[whether the C++ compiler is clang])],
[AC_MSG_RESULT([no])
AC_DEFINE([HAVE_CLANG],0,[whether the C++ compiler is clang])])
AM_CONDITIONAL([HAVE_CLANG], [test "$HAVE_CLANG" = "1"])

AS_IF([test "$ENABLE_GTKAPP" != true],
[CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXXSTD"])

Expand Down
7 changes: 6 additions & 1 deletion test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ endif
noinst_LTLIBRARIES = ${all_la_unit_tests}

MAGIC_TO_FORCE_SHLIB_CREATION = -rpath /dummy
AM_LDFLAGS = -pthread -module $(MAGIC_TO_FORCE_SHLIB_CREATION) $(ZLIB_LIBS) $(ZSTD_LIBS) ${PNG_LIBS}
AM_LDFLAGS = -module $(MAGIC_TO_FORCE_SHLIB_CREATION) $(ZLIB_LIBS) $(ZSTD_LIBS) ${PNG_LIBS}

# Clang's linker doesn't like -pthread.
if !HAVE_CLANG
AM_LDFLAGS += -pthread
endif

if ENABLE_SSL
AM_LDFLAGS += ${OPENSSL_LIBS}
Expand Down

0 comments on commit c6dd263

Please sign in to comment.