Do not default to static linking for libstdc++ 93/17393/2
Clément DAVID [Mon, 26 Oct 2015 08:16:26 +0000 (09:16 +0100)]
1. dlopen-ed C++ library might not work
2. People using older libstdc++ / glibc can easily preload a backported
   version at Scilab startup
3. The compilation chain now targets an old glibc / libstdc++ (RHEL 5)

In depth, rationale :
http://www.trilithium.com/johan/2005/06/static-libstdc/

Change-Id: I22b15d791e945a04879dc6f4737310f2849e960e

scilab/Makefile.am
scilab/Makefile.in
scilab/aclocal.m4
scilab/configure
scilab/configure.ac
scilab/m4/compiler.m4
scilab/modules/slint/Makefile.in

index 895380f..db4e121 100644 (file)
@@ -38,7 +38,7 @@ if IS_MACOSX
 bin_SCRIPTS            += bin/checkmacosx.applescript
 endif
 
-scilab_bin_LDFLAGS         = $(AM_LDFLAGS) $(OPENMPI_LIBS)
+scilab_bin_LDFLAGS      = $(AM_LDFLAGS) $(OPENMPI_LIBS)
 scilab_cli_bin_LDFLAGS  = $(AM_LDFLAGS) $(OPENMPI_LIBS)
 
 #
@@ -47,16 +47,12 @@ scilab_cli_bin_LDFLAGS  = $(AM_LDFLAGS) $(OPENMPI_LIBS)
 # solution for now.
 #
 if USE_STATIC_SYSTEM_LIB
-scilab_bin_LDFLAGS += -static-libstdc++ -static-libgcc
-# -static-libgfortran
-scilab_cli_bin_LDFLAGS += -static-libstdc++ -static-libgcc
-#-static-libgfortran
+scilab_bin_LDFLAGS += -static-libstdc++ -static-libgcc -static-libgfortran
+scilab_cli_bin_LDFLAGS += -static-libstdc++ -static-libgcc -static-libgfortran
 else
 # Clang (for example) needs an explicit reference to the lib
-scilab_bin_LDFLAGS += -lstdc++
-# -static-libgfortran
-scilab_cli_bin_LDFLAGS += -lstdc++
-#-static-libgfortran
+scilab_bin_LDFLAGS += -lstdc++ -lgfortran
+scilab_cli_bin_LDFLAGS += -lstdc++ -lgfortran
 endif
 
 
index bb0ae97..930deb1 100644 (file)
@@ -121,15 +121,11 @@ bin_PROGRAMS = scilab-bin$(EXEEXT) scilab-cli-bin$(EXEEXT)
 # std::nothrow for instance) but it seems to be the only acceptable
 # solution for now.
 #
-@USE_STATIC_SYSTEM_LIB_TRUE@am__append_2 = -static-libstdc++ -static-libgcc
-# -static-libgfortran
-@USE_STATIC_SYSTEM_LIB_TRUE@am__append_3 = -static-libstdc++ -static-libgcc
-#-static-libgfortran
+@USE_STATIC_SYSTEM_LIB_TRUE@am__append_2 = -static-libstdc++ -static-libgcc -static-libgfortran
+@USE_STATIC_SYSTEM_LIB_TRUE@am__append_3 = -static-libstdc++ -static-libgcc -static-libgfortran
 # Clang (for example) needs an explicit reference to the lib
-@USE_STATIC_SYSTEM_LIB_FALSE@am__append_4 = -lstdc++
-# -static-libgfortran
-@USE_STATIC_SYSTEM_LIB_FALSE@am__append_5 = -lstdc++
-#-static-libgfortran
+@USE_STATIC_SYSTEM_LIB_FALSE@am__append_4 = -lstdc++ -lgfortran
+@USE_STATIC_SYSTEM_LIB_FALSE@am__append_5 = -lstdc++ -lgfortran
 @IS_MACOSX_TRUE@am__append_6 = -framework Cocoa
 @NEED_JAVA_TRUE@am__append_7 = \
 @NEED_JAVA_TRUE@                       $(top_builddir)/modules/console/libsciconsole.la \
