From f783a326b82518bf75b1d3952332b05aac7ffd9b Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Sat, 17 Dec 2011 14:30:41 +0100 Subject: [PATCH 1/4] -lm should not be hardcoded. On some platforms (Haiku/BeOS) libm lives in libcore. Also added 'network' to the list of libraries to search for connect(). --- configure.in | 16 +++++++++++++++- src/or/Makefile.am | 2 +- src/test/Makefile.am | 8 ++++---- src/tools/Makefile.am | 8 +++++--- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/configure.in b/configure.in index b05e935343..d1b7c4441c 100644 --- a/configure.in +++ b/configure.in @@ -279,7 +279,7 @@ fi AC_C_BIGENDIAN -AC_SEARCH_LIBS(socket, [socket]) +AC_SEARCH_LIBS(socket, [socket network]) AC_SEARCH_LIBS(gethostbyname, [nsl]) AC_SEARCH_LIBS(dlopen, [dl]) AC_SEARCH_LIBS(inet_aton, [resolv]) @@ -482,6 +482,20 @@ if test "$enable_bufferevents" = "yes"; then fi AC_SUBST(TOR_LIBEVENT_LIBS) +dnl ------------------------------------------------------ +dnl Where do you live, libm? + +dnl On some platforms (Haiku/BeOS) the math library is +dnl part of libroot. In which case don't link against lm +TOR_LIB_MATH="" +save_LIBS="$LIBS" +AC_SEARCH_LIBS(cos, [m], , AC_MSG_ERROR([Could not find libm and libcore does not provide the functions.])) +if test "$ac_cv_search_cos" != "none required"; then + TOR_LIB_MATH="$ac_cv_search_cos" +fi +LIBS="$save_LIBS" +AC_SUBST(TOR_LIB_MATH) + dnl ------------------------------------------------------ dnl Where do you live, openssl? And how do we call you? diff --git a/src/or/Makefile.am b/src/or/Makefile.am index a5682081ae..57f5dd65e4 100644 --- a/src/or/Makefile.am +++ b/src/or/Makefile.am @@ -74,7 +74,7 @@ AM_CPPFLAGS = -DSHARE_DATADIR="\"$(datadir)\"" \ tor_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ @TOR_LDFLAGS_libevent@ tor_LDADD = ./libtor.a ../common/libor.a ../common/libor-crypto.a \ ../common/libor-event.a \ - @TOR_ZLIB_LIBS@ -lm @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \ + @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \ @TOR_LIB_WS32@ @TOR_LIB_GDI@ noinst_HEADERS = \ diff --git a/src/test/Makefile.am b/src/test/Makefile.am index 73de300719..e766446d3a 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -31,15 +31,15 @@ test_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ \ @TOR_LDFLAGS_libevent@ test_LDADD = ../or/libtor.a ../common/libor.a ../common/libor-crypto.a \ ../common/libor-event.a \ - @TOR_ZLIB_LIBS@ -lm @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \ - @TOR_LIB_WS32@ @TOR_LIB_GDI@ + @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \ + @TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ bench_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ \ @TOR_LDFLAGS_libevent@ bench_LDADD = ../or/libtor.a ../common/libor.a ../common/libor-crypto.a \ ../common/libor-event.a \ - @TOR_ZLIB_LIBS@ -lm @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \ - @TOR_LIB_WS32@ @TOR_LIB_GDI@ + @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \ + @TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ noinst_HEADERS = \ tinytest.h \ diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am index a9a619757a..35b0a41f53 100644 --- a/src/tools/Makefile.am +++ b/src/tools/Makefile.am @@ -3,17 +3,19 @@ noinst_PROGRAMS = tor-checkkey tor_resolve_SOURCES = tor-resolve.c tor_resolve_LDFLAGS = -tor_resolve_LDADD = ../common/libor.a -lm @TOR_LIB_WS32@ +tor_resolve_LDADD = ../common/libor.a @TOR_LIB_MATH@ @TOR_LIB_WS32@ tor_gencert_SOURCES = tor-gencert.c tor_gencert_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ tor_gencert_LDADD = ../common/libor.a ../common/libor-crypto.a \ - -lm @TOR_ZLIB_LIBS@ @TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ + @TOR_LIB_MATH@ @TOR_ZLIB_LIBS@ @TOR_OPENSSL_LIBS@ \ + @TOR_LIB_WS32@ @TOR_LIB_GDI@ tor_checkkey_SOURCES = tor-checkkey.c tor_checkkey_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ tor_checkkey_LDADD = ../common/libor.a ../common/libor-crypto.a \ - -lm @TOR_ZLIB_LIBS@ @TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ + @TOR_LIB_MATH@ @TOR_ZLIB_LIBS@ @TOR_OPENSSL_LIBS@ \ + @TOR_LIB_WS32@ @TOR_LIB_GDI@ SUBDIRS = tor-fw-helper DIST_SUBDIRS = tor-fw-helper From d5e964731c009589952be246d80d4114f65d5ee2 Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Sat, 17 Dec 2011 17:51:07 +0100 Subject: [PATCH 2/4] Fixed build with GCC < 3.3 Preprocessor directives should not be put inside the arguments of a macro. This is not supported on older GCC releases (< 3.3) thus broke compilation on Haiku (running gcc2). --- changes/portability_01_haiku | 11 +++++++++++ src/or/main.c | 7 +++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 changes/portability_01_haiku diff --git a/changes/portability_01_haiku b/changes/portability_01_haiku new file mode 100644 index 0000000000..ab583812c7 --- /dev/null +++ b/changes/portability_01_haiku @@ -0,0 +1,11 @@ + o Minor buxfixes: + - During configure, search for library containing cos function as + libm lives in libcore on some platforms (BeOS/Haiku). + Linking against libm was hard-coded before. Bugfix on + 0.2.2.2-alpha, fixes the first part of bug 4727. Patch and + analysis by Martin Hebnes Pedersen. + - Preprocessor directives should not be put inside the arguments + of a macro. This would break compilation with GCC releases prior + to version 3.3. Bugfix on 0.2.3.3-alpha, fixes the other part of + bug 4727. Patch and analysis by Martin Hebnes Pedersen. + diff --git a/src/or/main.c b/src/or/main.c index 74583b2ea0..1ba33957a6 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -2268,13 +2268,12 @@ tor_init(int argc, char *argv[]) { const char *version = get_version(); - log_notice(LD_GENERAL, "Tor v%s%s running on %s.", version, #ifdef USE_BUFFEREVENTS - " (with bufferevents)", + log_notice(LD_GENERAL, "Tor v%s (with bufferevents) running on %s.", + version, get_uname()); #else - "", + log_notice(LD_GENERAL, "Tor v%s running on %s.", version, get_uname()); #endif - get_uname()); log_notice(LD_GENERAL, "Tor can't help you if you use it wrong! " "Learn how to be safe at " From e535c8a460fb3c1973ec46fe0910bbd21148b475 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 19 Dec 2011 11:26:50 -0500 Subject: [PATCH 3/4] Tweak the haiku-support patches --- configure.in | 6 +++--- src/test/Makefile.am | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index d1b7c4441c..1f045f1349 100644 --- a/configure.in +++ b/configure.in @@ -489,9 +489,9 @@ dnl On some platforms (Haiku/BeOS) the math library is dnl part of libroot. In which case don't link against lm TOR_LIB_MATH="" save_LIBS="$LIBS" -AC_SEARCH_LIBS(cos, [m], , AC_MSG_ERROR([Could not find libm and libcore does not provide the functions.])) -if test "$ac_cv_search_cos" != "none required"; then - TOR_LIB_MATH="$ac_cv_search_cos" +AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.])) +if test "$ac_cv_search_pow" != "none required"; then + TOR_LIB_MATH="$ac_cv_search_pow" fi LIBS="$save_LIBS" AC_SUBST(TOR_LIB_MATH) diff --git a/src/test/Makefile.am b/src/test/Makefile.am index e766446d3a..31a464ee7a 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -31,7 +31,7 @@ test_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ \ @TOR_LDFLAGS_libevent@ test_LDADD = ../or/libtor.a ../common/libor.a ../common/libor-crypto.a \ ../common/libor-event.a \ - @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \ + @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \ @TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ bench_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ \ From 9cabedd3eb68313d0d6b079b489439bad7d26244 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 19 Dec 2011 11:29:03 -0500 Subject: [PATCH 4/4] Explain why we are making gcc 3.3 work --- changes/portability_01_haiku | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/changes/portability_01_haiku b/changes/portability_01_haiku index ab583812c7..74887fe0c3 100644 --- a/changes/portability_01_haiku +++ b/changes/portability_01_haiku @@ -6,6 +6,9 @@ analysis by Martin Hebnes Pedersen. - Preprocessor directives should not be put inside the arguments of a macro. This would break compilation with GCC releases prior - to version 3.3. Bugfix on 0.2.3.3-alpha, fixes the other part of - bug 4727. Patch and analysis by Martin Hebnes Pedersen. + to version 3.3. We would never recommend such an old GCC + version, but it is apparently required for binary compatibility + on some platforms (namely, certain builds of Haiku). Bugfix on + 0.2.3.3-alpha, fixes the other part of bug 4727. Patch and + analysis by Martin Hebnes Pedersen.