Преглед на файлове

Merge branch 'maint'

* maint:
  Switch to using CXX_FLAG_CHECK for -fcolor-diagnostics [clang]
  Only enable -fstack-protector if compiler supports it
  Add CXX_FLAG_CHECK to detect compiler support for various flags
  Regen after removing std_arg.h
  Remove MAKEJOBS as it breaks job control
  Show missing symbol errors in stderr on startup
  Also detect missing symbols in libssl and libtcl
  Fix startup crash when libcrypto symbols are missing
  Note fixed build in UPDATES
Bryan Drewery преди 12 години
родител
ревизия
2d20eadf96
променени са 11 файла, в които са добавени 147 реда и са изтрити 70 реда
  1. 2 2
      Makefile.in
  2. 4 4
      build/autotools/configure.ac
  3. 30 30
      build/autotools/includes/acinclude.m4
  4. 0 3
      build/autotools/includes/depend.m4
  5. 95 24
      configure
  6. 3 0
      doc/UPDATES
  7. 0 3
      src/config.h.in
  8. 1 1
      src/dl.h
  9. 4 1
      src/libcrypto.c
  10. 4 1
      src/libssl.c
  11. 4 1
      src/libtcl.c

+ 2 - 2
Makefile.in

@@ -42,7 +42,7 @@ DIFF = @DIFF@
 LIBS = @LIBS@
 INCLUDES = @TCL_INCLUDES@
 
-DEBCXXFLAGS = -DDEBUG -fno-inline -g3 -ggdb3 -O0 -Wshadow -Wpointer-arith -Wcast-align @GCC3DEB@ @GCC4DEB@
+DEBCXXFLAGS = -DDEBUG -fno-inline -g3 -ggdb3 -O0 -Wshadow -Wpointer-arith -Wcast-align @GCC3DEB@ @GCC4DEB@ @DEBCXXFLAGS@
 CFLGS = @GCC3@ -fno-rtti @SSL_INCLUDES@
 _CFLGS = -fno-strict-aliasing -W -Wformat \
 #-Wshadow -Wnested-externs -Wno-format-y2k \
@@ -56,7 +56,7 @@ _CFLGS = -fno-strict-aliasing -W -Wformat \
 #-Wconversion
 #-Wtraditional
 
-MAKEFLAGS = -s @MAKEJOBS@
+MAKEFLAGS = -s
 
 STRINGFIX = src/stringfix
 

+ 4 - 4
build/autotools/configure.ac

@@ -30,7 +30,8 @@ AC_CACHE_SAVE
 # Speedup compile
 EGG_CHECK_CCWALL
 EGG_CHECK_CCPIPE
-CHECK_CC_COLOR_DIAGNOSTICS
+CXX_FLAG_CHECK([CXXFLAGS], [-fcolor-diagnostics], [colordiagnostics])
+CXX_FLAG_CHECK([DEBCXXFLAGS], [-fstack-protector-all], [stackprotector])
 
 EGG_CHECK_DEPMODE
 
@@ -64,8 +65,7 @@ EGG_CHECK_RANDOM_MAX
 # Create static binaries
 EGG_CHECK_CCSTATIC
 AC_SUBST(CCDEBUG)dnl
-
-AC_SUBST(MAKEJOBS)dnl
+AC_SUBST(DEBCXXFLAGS)
 
 #checkpoint
 AC_CACHE_SAVE 
@@ -263,4 +263,4 @@ fi
 echo ""
 echo ""
 echo "------------ Configuring BDLIB ------------"
-test -f lib/bdlib/configure && cd lib/bdlib && CXX="$CXX" MAKEJOBS="$MAKEJOBS" ./configure
+test -f lib/bdlib/configure && cd lib/bdlib && CXX="$CXX" ./configure

+ 30 - 30
build/autotools/includes/acinclude.m4

@@ -181,6 +181,36 @@ AC_DEFUN([EGG_CHECK_CCWALL],
   fi
 ])
 