index 6c3e509..78f430f 100644 (file)
@@ -20,7 +20,7 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# gettext.m4 serial 67 (gettext-0.19.6)
+# gettext.m4 serial 66 (gettext-0.18.2)
 dnl Copyright (C) 1995-2014 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -422,10 +422,6 @@ AC_DEFUN([AM_GNU_GETTEXT_NEED],
 dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
 
-
-dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version])
-AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], [])
-
 # iconv.m4 serial 19 (gettext-0.18.2)
 dnl Copyright (C) 2000-2002, 2007-2014 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -756,7 +752,7 @@ AC_DEFUN([gt_INTL_MACOSX],
 ])
 
 # lib-link.m4 serial 26 (gettext-0.18.2)
-dnl Copyright (C) 2001-2015 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2014 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -1534,7 +1530,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
 ])
 
 # lib-prefix.m4 serial 7 (gettext-0.18)
-dnl Copyright (C) 2001-2005, 2008-2015 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2005, 2008-2014 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -2246,7 +2242,7 @@ AC_DEFUN([AM_XGETTEXT_OPTION],
 ])
 
 # progtest.m4 serial 7 (gettext-0.18.2)
-dnl Copyright (C) 1996-2003, 2005, 2008-2015 Free Software Foundation, Inc.
+dnl Copyright (C) 1996-2003, 2005, 2008-2014 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
index 5ce1a71..bbce4ee 100755 (executable)
@@ -1771,8 +1771,8 @@ Optional Features:
   --disable-libtool-lock  avoid locking (might break parallel builds)
   --disable-ccache        Disable the use of ccache
 
-  --disable-static-system-lib
-                          Disable the usage of the static stdc++ and libgcc
+  --enable-static-system-lib
+                          Enable the usage of the static stdc++ and libgcc
                           libs
 
 Optional Packages:
@@ -4397,7 +4397,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                       && LARGE_OFF_T % 2147483647 == 1)
                      ? 1 : -1];
@@ -4443,7 +4443,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                       && LARGE_OFF_T % 2147483647 == 1)
                      ? 1 : -1];
@@ -4467,7 +4467,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                       && LARGE_OFF_T % 2147483647 == 1)
                      ? 1 : -1];
@@ -4512,7 +4512,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                       && LARGE_OFF_T % 2147483647 == 1)
                      ? 1 : -1];
@@ -4536,7 +4536,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                       && LARGE_OFF_T % 2147483647 == 1)
                      ? 1 : -1];
@@ -24052,7 +24052,7 @@ if test "$with_openmp" != no; then
 #   AC_OPENMP
     OPENMP_CFLAGS="-fopenmp"
     OPENMP_CXXFLAGS="-fopenmp"
-    OPENMP_LIBS="-lgomp -lstdc++" # Force -lstdc++ because some compilers do not add it automatically.
+    OPENMP_LIBS="-lgomp"
 
     for ac_header in omp.h
 do :
@@ -43080,9 +43080,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-# Eliminate -lstdc++ addition to postdeps for cross compiles.
-postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ ,,g'`
-
 # Avoid to link all the dep from others libraries (*.la included by LIBADD)
 link_all_deplibs=no
 
 
 
 #########
-## Make sure that the libstdc++ and libgcc can be compiled as static
+## Make sure that the libstdc++ libgcc and libgfortran can be compiled as
+## static if requested
 #########
 
 
-
 # Check whether --enable-static-system-lib was given.
 if test "${enable_static_system_lib+set}" = set; then :
   enableval=$enable_static_system_lib;
 saved_LDFLAGS="$LDFLAGS"
 
 compiler_manage_static_libs=no
-USE_STATIC_SYSTEM_LIB=yes
+USE_STATIC_SYSTEM_LIB=no
 
