summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-10-07 20:28:10 +0200
committerHaru <haru@dotalux.com>2013-10-07 20:36:15 +0200
commit7af7a4c14ee2f8455fef66ad638d0954410dea4e (patch)
tree3ee468cd2a81a2d7fb3dbf05af76842a3c8b3876
parent95caa2458c92c04c479e0dce18aaeb1e8846c214 (diff)
downloadhercules-7af7a4c14ee2f8455fef66ad638d0954410dea4e.tar.gz
hercules-7af7a4c14ee2f8455fef66ad638d0954410dea4e.tar.bz2
hercules-7af7a4c14ee2f8455fef66ad638d0954410dea4e.tar.xz
hercules-7af7a4c14ee2f8455fef66ad638d0954410dea4e.zip
Ensured explicit check for undefined references on shared objects
- On certain platforms, shared objects will be built without linker errors even if they have undefined references (but they'll fail to load if those references can't be found at runtime). - This resolves issues with plugins that on linux seem to compile, but won't load (or will lead completely unpredictable results) because they use symbols that may not exist. Special thanks to oss10110 for bringing it up. Signed-off-by: Haru <haru@dotalux.com>
-rwxr-xr-xconfigure138
-rw-r--r--configure.in121
2 files changed, 180 insertions, 79 deletions
diff --git a/configure b/configure
index 712fe8dfc..17a84e1ff 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in c1dca64.
+# From configure.in 95caa24.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69.
#
@@ -5003,6 +5003,7 @@ CFLAGS="$OLD_CFLAGS"
$as_echo_n "checking how to make shared objects... " >&6; }
OLD_CFLAGS="$CFLAGS"
compiler_shared_objects=""
+compiler_supports_shared_objects="no"
if test "$compiler_supports_pic" = "yes" ; then
my_shared_test_flags="$CFLAGS -fPIC"
fi
@@ -5022,6 +5023,7 @@ _ACEOF
if ac_fn_c_try_link "$LINENO"; then :
compiler_shared_objects="-shared"
+ compiler_supports_shared_objects="yes"
fi
@@ -5043,12 +5045,12 @@ _ACEOF
if ac_fn_c_try_link "$LINENO"; then :
compiler_shared_objects="-nostart"
+ compiler_supports_shared_objects="yes"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-my_shared_test_flags=""
CFLAGS="$OLD_CFLAGS"
if test "$compiler_supports_shared_objects" = "no" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
@@ -5057,77 +5059,134 @@ $as_echo "not supported" >&6; }
$as_echo "$as_me: compiler is unable to generate shared objects, disabled plugins (optional)" >&6;}
WITH_PLUGINS="no"
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $compiler_shared_objects" >&5
-$as_echo "$compiler_shared_objects" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $compiler_shared_objects $compiler_supports_shared_objects" >&5
+$as_echo "$compiler_shared_objects $compiler_supports_shared_objects" >&6; }
SOFLAGS="$SOFLAGS $compiler_shared_objects"
-#
-# shared objects need position independent code; some platforms emit
-# it always, others need -fPIC
-#
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -fPIC for shared objects" >&5
+ #
+ # On certain platforms, undefined references on shared libraries won't be checked
+ # unless explicitly required with the --no-undefined linker option
+ #
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -Wl,--no-undefined to check for undefined references in shared objects" >&5
+$as_echo_n "checking whether $CC needs -Wl,--no-undefined to check for undefined references in shared objects... " >&6; }
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$SOFLAGS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ void foo(void) {
+ foobar();
+ }
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+ CFLAGS="$SOFLAGS -Wl,--no-undefined"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ int bar = 0;
+
+ int foo(void) {
+ return bar;
+ }
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ SOFLAGS="$SOFLAGS -Wl,--no-undefined"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported (undefined references check will be ignored)" >&5
+$as_echo "unsupported (undefined references check will be ignored)" >&6; }
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ CFLAGS="$OLD_CFLAGS"
+
+ #
+ # shared objects need position independent code; some platforms emit
+ # it always, others need -fPIC
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -fPIC for shared objects" >&5
$as_echo_n "checking whether $CC needs -fPIC for shared objects... " >&6; }
-OLD_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS $SOFLAGS"
-WITH_PLUGINS="yes"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $SOFLAGS"
+ WITH_PLUGINS="yes"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
- int bar = 0;
+ int bar = 0;
- int foo(void)
- {
- return bar;
- }
+ int foo(void)
+ {
+ return bar;
+ }
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- CFLAGS="$OLD_CFLAGS"
+ CFLAGS="$OLD_CFLAGS"
else
- if test "$compiler_supports_pic" = "yes" ; then
- # Verify if -shared really fails due to lack of -fPIC or something else
- CFLAGS="$CFLAGS -fPIC"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ if test "$compiler_supports_pic" = "yes" ; then
+ # Verify if -shared really fails due to lack of -fPIC or something else
+ CFLAGS="$CFLAGS -fPIC"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
- int bar = 0;
+ int bar = 0;
- int foo(void)
- {
- return bar;
- }
+ int foo(void)
+ {
+ return bar;
+ }
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- CFLAGS="$OLD_CFLAGS -fPIC"
+ CFLAGS="$OLD_CFLAGS -fPIC"
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, but fails for another reason" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, but fails for another reason" >&5
$as_echo "no, but fails for another reason" >&6; }
- as_fn_error $? "compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping" "$LINENO" 5
+ as_fn_error $? "compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping" "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- else
- # Disable compilation of plugins (optional), so 'make all' does not fail
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, but unsupported" >&5
+ else
+ # Disable compilation of plugins (optional), so 'make all' does not fail
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, but unsupported" >&5
$as_echo "yes, but unsupported" >&6; }
- { $as_echo "$as_me:${as_lineno-$LINENO}: compiler is unable to generate position independent code, disabled plugins (optional)" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: compiler is unable to generate position independent code, disabled plugins (optional)" >&5
$as_echo "$as_me: compiler is unable to generate position independent code, disabled plugins (optional)" >&6;}
- WITH_PLUGINS="no"
- fi
+ WITH_PLUGINS="no"
+ fi
fi
@@ -5135,6 +5194,7 @@ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
+my_shared_test_flags=""
diff --git a/configure.in b/configure.in
index d9353f51c..486390eaa 100644
--- a/configure.in
+++ b/configure.in
@@ -550,6 +550,7 @@ CFLAGS="$OLD_CFLAGS"
AC_MSG_CHECKING([how to make shared objects])
OLD_CFLAGS="$CFLAGS"
compiler_shared_objects=""
+compiler_supports_shared_objects="no"
if test "$compiler_supports_pic" = "yes" ; then
my_shared_test_flags="$CFLAGS -fPIC"
fi
@@ -566,6 +567,7 @@ AC_LINK_IFELSE(
])],
[
compiler_shared_objects="-shared"
+ compiler_supports_shared_objects="yes"
]
)
# BeOS specific
@@ -581,72 +583,111 @@ AC_LINK_IFELSE(
])],
[
compiler_shared_objects="-nostart"
+ compiler_supports_shared_objects="yes"
]
)
-my_shared_test_flags=""
CFLAGS="$OLD_CFLAGS"
if test "$compiler_supports_shared_objects" = "no" ; then
AC_MSG_RESULT([not supported])
AC_MSG_NOTICE([compiler is unable to generate shared objects, disabled plugins (optional)])
WITH_PLUGINS="no"
else
- AC_MSG_RESULT([$compiler_shared_objects])
+ AC_MSG_RESULT([$compiler_shared_objects $compiler_supports_shared_objects])
SOFLAGS="$SOFLAGS $compiler_shared_objects"
AC_SUBST([SOFLAGS])
-#
-# shared objects need position independent code; some platforms emit
-# it always, others need -fPIC
-#
-AC_MSG_CHECKING([whether $CC needs -fPIC for shared objects])
-OLD_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS $SOFLAGS"
-WITH_PLUGINS="yes"
-AC_LINK_IFELSE(
- [AC_LANG_SOURCE([
- int bar = 0;
-
- int foo(void)
- {
- return bar;
- }
- ])],
- [
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
- ],
- [
- if test "$compiler_supports_pic" = "yes" ; then
- # Verify if -shared really fails due to lack of -fPIC or something else
- CFLAGS="$CFLAGS -fPIC"
+ #
+ # On certain platforms, undefined references on shared libraries won't be checked
+ # unless explicitly required with the --no-undefined linker option
+ #
+ AC_MSG_CHECKING([whether $CC needs -Wl,--no-undefined to check for undefined references in shared objects])
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$SOFLAGS"
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE([
+ void foo(void) {
+ foobar();
+ }
+ ])],
+ [
+ CFLAGS="$SOFLAGS -Wl,--no-undefined"
AC_LINK_IFELSE(
[AC_LANG_SOURCE([
int bar = 0;
- int foo(void)
- {
+ int foo(void) {
return bar;
}
])],
[
AC_MSG_RESULT([yes])
- CFLAGS="$OLD_CFLAGS -fPIC"
+ SOFLAGS="$SOFLAGS -Wl,--no-undefined"
],
[
- AC_MSG_RESULT([no, but fails for another reason])
- AC_MSG_ERROR([compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping])
+ AC_MSG_RESULT([unsupported (undefined references check will be ignored)])
]
)
- else
- # Disable compilation of plugins (optional), so 'make all' does not fail
- AC_MSG_RESULT([yes, but unsupported])
- AC_MSG_NOTICE([compiler is unable to generate position independent code, disabled plugins (optional)])
- WITH_PLUGINS="no"
- fi
- ]
-)
+ ],
+ [
+ AC_MSG_RESULT([no])
+ ]
+ )
+ CFLAGS="$OLD_CFLAGS"
+
+ #
+ # shared objects need position independent code; some platforms emit
+ # it always, others need -fPIC
+ #
+ AC_MSG_CHECKING([whether $CC needs -fPIC for shared objects])
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $SOFLAGS"
+ WITH_PLUGINS="yes"
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE([
+ int bar = 0;
+
+ int foo(void)
+ {
+ return bar;
+ }
+ ])],
+ [
+ AC_MSG_RESULT([no])
+ CFLAGS="$OLD_CFLAGS"
+ ],
+ [
+ if test "$compiler_supports_pic" = "yes" ; then
+ # Verify if -shared really fails due to lack of -fPIC or something else
+ CFLAGS="$CFLAGS -fPIC"
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE([
+ int bar = 0;
+
+ int foo(void)
+ {
+ return bar;
+ }
+ ])],
+ [
+ AC_MSG_RESULT([yes])
+ CFLAGS="$OLD_CFLAGS -fPIC"
+ ],
+ [
+ AC_MSG_RESULT([no, but fails for another reason])
+ AC_MSG_ERROR([compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping])
+ ]
+ )
+ else
+ # Disable compilation of plugins (optional), so 'make all' does not fail
+ AC_MSG_RESULT([yes, but unsupported])
+ AC_MSG_NOTICE([compiler is unable to generate position independent code, disabled plugins (optional)])
+ WITH_PLUGINS="no"
+ fi
+ ]
+ )
fi
+my_shared_test_flags=""
AC_SUBST([WITH_PLUGINS])