Skip to content

Commit fc84f4f

Browse files
build: add checks for -rdynamic linker flag support
Signed-off-by: Ar Rakin <rakinar2@onesoftnet.eu.org>
1 parent a902a78 commit fc84f4f

2 files changed

Lines changed: 40 additions & 13 deletions

File tree

configure.ac

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,9 @@ LT_INIT
139139

140140
# Checks for libraries.
141141

142-
case "$host_os" in
143-
darwin*) shared_library_ext="dylib" ;;
144-
cygwin*|mingw*) shared_library_ext="dll" ;;
145-
*) shared_library_ext="so" ;;
146-
esac
147-
148-
AC_DEFINE_UNQUOTED([SHARED_LIBRARY_EXTENSION], ["$shared_library_ext"], [The extension shared libraries use on this platform])
142+
AC_CHECK_LIB([dl], [dlopen], [have_libdl=yes], [
143+
AC_MSG_ERROR([libdl is required for loading dynamic modules])
144+
])
149145

150146
FEATURE_SYSTEMD_SUPPORT_CHECK
151147
FEATURE_RAPIDHASH_CHECK
@@ -157,13 +153,21 @@ AC_SUBST([ABS_SRCDIR])
157153
AC_SUBST([ABS_BUILDDIR])
158154

159155
# Define macros
156+
case "$host_os" in
157+
darwin*) shared_library_ext="dylib" ;;
158+
cygwin*|mingw*) shared_library_ext="dll" ;;
159+
*) shared_library_ext="so" ;;
160+
esac
161+
162+
AC_DEFINE_UNQUOTED([SHARED_LIBRARY_EXTENSION], ["$shared_library_ext"], [The extension shared libraries use on this platform])
160163

161164
# Checks for header files.
162165
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/socket.h sys/time.h])
163166
AC_CHECK_HEADERS([stdnoreturn.h])
164167

165168
# Checks for typedefs, structures, and compiler characteristics.
166-
STDC_CHECK_VLA_SUPPORT
169+
CC_CHECK_VLA_SUPPORT
170+
CCLD_CHECK_RDYNAMIC_SUPPORT
167171

168172
AC_CHECK_HEADER_STDBOOL
169173
AC_TYPE_OFF_T
@@ -188,10 +192,6 @@ AC_FUNC_STRTOD
188192
AC_CHECK_FUNCS([atexit clock_gettime gettimeofday memchr memmove memset socket strcasecmp strdup strerror strndup strrchr strtoull])
189193
AC_CHECK_FUNCS([realpath strchr strncasecmp strtoul getopt_long])
190194

191-
AC_CHECK_LIB([dl], [dlopen], [have_libdl=yes], [
192-
AC_MSG_ERROR([libdl is required for loading dynamic modules])
193-
])
194-
195195
# Enable modules
196196
m4_foreach([name], [AVAILABLE_MODULES], [
197197
AM_CONDITIONAL([ENABLE_MOD_]m4_toupper(name), [test "x$enable_mod_]name[" = "xyes" || test "x$enable_mod_all" = "xyes"])

m4/compiler.m4

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
AC_DEFUN([STDC_CHECK_VLA_SUPPORT], [
1+
# -*- Autoconf -*-
2+
3+
AC_DEFUN([CC_CHECK_VLA_SUPPORT], [
24
AC_MSG_CHECKING([whether $CC supports VLAs])
35
46
AC_COMPILE_IFELSE(
@@ -16,3 +18,28 @@ AC_DEFUN([STDC_CHECK_VLA_SUPPORT], [
1618
]
1719
)
1820
])
21+
22+
AC_DEFUN([CCLD_CHECK_RDYNAMIC_SUPPORT], [
23+
AC_MSG_CHECKING([whether $LD supports -rdynamic])
24+
25+
prev_ldflags="$LDFLAGS"
26+
LDFLAGS="$LDFLAGS -rdynamic"
27+
28+
AC_LINK_IFELSE(
29+
[AC_LANG_PROGRAM(
30+
[[
31+
#include <stdio.h>
32+
]],
33+
[[
34+
puts ("Hello world");
35+
]]
36+
)],
37+
[AC_MSG_RESULT([yes])],
38+
[
39+
AC_MSG_RESULT([no])
40+
AC_MSG_ERROR([The linker $LD does not support -rdynamic])
41+
]
42+
)
43+
44+
LDFLAGS="$prev_ldflags"
45+
])

0 commit comments

Comments
 (0)