-
-if test "x$enable_static_system_lib" == "xno"; then
-# The user ask for an explicit disable.
-   USE_STATIC_SYSTEM_LIB=no
+if test "x$enable_static_system_lib" == "xyes"; then
+# The user ask for an explicit enable.
+   USE_STATIC_SYSTEM_LIB=yes
 fi
 
 
@@ -43832,7 +43828,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 LDFLAGS="$saved_LDFLAGS"
-if test "x$compiler_manage_static_libs" == "xno" -a "x$enable_static_system_lib" != "xno"; then
+if test "x$compiler_manage_static_libs" == "xno" -a "x$enable_static_system_lib" == "xyes"; then
    as_fn_error $? "The $CC compiler does not support the options -static-libstdc++/-static-libgcc. Update your compiler or use the option --disable-static-system-lib" "$LINENO" 5
 fi
 
@@ -43866,10 +43862,47 @@ if test "$enable_stop_on_warning" = yes; then
 fi
 
 # SCI_*FLAGS contains all defaults values detected on configure
-SCI_CFLAGS=$(echo                       $LARGEFILE_CFLAGS   $CODECOVERAGE_CFLAGS   $DEBUG_CFLAGS   $ARCH_CFLAGS   $COMPILER_CFLAGS   $SCILIBS_CFLAGS   $SSE_CFLAGS   $BACKTRACE_CFLAGS   $WARNING_CFLAGS)
-SCI_CXXFLAGS=$(echo $STDCXX_11_CXXFLAGS $LARGEFILE_CXXFLAGS $CODECOVERAGE_CXXFLAGS $DEBUG_CXXFLAGS $ARCH_CXXFLAGS $COMPILER_CXXFLAGS $SCILIBS_CXXFLAGS $SSE_CXXFLAGS $BACKTRACE_CXXFLAGS $WARNING_CXXFLAGS)
-SCI_FFLAGS=$(echo                       $LARGEFILE_FFLAGS   $CODECOVERAGE_FFLAGS   $DEBUG_FFLAGS   $ARCH_FFLAGS   $COMPILER_FFLAGS   $SCILIBS_FFLAGS   $SSE_FFLAGS   $BACKTRACE_FFLAGS   $WARNING_FFLAGS)
-SCI_LDFLAGS=$(echo                      $LARGEFILE_LDFLAGS  $CODECOVERAGE_LDFLAGS  $DEBUG_LDFLAGS  $ARCH_LDFLAGS  $COMPILER_LDFLAGS  $SCILIBS_LDFLAGS  $SSE_LDFLAGS  $BACKTRACE_LDFLAGS  $WARNING_LDFLAGS)
+SCI_CFLAGS=$(echo                                             \
+             $LARGEFILE_CFLAGS                                \
+             $CODECOVERAGE_CFLAGS                             \
+             $DEBUG_CFLAGS                                    \
+             $ARCH_CFLAGS                                     \
+             $COMPILER_CFLAGS                                 \
+             $SCILIBS_CFLAGS                                  \
+             $SSE_CFLAGS                                      \
+             $BACKTRACE_CFLAGS                                \
+             $WARNING_CFLAGS                                  )
+SCI_CXXFLAGS=$(echo                                           \
+               $STDCXX_11_CXXFLAGS                            \
+               $LARGEFILE_CXXFLAGS                            \
+               $CODECOVERAGE_CXXFLAGS                         \
+               $DEBUG_CXXFLAGS                                \
+               $ARCH_CXXFLAGS                                 \
+               $COMPILER_CXXFLAGS                             \
+               $SCILIBS_CXXFLAGS                              \
+               $SSE_CXXFLAGS                                  \
+               $BACKTRACE_CXXFLAGS                            \
+               $WARNING_CXXFLAGS                              )
+SCI_FFLAGS=$(echo                                             \
+             $LARGEFILE_FFLAGS                                \
+             $CODECOVERAGE_FFLAGS                             \
+             $DEBUG_FFLAGS                                    \
+             $ARCH_FFLAGS                                     \
+             $COMPILER_FFLAGS                                 \
+             $SCILIBS_FFLAGS                                  \
+             $SSE_FFLAGS                                      \
+             $BACKTRACE_FFLAGS                                \
+             $WARNING_FFLAGS                                  )
+SCI_LDFLAGS=$(echo                                            \
+              $LARGEFILE_LDFLAGS                              \
+              $CODECOVERAGE_LDFLAGS                           \
+              $DEBUG_LDFLAGS                                  \
+              $ARCH_LDFLAGS                                   \
+              $COMPILER_LDFLAGS                               \
+              $SCILIBS_LDFLAGS                                \
+              $SSE_LDFLAGS                                    \
+              $BACKTRACE_LDFLAGS                              \
+              $WARNING_LDFLAGS                                )
 
 
 
