Browse Source

Merge branch 'gcc-rpath' into maint

* gcc-rpath:
  Only add -rpath if it is really needed.
  Fix cache handling
  Fix GCC port usage on FreeBSD where clang is not default.

Conflicts:
	doc/UPDATES
Bryan Drewery 11 năm trước cách đây
mục cha
commit
c36b1b2b35
4 tập tin đã thay đổi với 151 bổ sung1 xóa
  1. 1 0
      build/autotools/configure.ac
  2. 51 0
      build/autotools/includes/acinclude.m4
  3. 98 1
      configure
  4. 1 0
      doc/UPDATES

+ 1 - 0
build/autotools/configure.ac

@@ -19,6 +19,7 @@ AC_PROG_CXX([g++49 g++-4.9 g++48 g++-4.8 g++47 g++-4.7 g++46 g++-4.6 g++45 g++-4
 CC="${CXX} -x c"
 AC_SUBST(CC)
 EGG_CHECK_CC
+CXX_RPATH_CHECK
 
 #checkpoint
 AC_CACHE_SAVE 

+ 51 - 0
build/autotools/includes/acinclude.m4

@@ -211,6 +211,57 @@ EOF
   fi
 ])
 
+dnl Fix GCC lame compiler paths (FreeBSD)
+dnl @summary check whether compiler requires -rpath for libstdc++.so
+AC_DEFUN([CXX_RPATH_CHECK],
+[
+  AC_CACHE_CHECK([whether the compiler requires -rpath], ax_cv_prog_cc_need_rpath, [
+  AC_TRY_RUN([
+#include <vector>
+int main() {
+        std::vector<int> test;
+        try {
+                return test.at(5);
+        } catch (...) {
+                ;
+        }
+        return 0;
+}
+  ], ax_cv_prog_cc_need_rpath=no, ax_cv_prog_cc_need_rpath=yes)])
+
+  if [[ "${ax_cv_prog_cc_need_rpath}" = "yes" ]]; then
+    save_ldflags="$LDFLAGS"
+    AC_CACHE_CHECK([whether the compiler requires -rpath], ax_cv_prog_cc_rpath, [
+      ax_cv_prog_cc_rpath=
+
+      for path in `${CXX} -print-search-dirs | awk '/^libraries:/ {print substr([$]0, 13)}' | tr ':' ' '`; do
+        if [[ -r "${path}/libstdc++.so" ]]; then
+          LDFLAGS="-Wl,-rpath,${path}"
+          AC_TRY_RUN([
+#include <vector>
+int main() {
+        std::vector<int> test;
+        try {
+                return test.at(5);
+        } catch (...) {
+                ;
+        }
+        return 0;
+}
+          ], ax_cv_prog_cc_rpath="`realpath ${path}`")
+          LDFLAGS="$save_ldflags"
+          [[ -n "${ax_cv_prog_cc_rpath}" ]] && break
+        fi
+      done
+    ])
+    LDFLAGS="$save_ldflags"
+  fi
+
+  if [[ -n "${ax_cv_prog_cc_rpath}" ]]; then
+    LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-Wl,-rpath,${ax_cv_prog_cc_rpath}"
+  fi
+])
+
 dnl  EGG_CHECK_CCSTATIC()
 dnl
 dnl  Checks whether the compiler supports the `-static' flag.

+ 98 - 1
configure

@@ -2999,6 +2999,104 @@ fi
 
 
 
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler requires -rpath" >&5
+$as_echo_n "checking whether the compiler requires -rpath... " >&6; }
+if ${ax_cv_prog_cc_need_rpath+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`build/config.log' for more details" "$LINENO" 5; }
+else
+  cat build/confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end build/confdefs.h.  */
+
+#include <vector>
+int main() {
+        std::vector<int> test;
+        try {
+                return test.at(5);
+        } catch (...) {
+                ;
+        }
+        return 0;
+}
+
+_ACEOF
+if ac_fn_cxx_try_run "$LINENO"; then :
+  ax_cv_prog_cc_need_rpath=no
+else
+  ax_cv_prog_cc_need_rpath=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_prog_cc_need_rpath" >&5
+$as_echo "$ax_cv_prog_cc_need_rpath" >&6; }
+
+  if [ "${ax_cv_prog_cc_need_rpath}" = "yes" ]; then
+    save_ldflags="$LDFLAGS"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler requires -rpath" >&5
+$as_echo_n "checking whether the compiler requires -rpath... " >&6; }
+if ${ax_cv_prog_cc_rpath+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+      ax_cv_prog_cc_rpath=
+
+      for path in `${CXX} -print-search-dirs | awk '/^libraries:/ {print substr($0, 13)}' | tr ':' ' '`; do
+        if [ -r "${path}/libstdc++.so" ]; then
+          LDFLAGS="-Wl,-rpath,${path}"
+          if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`build/config.log' for more details" "$LINENO" 5; }
+else
+  cat build/confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end build/confdefs.h.  */
+
+#include <vector>
+int main() {
+        std::vector<int> test;
+        try {
+                return test.at(5);
+        } catch (...) {
+                ;
+        }
+        return 0;
+}
+
+_ACEOF
+if ac_fn_cxx_try_run "$LINENO"; then :
+  ax_cv_prog_cc_rpath="`realpath ${path}`"
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+          LDFLAGS="$save_ldflags"
+          [ -n "${ax_cv_prog_cc_rpath}" ] && break
+        fi
+      done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_prog_cc_rpath" >&5
+$as_echo "$ax_cv_prog_cc_rpath" >&6; }
+    LDFLAGS="$save_ldflags"
+  fi
+
+  if [ -n "${ax_cv_prog_cc_rpath}" ]; then
+    LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-Wl,-rpath,${ax_cv_prog_cc_rpath}"
+  fi
+
+
 #checkpoint
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -3088,7 +3186,6 @@ rm -f confcache
 
 # Speedup compile
 
-
   if test -n "$GXX" && test -z "$no_wall"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler understands -Wall" >&5
 $as_echo_n "checking whether the compiler understands -Wall... " >&6; }

+ 1 - 0
doc/UPDATES

@@ -3,6 +3,7 @@ maint
   * Avoid apparmor ptrace(2) warnings on Ubuntu
   * Allow 'set trace ignore' again. Undoes a change from 2005.
   * Fix ptrace detection on Linux
+  * Fix broken startup with GCC from ports on FreeBSD.
 
 1.4.5
   * Remove ahbl as it now positively identifies all hosts as abusive