+dnl @synopsis CXX_FLAGS_CHECK [var] [compiler flags] [cache name] [required]
+dnl @summary check whether compiler supports given C++ flags or not
+AC_DEFUN([CXX_FLAG_CHECK],
+[
+  AC_CACHE_CHECK([whether the compiler understands $2], egg_cv_prog_cc_$3, [
+    AC_LANG_PUSH([C++])
+    ac_saved_flags="$CXXFLAGS"
+    CXXFLAGS="-Werror $2"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+      [egg_cv_prog_cc_$3="yes"],
+      [egg_cv_prog_cc_$3="no"],
+    )
+    CXXFLAGS="$ac_saved_flags"
+    AC_LANG_POP([C++])
+  ])
+
+  if [[ "$egg_cv_prog_cc_$3" = "yes" ]]; then
+    $1="$$1 $2"
+  elif [[ -n "$4" ]]; then
+      cat << 'EOF' >&2
+configure: error:
+
+  Your OS or C++ compiler does not support $2.
+  This compile flag is required.
+
+EOF
+    exit 1
+  fi
+])
+
 dnl  EGG_CHECK_CCSTATIC()
 dnl
 dnl  Checks whether the compiler supports the `-static' flag.
@@ -213,36 +243,6 @@ fi
 AC_SUBST(STATIC)dnl
 ])
 
-dnl CHECK_CC_COLOR_DIAGNOSTICS()
-dnl
-dnl See if the compiler supports -fcolor-diagnostics (Clang).
-dnl
-AC_DEFUN([CHECK_CC_COLOR_DIAGNOSTICS],
-[
-  if test -n "$GXX" && test -z "$no_color_diagnostics"; then
-    AC_CACHE_CHECK([whether the compiler understands -fcolor-diagnostics], egg_cv_var_cc_color_diagnostics, [
-      ac_old_CXXFLAGS="$CXXFLAGS"
-      CXXFLAGS="$CXXFLAGS -fcolor-diagnostics"
-       AC_COMPILE_IFELSE([AC_LANG_SOURCE([
-         int main ()
-         {
-           return(0);
-         }
-       ])], [
-         egg_cv_var_cc_color_diagnostics="yes"
-       ], [
-         egg_cv_var_cc_color_diagnostics="no"
-       ])
-      CXXFLAGS="$ac_old_CXXFLAGS"
-    ])
-
-    if test "$egg_cv_var_cc_color_diagnostics" = "yes"; then
-      CXXFLAGS="$CXXFLAGS -fcolor-diagnostics"
-    fi
-  fi
-])
-
-
 dnl EGG_PROG_HEAD_1()
 dnl
 AC_DEFUN([EGG_PROG_HEAD_1],

+ 0 - 3
build/autotools/includes/depend.m4

@@ -14,9 +14,6 @@ if test $num -ge "3"; then
   GCC3="-W -Wno-unused-parameter -Wdisabled-optimization -Wno-write-strings -Wno-format-security -fno-strict-aliasing -Woverloaded-virtual -Wno-format-y2k"
   GCC3DEB="-Wno-disabled-optimization -Wmissing-format-attribute"
 fi
-if test $num -ge "4"; then
-  GCC4DEB="-fstack-protector-all"
-fi
 AC_SUBST(CCDEPMODE)dnl
 AC_SUBST(GCC3)dnl
 AC_SUBST(GCC3DEB)dnl

+ 95 - 24
configure

@@ -639,7 +639,7 @@ TCLLIBFN
 TCLLIB
 SSL_LIBS
 SSL_INCLUDES
-MAKEJOBS
+DEBCXXFLAGS
 CCDEBUG
 STATIC
 BUILDARCH
@@ -3680,43 +3680,117 @@ $as_echo "$egg_cv_var_ccpipe" >&6; }
   fi
 
 
-  if test -n "$GXX" && test -z "$no_color_diagnostics"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler understands -fcolor-diagnostics" >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler understands -fcolor-diagnostics" >&5
 $as_echo_n "checking whether the compiler understands -fcolor-diagnostics... " >&6; }
-if ${egg_cv_var_cc_color_diagnostics+:} false; then :
+if ${egg_cv_prog_cc_colordiagnostics+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
-      ac_old_CXXFLAGS="$CXXFLAGS"
-      CXXFLAGS="$CXXFLAGS -fcolor-diagnostics"
-       cat build/confdefs.h - <<_ACEOF >conftest.$ac_ext
+    ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+    ac_saved_flags="$CXXFLAGS"
+    CXXFLAGS="-Werror -fcolor-diagnostics"
+    cat build/confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end build/confdefs.h.  */
 
-         int main ()
-         {
-           return(0);
-         }
+int
+main ()
+{
 
+  ;
+  return 0;
+}
 _ACEOF
 if ac_fn_cxx_try_compile "$LINENO"; then :
+  egg_cv_prog_cc_colordiagnostics="yes"
+else
+  egg_cv_prog_cc_colordiagnostics="no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    CXXFLAGS="$ac_saved_flags"
+    ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $egg_cv_prog_cc_colordiagnostics" >&5
+$as_echo "$egg_cv_prog_cc_colordiagnostics" >&6; }
+
+  if [ "$egg_cv_prog_cc_colordiagnostics" = "yes" ]; then
+    CXXFLAGS="$CXXFLAGS -fcolor-diagnostics"
+  elif [ -n "" ]; then
+      cat << 'EOF' >&2
+configure: error:
+
+  Your OS or C++ compiler does not support -fcolor-diagnostics.
+  This compile flag is required.
+
+EOF
+    exit 1
+  fi
 
-         egg_cv_var_cc_color_diagnostics="yes"
 
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler understands -fstack-protector-all" >&5
+$as_echo_n "checking whether the compiler understands -fstack-protector-all... " >&6; }
+if ${egg_cv_prog_cc_stackprotector+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
 
-         egg_cv_var_cc_color_diagnostics="no"
+    ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
+    ac_saved_flags="$CXXFLAGS"
+    CXXFLAGS="-Werror -fstack-protector-all"
+    cat build/confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end build/confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  egg_cv_prog_cc_stackprotector="yes"
+else
+  egg_cv_prog_cc_stackprotector="no"
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-      CXXFLAGS="$ac_old_CXXFLAGS"
+    CXXFLAGS="$ac_saved_flags"
+    ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $egg_cv_var_cc_color_diagnostics" >&5
-$as_echo "$egg_cv_var_cc_color_diagnostics" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $egg_cv_prog_cc_stackprotector" >&5
+$as_echo "$egg_cv_prog_cc_stackprotector" >&6; }
 
-    if test "$egg_cv_var_cc_color_diagnostics" = "yes"; then
-      CXXFLAGS="$CXXFLAGS -fcolor-diagnostics"
-    fi
+  if [ "$egg_cv_prog_cc_stackprotector" = "yes" ]; then
+    DEBCXXFLAGS="$DEBCXXFLAGS -fstack-protector-all"
+  elif [ -n "" ]; then
+      cat << 'EOF' >&2
+configure: error:
+
+  Your OS or C++ compiler does not support -fstack-protector-all.
+  This compile flag is required.
+
+EOF
+    exit 1
   fi
 
 
@@ -3729,9 +3803,6 @@ if test $num -ge "3"; then
   GCC3="-W -Wno-unused-parameter -Wdisabled-optimization -Wno-write-strings -Wno-format-security -fno-strict-aliasing -Woverloaded-virtual -Wno-format-y2k"
   GCC3DEB="-Wno-disabled-optimization -Wmissing-format-attribute"
 fi
-if test $num -ge "4"; then
-  GCC4DEB="-fstack-protector-all"
-fi
 
 
 #checkpoint
@@ -5273,7 +5344,7 @@ $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
   fi
 fi
 rm -f confcache
-for ac_header in stdarg.h std_arg.h arpa/inet.h fcntl.h limits.h locale.h netdb.h netinet/in.h
+for ac_header in stdarg.h arpa/inet.h fcntl.h limits.h locale.h netdb.h netinet/in.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -9995,4 +10066,4 @@ fi
 echo ""
 echo ""
 echo "------------ Configuring BDLIB ------------"
-test -f lib/bdlib/configure && cd lib/bdlib && CXX="$CXX" MAKEJOBS="$MAKEJOBS" ./configure
+test -f lib/bdlib/configure && cd lib/bdlib && CXX="$CXX" ./configure

+ 3 - 0
doc/UPDATES

@@ -4,6 +4,9 @@ maint
   * Fix cmd_slowjoin eating the first channel option (This fixes groups support)
   * Fix help for 'topic' to show optional channel argument
   * Fix cmd_hublevel not properly requiring a hublevel argument
+  * Fix build with clang (FreeBSD 10)
+  * Fix startup crash when some shared library symbols were missing
+  * Fix build on systems without working libssp
 
 1.4.3
   * Default 'set promisc' to ignore since it's usually a false positive

+ 0 - 3
src/config.h.in

@@ -151,9 +151,6 @@
 /* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
-/* Define to 1 if you have the <std_arg.h> header file. */
-#undef HAVE_STD_ARG_H
-
 /* Define to 1 if you have the `strcasecmp' function. */
 #undef HAVE_STRCASECMP
 

