Skip to content

Commit

Permalink
fix #356, disable TLS for uClibc
Browse files Browse the repository at this point in the history
  • Loading branch information
madeye committed Jul 19, 2015
1 parent 53ddb3b commit 2b1eef1
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 39 deletions.
11 changes: 6 additions & 5 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
auto/missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
$(top_srcdir)/m4/inet_ntop.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/polarssl.m4 \
$(top_srcdir)/libev/libev.m4 $(top_srcdir)/configure.ac
$(top_srcdir)/m4/ax_tls.m4 $(top_srcdir)/m4/inet_ntop.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/openssl.m4 \
$(top_srcdir)/m4/polarssl.m4 $(top_srcdir)/libev/libev.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
Expand Down
1 change: 1 addition & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,7 @@ AC_SUBST([am__untar])
]) # _AM_PROG_TAR

m4_include([m4/acx_pthread.m4])
m4_include([m4/ax_tls.m4])
m4_include([m4/inet_ntop.m4])
m4_include([m4/libtool.m4])
m4_include([m4/ltoptions.m4])
Expand Down
3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME

/* If the compiler supports a TLS storage class define it to that here */
#undef TLS

/* Use Apple CommonCrypto library */
#undef USE_CRYPTO_APPLECC

Expand Down
54 changes: 54 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -12851,6 +12851,60 @@ case $host in
;;
esac


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for thread local storage (TLS) class" >&5
$as_echo_n "checking for thread local storage (TLS) class... " >&6; }
if ${ac_cv_tls+:} false; then :
$as_echo_n "(cached) " >&6
else
for ax_tls_keyword in __thread '__declspec(thread)' none; do
case $ax_tls_keyword in #(
none) :
ac_cv_tls=none ; break ;; #(
*) :
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
static void
foo(void) {
static $ax_tls_keyword int bar;
exit(1);
}
int
main ()
{

;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_tls=$ax_tls_keyword ; break
else
ac_cv_tls=none

fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;;
esac
done

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_tls" >&5
$as_echo "$ac_cv_tls" >&6; }

if test "$ac_cv_tls" != "none"; then :

cat >>confdefs.h <<_ACEOF
#define TLS $ac_cv_tls
_ACEOF

:
else
:
fi


case "${with_crypto_library}" in
openssl)

Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ case $host in
;;
esac

dnl Checks for TLS
AX_TLS([:], [:])

dnl Checks for crypto library
case "${with_crypto_library}" in
openssl)
Expand Down
11 changes: 6 additions & 5 deletions libcork/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ subdir = libcork
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in COPYING
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
$(top_srcdir)/m4/inet_ntop.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/polarssl.m4 \
$(top_srcdir)/libev/libev.m4 $(top_srcdir)/configure.ac
$(top_srcdir)/m4/ax_tls.m4 $(top_srcdir)/m4/inet_ntop.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/openssl.m4 \
$(top_srcdir)/m4/polarssl.m4 $(top_srcdir)/libev/libev.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
Expand Down
4 changes: 2 additions & 2 deletions libcork/include/libcork/config/gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@
#endif

/* Thread-local storage has been available since GCC 3.3, but not on Mac
* OS X. */
* OS X. Also disable TLS for uClibc*/

#if !(defined(__APPLE__) && defined(__MACH__))
#if CORK_CONFIG_GCC_VERSION >= 30300
#if CORK_CONFIG_GCC_VERSION >= 30300 && defined(TLS)
#define CORK_CONFIG_HAVE_THREAD_STORAGE_CLASS 1
#else
#define CORK_CONFIG_HAVE_THREAD_STORAGE_CLASS 0
Expand Down
11 changes: 6 additions & 5 deletions libev/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
$(top_srcdir)/m4/inet_ntop.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/polarssl.m4 \
$(top_srcdir)/libev/libev.m4 $(top_srcdir)/configure.ac
$(top_srcdir)/m4/ax_tls.m4 $(top_srcdir)/m4/inet_ntop.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/openssl.m4 \
$(top_srcdir)/m4/polarssl.m4 $(top_srcdir)/libev/libev.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
Expand Down
11 changes: 6 additions & 5 deletions libipset/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ subdir = libipset
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
$(top_srcdir)/m4/inet_ntop.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/polarssl.m4 \
$(top_srcdir)/libev/libev.m4 $(top_srcdir)/configure.ac
$(top_srcdir)/m4/ax_tls.m4 $(top_srcdir)/m4/inet_ntop.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/openssl.m4 \
$(top_srcdir)/m4/polarssl.m4 $(top_srcdir)/libev/libev.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
Expand Down
11 changes: 6 additions & 5 deletions libudns/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ subdir = libudns
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in NEWS TODO
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
$(top_srcdir)/m4/inet_ntop.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/polarssl.m4 \
$(top_srcdir)/libev/libev.m4 $(top_srcdir)/configure.ac
$(top_srcdir)/m4/ax_tls.m4 $(top_srcdir)/m4/inet_ntop.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/openssl.m4 \
$(top_srcdir)/m4/polarssl.m4 $(top_srcdir)/libev/libev.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
Expand Down
74 changes: 74 additions & 0 deletions m4/ax_tls.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_tls.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_TLS([action-if-found], [action-if-not-found])
#
# DESCRIPTION
#
# Provides a test for the compiler support of thread local storage (TLS)
# extensions. Defines TLS if it is found. Currently knows about GCC/ICC
# and MSVC. I think SunPro uses the same as GCC, and Borland apparently
# supports either.
#
# LICENSE
#
# Copyright (c) 2008 Alan Woodland <[email protected]>
# Copyright (c) 2010 Diego Elio Petteno` <[email protected]>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.

