From adbdeafad9a85226ef9d232e85360bea54f78a73 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2012 21:04:07 -0400 Subject: [PATCH 1/2] More sophisticated attempt at detecting working linker options On some platforms, the linker is perfectly happy to produce binaries that won't run if you give it the wrong set of flags. So when not cross-compiling, try to link-and-run a little test program, rather than just linking it. Possible fix for 6173. --- acinclude.m4 | 9 +++++++-- changes/bug6173 | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changes/bug6173 diff --git a/acinclude.m4 b/acinclude.m4 index 43280597a4..ae14411f6b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -71,9 +71,14 @@ AC_DEFUN([TOR_CHECK_LDFLAGS], [ CFLAGS="$CFLAGS -pedantic -Werror" LDFLAGS="$LDFLAGS $2 $1" LIBS="$LIBS $3" - AC_TRY_LINK([], [return 0;], + AC_RUN_IFELSE([ +#include +int main(int argc, char **argv) { fputs("", stdout); return 0; }], [AS_VAR_SET(VAR,yes)], - [AS_VAR_SET(VAR,no)]) + [AS_VAR_SET(VAR,no)], + [AC_TRY_LINK([], [return 0;], + [AS_VAR_SET(VAR,yes)], + [AS_VAR_SET(VAR,no)])]) CFLAGS="$tor_saved_CFLAGS" LDFLAGS="$tor_saved_LDFLAGS" LIBS="$tor_saved_LIBS" diff --git a/changes/bug6173 b/changes/bug6173 new file mode 100644 index 0000000000..3b467a9aca --- /dev/null +++ b/changes/bug6173 @@ -0,0 +1,5 @@ + o Major bugfixes: + - Make our linker option detection code more robust against linkers + where a bad combination of options completes successfully but + makes an unrunnable binary. Fixes bug 6173; bugfix on 0.2.3.17-beta. + From 8c0158101cd18c1854c45e51d28316b517184e36 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 18 Jun 2012 11:47:05 -0400 Subject: [PATCH 2/2] oops: AC_RUN_IFELSE gets offended if I don't give it a AC_LANG_PROGRAM --- acinclude.m4 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index ae14411f6b..9ab684877a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -71,14 +71,12 @@ AC_DEFUN([TOR_CHECK_LDFLAGS], [ CFLAGS="$CFLAGS -pedantic -Werror" LDFLAGS="$LDFLAGS $2 $1" LIBS="$LIBS $3" - AC_RUN_IFELSE([ -#include -int main(int argc, char **argv) { fputs("", stdout); return 0; }], - [AS_VAR_SET(VAR,yes)], - [AS_VAR_SET(VAR,no)], - [AC_TRY_LINK([], [return 0;], - [AS_VAR_SET(VAR,yes)], - [AS_VAR_SET(VAR,no)])]) + AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [fputs("", stdout)])], + [AS_VAR_SET(VAR,yes)], + [AS_VAR_SET(VAR,no)], + [AC_TRY_LINK([], [return 0;], + [AS_VAR_SET(VAR,yes)], + [AS_VAR_SET(VAR,no)])]) CFLAGS="$tor_saved_CFLAGS" LDFLAGS="$tor_saved_LDFLAGS" LIBS="$tor_saved_LIBS"