+ 1 - 1
src/dl.h

@@ -23,7 +23,7 @@
   my_symbols << #x; \
   dlsym_error = dlerror(); \
   if (dlsym_error) { \
-    sdprintf("%s", dlsym_error); \
+    fprintf(stderr, "%s", dlsym_error); \
     return(1); \
   } \
 } while (0)

+ 4 - 1
src/libcrypto.c

@@ -111,7 +111,10 @@ int load_libcrypto() {
     return(1);
   }
 
-  load_symbols(libcrypto_handle);
+  if (load_symbols(libcrypto_handle)) {
+    fprintf(stderr, STR("Missing symbols for libcrypto (likely too old)\n"));
+    return(1);
+  }
 
   return 0;
 }

+ 4 - 1
src/libssl.c

@@ -84,7 +84,10 @@ int load_libssl() {
     return(1);
   }
 
-  load_symbols(libssl_handle);
+  if (load_symbols(libssl_handle)) {
+    fprintf(stderr, STR("Missing symbols for libssl (likely too old)\n"));
+    return(1);
+  }
 
   return 0;
 }

+ 4 - 1
src/libtcl.c

@@ -81,7 +81,10 @@ int load_libtcl() {
     return 1;
   }
 
-  load_symbols(libtcl_handle);
+  if (load_symbols(libtcl_handle)) {
+    fprintf(stderr, STR("Missing symbols for libtcl (likely too old)\n"));
+    return(1);
+  }
 
 #ifdef USE_SCRIPT_TCL
   // create interp