summaryrefslogtreecommitdiff
path: root/configure.in
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 /configure.in
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>
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in121
1 files changed, 81 insertions, 40 deletions
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])