index d3dd9a6..dee43ac 100644 (file)
@@ -1481,7 +1481,7 @@ if test "$with_openmp" != no; then
 #   AC_OPENMP
     OPENMP_CFLAGS="-fopenmp"
     OPENMP_CXXFLAGS="-fopenmp"
-    OPENMP_LIBS="-lgomp -lstdc++" # Force -lstdc++ because some compilers do not add it automatically.
+    OPENMP_LIBS="-lgomp" 
 
     AC_CHECK_HEADERS([omp.h], [],
      [AC_MSG_ERROR([Could not find omp.h])])
@@ -1849,9 +1849,6 @@ AC_SUBST(GRAPHICS_ENABLE)
 LT_PREREQ([2.2.7])
 LT_INIT([shared dlopen disable-static])
 
-# Eliminate -lstdc++ addition to postdeps for cross compiles.
-postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ ,,g'`
-
 # Avoid to link all the dep from others libraries (*.la included by LIBADD)
 link_all_deplibs=no
 
@@ -1949,9 +1946,9 @@ fi
 
 
 #########
-## Make sure that the libstdc++ and libgcc can be compiled as static
+## Make sure that the libstdc++ libgcc and libgfortran can be compiled as 
+## static if requested
 #########
-
 AC_CHECK_STDCPP_STATIC()
 
 #################
@@ -1968,10 +1965,47 @@ if test "$enable_stop_on_warning" = yes; then
 fi
 
 # SCI_*FLAGS contains all defaults values detected on configure
