]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
tools: link executables with libtinfo explicitly
authorDaniel Kiper <daniel.kiper@oracle.com>
Tue, 2 Jun 2015 13:33:26 +0000 (15:33 +0200)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 3 Jun 2015 10:12:03 +0000 (11:12 +0100)
binutils 2.22 changed ld default from --copy-dt-needed-entries
to -no-copy-dt-needed-entries. This revealed that some objects
are linked implicitly with libtinfo and newer ld fails to build
relevant executables.

Below is short explanation why we should not do that...

http://fedoraproject.org/wiki/UnderstandingDSOLinkChange says:

The default behaviour for ld (my note: before version 2.22) allows
users to 'indirectly' link to required objects/libraries through
intermediate objects/libraries. While this is convenient, it can
also be dangerous because it makes your program's dependencies tied
to the dependencies of other objects. If those objects ever change
their linkages, they can break your program without any changes
to your own code!

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
config/Tools.mk.in
tools/configure
tools/configure.ac
tools/misc/Makefile
tools/xenstat/xentop/Makefile

index d67352e56d0f2aeb33184090a19839d42d14bf9c..aef9ed6657c8b750c45485cf253ea6d888f935bb 100644 (file)
@@ -77,5 +77,6 @@ CONFIG_LIBICONV     := @libiconv@
 CONFIG_GCRYPT       := @libgcrypt@
 EXTFS_LIBS          := @EXTFS_LIBS@
 CURSES_LIBS         := @CURSES_LIBS@
+TINFO_LIBS          := @TINFO_LIBS@
 
 FILE_OFFSET_BITS    := @FILE_OFFSET_BITS@
index 4c2928dc7b286c7952968e8b6937f6c6f77faf0a..896d8928f15a010ba795d32b24d150af7b5eb168 100755 (executable)
@@ -651,6 +651,7 @@ glib_CFLAGS
 PKG_CONFIG_LIBDIR
 PKG_CONFIG_PATH
 PKG_CONFIG
+TINFO_LIBS
 CURSES_LIBS
 PY_NOOPT_CFLAGS
 EGREP
@@ -7678,6 +7679,51 @@ $as_echo "#define INCLUDE_CURSES_H <curses.h>" >>confdefs.h
 fi
 
 
+if test "$ncurses" = "y"; then :
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for define_key in -ltinfo" >&5
+$as_echo_n "checking for define_key in -ltinfo... " >&6; }
+if ${ac_cv_lib_tinfo_define_key+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ltinfo  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char define_key ();
+int
+main ()
+{
+return define_key ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_tinfo_define_key=yes
+else
+  ac_cv_lib_tinfo_define_key=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tinfo_define_key" >&5
+$as_echo "$ac_cv_lib_tinfo_define_key" >&6; }
+if test "x$ac_cv_lib_tinfo_define_key" = xyes; then :
+  TINFO_LIBS=-ltinfo
+fi
+
+
+fi
+
 
 
 
index 9bf6450a64c412671252f3a7ff9677e747e225c7..1a06ddf98d7daf919d90d414e25d53b264e35f4d 100644 (file)
@@ -318,6 +318,10 @@ i[[3456]]86|x86_64)
 esac
  AX_CHECK_UUID
  AX_CHECK_CURSES
+AS_IF([test "$ncurses" = "y"], [
+AC_CHECK_LIB([tinfo], [define_key], [TINFO_LIBS=-ltinfo])
+])
+AC_SUBST(TINFO_LIBS)
 
 dnl The following are only required when upstream QEMU is built
 AS_IF([test "x$qemu_xen" = "xy"], [
index 3817317c950498c464c9fdbdc54d9484d4758e4e..82c361f2855e1912897909e436dbb7698d4d1f3c 100644 (file)
@@ -100,7 +100,7 @@ xen-lowmemd: xen-lowmemd.o
        $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
 
 gtraceview: gtraceview.o
-       $(CC) $(LDFLAGS) -o $@ $< $(CURSES_LIBS) $(APPEND_LDFLAGS)
+       $(CC) $(LDFLAGS) -o $@ $< $(CURSES_LIBS) $(TINFO_LIBS) $(APPEND_LDFLAGS)
 
 xencov: xencov.o
        $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
index 2652c9dac55a83f7386972a9243338aacd1471d7..97950b970bb6f28c8ce8432e47cdb9181eb0fc54 100644 (file)
@@ -19,7 +19,7 @@ all install xentop:
 else
 
 CFLAGS += -DGCC_PRINTF -Werror $(CFLAGS_libxenstat)
-LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(SOCKET_LIBS) -lm -lyajl
+LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(TINFO_LIBS) $(SOCKET_LIBS) -lm -lyajl
 CFLAGS += -DHOST_$(XEN_OS)
 
 # Include configure output (config.h) to headers search path