#serial 11

AC_DEFUN([AX_TLS], [
AC_MSG_CHECKING([for thread local storage (TLS) class])
AC_CACHE_VAL([ac_cv_tls],
[for ax_tls_keyword in __thread '__declspec(thread)' none; do
AS_CASE([$ax_tls_keyword],
[none], [ac_cv_tls=none ; break],
[AC_TRY_COMPILE(
[#include <stdlib.h>
static void
foo(void) {
static ] $ax_tls_keyword [ int bar;
exit(1);
}],
[],
[ac_cv_tls=$ax_tls_keyword ; break],
ac_cv_tls=none
)])
done
])
AC_MSG_RESULT([$ac_cv_tls])
AS_IF([test "$ac_cv_tls" != "none"],
[AC_DEFINE_UNQUOTED([TLS],[$ac_cv_tls],[If the compiler supports a TLS storage class define it to that here])
m4_ifnblank([$1],[$1])],
[m4_ifnblank([$2],[$2])])
])
4 changes: 2 additions & 2 deletions openwrt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ define Package/shadowsocks-libev
$(call Package/shadowsocks-libev/Default)
TITLE+= (OpenSSL)
VARIANT:=openssl
DEPENDS:=+libopenssl
DEPENDS:=+libopenssl +libpthread
endef

define Package/shadowsocks-libev-polarssl
$(call Package/shadowsocks-libev/Default)
TITLE+= (PolarSSL)
VARIANT:=polarssl
DEPENDS:=+libpolarssl
DEPENDS:=+libpolarssl +libpthread
endef

define Package/shadowsocks-libev/description
Expand Down
4 changes: 3 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
VERSION_INFO = 1:0:0

AM_CFLAGS = -g -O2 -Wall -Werror -Wno-deprecated-declarations -fno-strict-aliasing -std=gnu99 -D_GNU_SOURCE
AM_CFLAGS += $(PTHREAD_CFLAGS)
AM_CFLAGS += -I$(top_srcdir)/libev
AM_CFLAGS += -I$(top_srcdir)/libudns
AM_CFLAGS += -I$(top_srcdir)/libipset/include
Expand All @@ -9,7 +10,8 @@ AM_CFLAGS += -I$(top_srcdir)/libsodium/src/libsodium/include

AM_LDFLAGS = -static

SS_COMMON_LIBS = $(top_builddir)/libev/libev.la \
SS_COMMON_LIBS = $(PTHREAD_LIBS) \
$(top_builddir)/libev/libev.la \
$(top_builddir)/libipset/libipset.la \
$(top_builddir)/libcork/libcork.la \
$(top_builddir)/libsodium/src/libsodium/libsodium.la \
Expand Down
21 changes: 12 additions & 9 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
$(top_srcdir)/m4/inet_ntop.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/polarssl.m4 \
$(top_srcdir)/libev/libev.m4 $(top_srcdir)/configure.ac
$(top_srcdir)/m4/ax_tls.m4 $(top_srcdir)/m4/inet_ntop.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/openssl.m4 \
$(top_srcdir)/m4/polarssl.m4 $(top_srcdir)/libev/libev.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
Expand Down Expand Up @@ -106,7 +107,8 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
"$(DESTDIR)$(includedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = $(top_builddir)/libev/libev.la \
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) \
$(top_builddir)/libev/libev.la \
$(top_builddir)/libipset/libipset.la \
$(top_builddir)/libcork/libcork.la \
$(top_builddir)/libsodium/src/libsodium/libsodium.la \
Expand Down Expand Up @@ -355,12 +357,13 @@ top_srcdir = @top_srcdir@
VERSION_INFO = 1:0:0
AM_CFLAGS = -g -O2 -Wall -Werror -Wno-deprecated-declarations \
-fno-strict-aliasing -std=gnu99 -D_GNU_SOURCE \
-I$(top_srcdir)/libev -I$(top_srcdir)/libudns \
-I$(top_srcdir)/libipset/include \
$(PTHREAD_CFLAGS) -I$(top_srcdir)/libev \
-I$(top_srcdir)/libudns -I$(top_srcdir)/libipset/include \
-I$(top_srcdir)/libcork/include \
-I$(top_srcdir)/libsodium/src/libsodium/include
AM_LDFLAGS = -static
SS_COMMON_LIBS = $(top_builddir)/libev/libev.la \
SS_COMMON_LIBS = $(PTHREAD_LIBS) \
$(top_builddir)/libev/libev.la \
$(top_builddir)/libipset/libipset.la \
$(top_builddir)/libcork/libcork.la \
$(top_builddir)/libsodium/src/libsodium/libsodium.la \
Expand Down

0 comments on commit 2b1eef1

Please sign in to comment.