From 677fbc7d4e34dff14aaf49efa114bc85aa986da1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Apr 2005 20:10:28 +0200 Subject: Step 1 of the switch to support configuration with NPTL: Rename 'IS_LINUX' configuration variable to 'TARGET_LINUX'. --- configure.in | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index d191463d0f9..6650c0fc64a 100644 --- a/configure.in +++ b/configure.in @@ -410,15 +410,15 @@ AC_MSG_CHECKING("if we should use 'skip-locking' as default for $target_os") if expr "$target_os" : "[[Ll]]inux.*" > /dev/null then MYSQLD_DEFAULT_SWITCHES="--skip-locking" - IS_LINUX="true" + TARGET_LINUX="true" AC_MSG_RESULT("yes"); else MYSQLD_DEFAULT_SWITCHES="" - IS_LINUX="false" + TARGET_LINUX="false" AC_MSG_RESULT("no"); fi AC_SUBST(MYSQLD_DEFAULT_SWITCHES) -AC_SUBST(IS_LINUX) +AC_SUBST(TARGET_LINUX) dnl Find paths to some shell programs AC_PATH_PROG(LN, ln, ln) @@ -607,7 +607,7 @@ AC_SUBST(NOINST_LDFLAGS) # (this is true on the MySQL build machines to avoid NSS problems) # -if test "$IS_LINUX" = "true" -a "$static_nss" = "" +if test "$TARGET_LINUX" = "true" -a "$static_nss" = "" then tmp=`nm /usr/lib/libc.a | grep _nss_files_getaliasent_r` if test -n "$tmp" @@ -841,7 +841,7 @@ struct request_info *req; ]) AC_SUBST(WRAPLIBS) -if test "$IS_LINUX" = "true"; then +if test "$TARGET_LINUX" = "true"; then AC_MSG_CHECKING([for atomic operations]) atom_ops= @@ -885,7 +885,7 @@ int main() [ USE_PSTACK=no ]) pstack_libs= pstack_dirs= - if test "$USE_PSTACK" = yes -a "$IS_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386" -a "$with_mit_threads" = "no" + if test "$USE_PSTACK" = yes -a "$TARGET_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386" -a "$with_mit_threads" = "no" then have_libiberty= have_libbfd= my_save_LIBS="$LIBS" @@ -1286,7 +1286,7 @@ then else AC_MSG_RESULT("Not found") # If this is a linux machine we should barf - if test "$IS_LINUX" = "true" + if test "$TARGET_LINUX" = "true" then AC_MSG_ERROR([This is a linux system and Linuxthreads was not found. On linux Linuxthreads should be used. Please install Linuxthreads @@ -1738,7 +1738,7 @@ fi AC_SUBST(COMPILATION_COMMENT) AC_MSG_CHECKING("need of special linking flags") -if test "$IS_LINUX" = "true" -a "$ac_cv_prog_gcc" = "yes" -a "$all_is_static" != "yes" +if test "$TARGET_LINUX" = "true" -a "$ac_cv_prog_gcc" = "yes" -a "$all_is_static" != "yes" then LDFLAGS="$LDFLAGS -rdynamic" AC_MSG_RESULT("-rdynamic") @@ -1955,7 +1955,7 @@ CFLAGS="$ORG_CFLAGS" # Sanity check: We chould not have any fseeko symbol unless # large_file_support=yes AC_CHECK_FUNC(fseeko, -[if test "$large_file_support" = no -a "$IS_LINUX" = "true"; +[if test "$large_file_support" = no -a "$TARGET_LINUX" = "true"; then AC_MSG_ERROR("Found fseeko symbol but large_file_support is not enabled!"); fi] -- cgit v1.2.1 From b6a4a2f41cb7aa04b59d8017070a69cd6f4c5082 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Apr 2005 20:38:57 +0200 Subject: Step 2 of the switch to support configuration with NPTL: Define a new CPP symbol that the target OS is Linux, and use it where only the OS matters and not the threads Library. Until now, 'HAVE_LINUXTHREADS' was used to indicate "Target is Linux" in many places. When we support configuration with NPTL but no Linuxthreads, this misuse must cease. configure.in: Step 2 of the switch to support configuration with NPTL: Define a new CPP symbol that the target OS is Linux. Until now, 'HAVE_LINUXTHREADS' was used to indicate "Target is Linux" in many places. When we support configuration with NPTL but no Linuxthreads, this misuse must cease. include/my_global.h: Step 2 of the switch to support configuration with NPTL: Use the new 'TARGET_OS_LINUX' where only the OS matters and not the threads Library. mysys/thr_mutex.c: Step 2 of the switch to support configuration with NPTL: Use the new 'TARGET_OS_LINUX' where only the OS matters and not the threads Library. sql/stacktrace.c: Step 2 of the switch to support configuration with NPTL: Use the new 'TARGET_OS_LINUX' where only the OS matters and not the threads Library. sql/stacktrace.h: Step 2 of the switch to support configuration with NPTL: Use the new 'TARGET_OS_LINUX' where only the OS matters and not the threads Library. tools/mysqlmanager.c: Step 2 of the switch to support configuration with NPTL: Use the new 'TARGET_OS_LINUX' where only the OS matters and not the threads Library. --- configure.in | 1 + 1 file changed, 1 insertion(+) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 6650c0fc64a..f7a266eebec 100644 --- a/configure.in +++ b/configure.in @@ -412,6 +412,7 @@ then MYSQLD_DEFAULT_SWITCHES="--skip-locking" TARGET_LINUX="true" AC_MSG_RESULT("yes"); + AC_DEFINE([TARGET_OS_LINUX], [1], [Whether we build for Linux]) else MYSQLD_DEFAULT_SWITCHES="" TARGET_LINUX="false" -- cgit v1.2.1 From 8a9c988122135441d35bbab1b70c3e0ccb88b7a4 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Apr 2005 20:49:05 +0200 Subject: Step 3 of the switch to support configuration with NPTL: Change "configure.in". The branches for Tru64 (ex: OSF/1) and Linux are separated, and for Linux 'getconf GNU_LIBPTHREAD_VERSION' is used to tell between Linuxthreads and NPTL. configure.in: Step 3 of the switch to support configuration with NPTL: Change "configure.in". 1) Separate the branches checking for thread libraries on OSF/1 (now: Tru64) and on Linux, as these are different things. In the Tru64 branch, remove the obsolete part for OSF/1 3.2, because that is gone since long (about a decade?); we are at 5 now. Adapt the comment. 2) For Linux, the thread libraries are "Linuxthreads" (older) and "NPTL" (newer). Until now, we cared only about "Linuxthreads", and we did so by checking a comment in the header file '/usr/include/pthread.h'. With NPTL as an alternative or only thread package, this is not secure any more, there are distributions where the header file still contains that comment but the lib is NPTL. For all current distributions, the way to check is the 'getconf' command. On old distributions, 'getconf' exists but does not understand the 'GNU_LIBPTHREAD_VERSION' parameter. It is unlikely that such an old system should have NPTL, so the header file check is sufficient if the getconf inquiry fails. For both Linuxthreads and NPTL, '-lpthread' is the linker option to use. 3) To detect problems as early as possible, on Linux a link test using '-lpthread' is done. The code is copied from a later check where the thread functions are searched in '-lc', '-lpthread', and '-lpthreads', but this later search would not be executed after the lib was already determined. So if the test is not done here, it will be detected only during the real build. This is too late. --- configure.in | 138 ++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 85 insertions(+), 53 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index f7a266eebec..dfffecdff08 100644 --- a/configure.in +++ b/configure.in @@ -411,12 +411,12 @@ if expr "$target_os" : "[[Ll]]inux.*" > /dev/null then MYSQLD_DEFAULT_SWITCHES="--skip-locking" TARGET_LINUX="true" - AC_MSG_RESULT("yes"); + AC_MSG_RESULT("yes") AC_DEFINE([TARGET_OS_LINUX], [1], [Whether we build for Linux]) else MYSQLD_DEFAULT_SWITCHES="" TARGET_LINUX="false" - AC_MSG_RESULT("no"); + AC_MSG_RESULT("no") fi AC_SUBST(MYSQLD_DEFAULT_SWITCHES) AC_SUBST(TARGET_LINUX) @@ -1267,61 +1267,93 @@ esac # We have to check libc last because else it fails on Solaris 2.6 with_posix_threads="no" -# Hack for DEC-UNIX (OSF1) +# Search thread lib on Linux if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no" then - # Look for LinuxThreads. - AC_MSG_CHECKING("LinuxThreads") - res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l` - if test "$res" -gt 0 + AC_MSG_CHECKING("Linux threads") + if test "$TARGET_LINUX" = "true" then - AC_MSG_RESULT("Found") - AC_DEFINE([HAVE_LINUXTHREADS], [1], - [Whether we are using Xavier Leroy's LinuxThreads]) - # Linux 2.0 sanity check - AC_TRY_COMPILE([#include ], [int a = sched_get_priority_min(1);], , - AC_MSG_ERROR([Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file. See the Installation chapter in the Reference Manual])) - # RedHat 5.0 does not work with dynamic linking of this. -static also - # gives a speed increase in linux so it does not hurt on other systems. - with_named_thread="-lpthread" - else - AC_MSG_RESULT("Not found") - # If this is a linux machine we should barf - if test "$TARGET_LINUX" = "true" - then - AC_MSG_ERROR([This is a linux system and Linuxthreads was not -found. On linux Linuxthreads should be used. Please install Linuxthreads -(or a new glibc) and try again. See the Installation chapter in the -Reference Manual for more information.]) - else - AC_MSG_CHECKING("DEC threads") - if test -f /usr/shlib/libpthread.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a - then - with_named_thread="-lpthread -lmach -lexc" - CFLAGS="$CFLAGS -D_REENTRANT" - CXXFLAGS="$CXXFLAGS -D_REENTRANT" - AC_DEFINE(HAVE_DEC_THREADS, [1], - [Whether we are using DEC threads]) - AC_MSG_RESULT("yes") - else - AC_MSG_RESULT("no") - AC_MSG_CHECKING("DEC 3.2 threads") - if test -f /usr/shlib/libpthreads.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a - then - with_named_thread="-lpthreads -lmach -lc_r" - AC_DEFINE(HAVE_DEC_THREADS, [1]) - AC_DEFINE([HAVE_DEC_3_2_THREADS], [1], - [Whether we are using OSF1 DEC threads on 3.2]) - with_osf32_threads="yes" - MYSQLD_DEFAULT_SWITCHES="--skip-thread-priority" - AC_MSG_RESULT("yes") - else - AC_MSG_RESULT("no") + AC_MSG_RESULT("starting") + # use getconf to check glibc contents + AC_MSG_CHECKING("getconf GNU_LIBPTHREAD_VERSION") + case `getconf GNU_LIBPTHREAD_VERSION | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` in + NPTL* ) + AC_MSG_RESULT("NPTL") + AC_DEFINE([HAVE_NPTL], [1], [NPTL threads implementation]) + with_named_thread="-lpthread" + ;; + LINUXTHREADS* ) + AC_MSG_RESULT("Linuxthreads") + AC_DEFINE([HAVE_LINUXTHREADS], [1], + [Whether we are using Xavier Leroy's LinuxThreads]) + with_named_thread="-lpthread" + ;; + * ) + AC_MSG_RESULT("unknown") + ;; + esac + if test "$with_named_thread" = "no" + then + # old method, check headers + # Look for LinuxThreads. + AC_MSG_CHECKING("LinuxThreads in header file comment") + res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l` + if test "$res" -gt 0 + then + AC_MSG_RESULT("Found") + AC_DEFINE([HAVE_LINUXTHREADS], [1], + [Whether we are using Xavier Leroy's LinuxThreads]) + # Linux 2.0 sanity check + AC_TRY_COMPILE([#include ], [int a = sched_get_priority_min(1);], , + AC_MSG_ERROR([Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file. See the Installation chapter in the Reference Manual])) + # RedHat 5.0 does not work with dynamic linking of this. -static also + # gives a speed increase in linux so it does not hurt on other systems. + with_named_thread="-lpthread" + else + AC_MSG_RESULT("Not found") + # If this is a linux machine we should barf + AC_MSG_ERROR([This is a Linux system without a working getconf, +and Linuxthreads was not found. Please install it (or a new glibc) and try again. +See the Installation chapter in the Reference Manual for more information.]) fi - fi - fi - fi -fi + else + AC_MSG_RESULT("no need to check headers") + fi + + AC_MSG_CHECKING("for pthread_create in -lpthread"); + ac_save_LIBS="$LIBS" + LIBS="$LIBS -lpthread" + AC_TRY_LINK( [#include ], + [ (void) pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ], + AC_MSG_RESULT("yes"), + [ AC_MSG_RESULT("no") + AC_MSG_ERROR([ +This is a Linux system claiming to support threads, either Linuxthreads or NPTL, but linking a test program failed. +Please install one of these (or a new glibc) and try again. +See the Installation chapter in the Reference Manual for more information.]) ] + ) + LIBS="$ac_save_LIBS" + else + AC_MSG_RESULT("no") + fi # "$TARGET_LINUX" +fi # "$with_named_thread" = "no" -a "$with_mit_threads" = "no" + + +# Hack for DEC-UNIX (OSF1 -> Tru64) +if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no" +then + AC_MSG_CHECKING("DEC threads post OSF/1 3.2") + if test -f /usr/shlib/libpthread.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a + then + with_named_thread="-lpthread -lmach -lexc" + CFLAGS="$CFLAGS -D_REENTRANT" + CXXFLAGS="$CXXFLAGS -D_REENTRANT" + AC_DEFINE(HAVE_DEC_THREADS, [1], [Whether we are using DEC threads]) + AC_MSG_RESULT("yes") + else + AC_MSG_RESULT("no") + fi # DEC threads +fi # "$with_named_thread" = "no" -a "$with_mit_threads" = "no" dnl This is needed because -lsocket has to come after the thread -- cgit v1.2.1