-SCI_CFLAGS=$(echo                       $LARGEFILE_CFLAGS   $CODECOVERAGE_CFLAGS   $DEBUG_CFLAGS   $ARCH_CFLAGS   $COMPILER_CFLAGS   $SCILIBS_CFLAGS   $SSE_CFLAGS   $BACKTRACE_CFLAGS   $WARNING_CFLAGS)
-SCI_CXXFLAGS=$(echo $STDCXX_11_CXXFLAGS $LARGEFILE_CXXFLAGS $CODECOVERAGE_CXXFLAGS $DEBUG_CXXFLAGS $ARCH_CXXFLAGS $COMPILER_CXXFLAGS $SCILIBS_CXXFLAGS $SSE_CXXFLAGS $BACKTRACE_CXXFLAGS $WARNING_CXXFLAGS)
-SCI_FFLAGS=$(echo                       $LARGEFILE_FFLAGS   $CODECOVERAGE_FFLAGS   $DEBUG_FFLAGS   $ARCH_FFLAGS   $COMPILER_FFLAGS   $SCILIBS_FFLAGS   $SSE_FFLAGS   $BACKTRACE_FFLAGS   $WARNING_FFLAGS)
-SCI_LDFLAGS=$(echo                      $LARGEFILE_LDFLAGS  $CODECOVERAGE_LDFLAGS  $DEBUG_LDFLAGS  $ARCH_LDFLAGS  $COMPILER_LDFLAGS  $SCILIBS_LDFLAGS  $SSE_LDFLAGS  $BACKTRACE_LDFLAGS  $WARNING_LDFLAGS)
+SCI_CFLAGS=$(echo                                             \
+             $LARGEFILE_CFLAGS                                \
+             $CODECOVERAGE_CFLAGS                             \
+             $DEBUG_CFLAGS                                    \
+             $ARCH_CFLAGS                                     \
+             $COMPILER_CFLAGS                                 \
+             $SCILIBS_CFLAGS                                  \
+             $SSE_CFLAGS                                      \
+             $BACKTRACE_CFLAGS                                \
+             $WARNING_CFLAGS                                  )
+SCI_CXXFLAGS=$(echo                                           \
+               $STDCXX_11_CXXFLAGS                            \
+               $LARGEFILE_CXXFLAGS                            \
+               $CODECOVERAGE_CXXFLAGS                         \
+               $DEBUG_CXXFLAGS                                \
+               $ARCH_CXXFLAGS                                 \
+               $COMPILER_CXXFLAGS                             \
+               $SCILIBS_CXXFLAGS                              \
+               $SSE_CXXFLAGS                                  \
+               $BACKTRACE_CXXFLAGS                            \
+               $WARNING_CXXFLAGS                              )
+SCI_FFLAGS=$(echo                                             \
+             $LARGEFILE_FFLAGS                                \
+             $CODECOVERAGE_FFLAGS                             \
+             $DEBUG_FFLAGS                                    \
+             $ARCH_FFLAGS                                     \
+             $COMPILER_FFLAGS                                 \
+             $SCILIBS_FFLAGS                                  \
+             $SSE_FFLAGS                                      \
+             $BACKTRACE_FFLAGS                                \
+             $WARNING_FFLAGS                                  )
+SCI_LDFLAGS=$(echo                                            \
+              $LARGEFILE_LDFLAGS                              \
+              $CODECOVERAGE_LDFLAGS                           \
+              $DEBUG_LDFLAGS                                  \
+              $ARCH_LDFLAGS                                   \
+              $COMPILER_LDFLAGS                               \
+              $SCILIBS_LDFLAGS                                \
+              $SSE_LDFLAGS                                    \
+              $BACKTRACE_LDFLAGS                              \
+              $WARNING_LDFLAGS                                )
 AC_SUBST(SCI_CFLAGS)
 AC_SUBST(SCI_CXXFLAGS)
 AC_SUBST(SCI_FFLAGS)
index bf7de57..a7a536a 100644 (file)
@@ -31,18 +31,18 @@ AC_DEFUN([CHECK_COMPILER_ARG],[
 AC_DEFUN([AC_CHECK_STDCPP_STATIC],[
 
 AC_ARG_ENABLE(static-system-lib,
-    AC_HELP_STRING([--disable-static-system-lib],[Disable the usage of the static stdc++ and libgcc libs]))
+    AC_HELP_STRING([--enable-static-system-lib],[Enable the usage of the static stdc++ and libgcc libs]),
+)
 
 # Check if -static-libstdc++ and -static-libgcc are supported.
 saved_LDFLAGS="$LDFLAGS"
 
 compiler_manage_static_libs=no
-USE_STATIC_SYSTEM_LIB=yes
+USE_STATIC_SYSTEM_LIB=no
 
-
-if test "x$enable_static_system_lib" == "xno"; then
-# The user ask for an explicit disable.
-   USE_STATIC_SYSTEM_LIB=no
+if test "x$enable_static_system_lib" == "xyes"; then
+# The user ask for an explicit enable.
+   USE_STATIC_SYSTEM_LIB=yes
 fi
 
 
@@ -59,7 +59,7 @@ int main() {return 0;}])],
 AC_LANG_POP(C++)
 
 LDFLAGS="$saved_LDFLAGS"
-if test "x$compiler_manage_static_libs" == "xno" -a "x$enable_static_system_lib" != "xno"; then
+if test "x$compiler_manage_static_libs" == "xno" -a "x$enable_static_system_lib" == "xyes"; then
    AC_MSG_ERROR([The $CC compiler does not support the options -static-libstdc++/-static-libgcc. Update your compiler or use the option --disable-static-system-lib])
 fi
 
index e30feef..4f935f6 100644 (file)
@@ -581,7 +581,6 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
-runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@