]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
More sophisticated attempt at detecting working linker options
authorNick Mathewson <nickm@torproject.org>
Sat, 16 Jun 2012 01:04:07 +0000 (21:04 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 18 Jun 2012 15:48:45 +0000 (11:48 -0400)
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
changes/bug6173 [new file with mode: 0644]

index 43280597a409f972ce96e0edc3413d05eeea225d..ae14411f6bbe483301a0a9238804fd46096d3995 100644 (file)
@@ -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 <stdio.h>
+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 (file)
index 0000000..3b467a9
--- /dev/null
@@ -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.
+