[gcc r11-5438] ada: c++: Get rid of libposix4, librt on Solaris
Rainer Orth
ro@gcc.gnu.org
Thu Nov 26 12:05:50 GMT 2020
https://gcc.gnu.org/g:55ebb0d6fb06e9e5407c4b382b66ce86c48ecaf6
commit r11-5438-g55ebb0d6fb06e9e5407c4b382b66ce86c48ecaf6
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date: Thu Nov 26 13:01:30 2020 +0100
ada: c++: Get rid of libposix4, librt on Solaris
I recently noticed that neither libposix4 nor librt are needed on
Solaris 11 any longer:
* libposix4 was renamed to librt in Solaris 7 back in 1998.
* librt was folded into libc in the OpenSolaris timeframe, leaving librt
only as a filter on libc. Thus, it's no longer needed on either
Solaris 11 or Illumos.
The following patch removes both uses. At the same time, Ada's use of
libthread has gone: it was folded into libc in Solaris 10 already.
TIME_LIBRARY and friends in g++ are likewise removed: Solaris was the
only user.
Bootstrapped without regressions on i386-pc-solaris2.11,
sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.
2020-11-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
gcc/cp:
* g++spec.c (TIMELIB, TIME_LIBRARY): Remove.
(lang_specific_driver): Remove TIME_LIBRARY handling.
gcc:
* config/sol2.h (TIME_LIBRARY): Remove.
libstdc++-v3:
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Remove libposix4
references.
<solaris*>: Don't use -lrt any longer.
* configure: Regenerate.
* doc/xml/manual/configure.xml (--enable-libstdcxx-time=OPTION):
Remove libposix4 reference.
gcc/ada:
* Makefile.rtl <sparc*-sun-solaris*> (THREADSLIB): Remove.
(MISCLIB): Remove -lposix4.
<*86-*-solaris2*>: Likewise.
* libgnarl/s-osinte__solaris.ads (System.OS_Interface): Remove
-lposix4 -lthread.
Diff:
---
gcc/ada/Makefile.rtl | 6 +-
gcc/ada/libgnarl/s-osinte__solaris.ads | 3 -
gcc/config/sol2.h | 3 -
gcc/cp/g++spec.c | 33 +----
libstdc++-v3/acinclude.m4 | 18 +--
libstdc++-v3/configure | 215 ++++++++++++------------------
libstdc++-v3/doc/xml/manual/configure.xml | 3 +-
7 files changed, 98 insertions(+), 183 deletions(-)
diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
index 97792b43e51..1809bdb676c 100644
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -1674,8 +1674,7 @@ ifeq ($(strip $(filter-out sparc% sun solaris%,$(target_cpu) $(target_vendor) $(
endif
EH_MECHANISM=-gcc
- THREADSLIB = -lposix4 -lthread
- MISCLIB = -lposix4 -lnsl -lsocket
+ MISCLIB = -lnsl -lsocket
SO_OPTS = -Wl,-h,
GNATLIB_SHARED = gnatlib-shared-dual
GMEM_LIB = gmemlib
@@ -1728,8 +1727,7 @@ ifeq ($(strip $(filter-out %86 %x86_64 solaris2%,$(target_cpu) $(target_os))),)
EXTRA_GNATRTL_NONTASKING_OBJS += $(TRASYM_DWARF_UNIX_OBJS)
EH_MECHANISM=-gcc
- THREADSLIB = -lposix4 -lthread
- MISCLIB = -lposix4 -lnsl -lsocket
+ MISCLIB = -lnsl -lsocket
SO_OPTS = -Wl,-h,
GNATLIB_SHARED = gnatlib-shared-dual
GMEM_LIB = gmemlib
diff --git a/gcc/ada/libgnarl/s-osinte__solaris.ads b/gcc/ada/libgnarl/s-osinte__solaris.ads
index b3faa10e6b9..b9d6b8818b3 100644
--- a/gcc/ada/libgnarl/s-osinte__solaris.ads
+++ b/gcc/ada/libgnarl/s-osinte__solaris.ads
@@ -45,9 +45,6 @@ with Ada.Unchecked_Conversion;
package System.OS_Interface is
pragma Preelaborate;
- pragma Linker_Options ("-lposix4");
- pragma Linker_Options ("-lthread");
-
subtype int is Interfaces.C.int;
subtype short is Interfaces.C.short;
subtype long is Interfaces.C.long;
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
index 91b4602b49d..7a21f22d549 100644
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -381,9 +381,6 @@ along with GCC; see the file COPYING3. If not see
{ "endfile_vtv", ENDFILE_VTV_SPEC }, \
SUBTARGET_CPU_EXTRA_SPECS
-/* C++11 programs need -lrt for nanosleep. */
-#define TIME_LIBRARY "rt"
-
#ifndef USE_GLD
/* With Sun ld, -rdynamic is a no-op. */
#define RDYNAMIC_SPEC ""
diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c
index 0ab63bcd211..0f17148ccbd 100644
--- a/gcc/cp/g++spec.c
+++ b/gcc/cp/g++spec.c
@@ -27,12 +27,10 @@ along with GCC; see the file COPYING3. If not see
#define LANGSPEC (1<<1)
/* This bit is set if they did `-lm' or `-lmath'. */
#define MATHLIB (1<<2)
-/* This bit is set if they did `-lrt' or equivalent. */
-#define TIMELIB (1<<3)
/* This bit is set if they did `-lc'. */
-#define WITHLIBC (1<<4)
+#define WITHLIBC (1<<3)
/* Skip this option. */
-#define SKIPOPT (1<<5)
+#define SKIPOPT (1<<4)
#ifndef MATH_LIBRARY
#define MATH_LIBRARY "m"
@@ -41,10 +39,6 @@ along with GCC; see the file COPYING3. If not see
#define MATH_LIBRARY_PROFILE MATH_LIBRARY
#endif
-#ifndef TIME_LIBRARY
-#define TIME_LIBRARY ""
-#endif
-
#ifndef LIBSTDCXX
#define LIBSTDCXX "stdc++"
#endif
@@ -95,15 +89,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
const struct cl_decoded_option *saw_libc = NULL;
/* An array used to flag each argument that needs a bit set for
- LANGSPEC, MATHLIB, TIMELIB, or WITHLIBC. */
+ LANGSPEC, MATHLIB, or WITHLIBC. */
int *args;
/* By default, we throw on the math library if we have one. */
int need_math = (MATH_LIBRARY[0] != '\0');
- /* By default, we throw on the time library if we have one. */
- int need_time = (TIME_LIBRARY[0] != '\0');
-
/* True if we saw -static. */
int static_link = 0;
@@ -147,11 +138,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
args[i] |= MATHLIB;
need_math = 0;
}
- else if (strcmp (arg, TIME_LIBRARY) == 0)
- {
- args[i] |= TIMELIB;
- need_time = 0;
- }
else if (strcmp (arg, "c") == 0)
args[i] |= WITHLIBC;
else
@@ -285,12 +271,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
saw_math = &decoded_options[i];
}
- if (!saw_time && (args[i] & TIMELIB) && library > 0)
- {
- --j;
- saw_time = &decoded_options[i];
- }
-
if (!saw_libc && (args[i] & WITHLIBC) && library > 0)
{
--j;
@@ -377,13 +357,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
}
if (saw_time)
new_decoded_options[j++] = *saw_time;
- else if (library > 0 && need_time)
- {
- generate_option (OPT_l, TIME_LIBRARY, 1, CL_DRIVER,
- &new_decoded_options[j]);
- added_libraries++;
- j++;
- }
if (saw_libc)
new_decoded_options[j++] = *saw_libc;
if (shared_libgcc && !static_link)
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index a4a0bb84018..fcd9ea3d23a 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1381,8 +1381,7 @@ dnl
dnl --enable-libstdcxx-time
dnl --enable-libstdcxx-time=yes
dnl checks for the availability of monotonic and realtime clocks,
-dnl nanosleep and sched_yield in libc and libposix4 and, if needed,
-dnl links in the latter.
+dnl nanosleep and sched_yield in libc.
dnl --enable-libstdcxx-time=rt
dnl also searches (and, if needed, links) librt. Note that this is
dnl not always desirable because, in glibc 2.16 and earlier, for
@@ -1455,7 +1454,6 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
ac_has_nanosleep=yes
;;
solaris*)
- GLIBCXX_LIBS="$GLIBCXX_LIBS -lrt"
ac_has_clock_monotonic=yes
ac_has_clock_realtime=yes
ac_has_nanosleep=yes
@@ -1469,11 +1467,11 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
elif test x"$enable_libstdcxx_time" != x"no"; then
if test x"$enable_libstdcxx_time" = x"rt"; then
- AC_SEARCH_LIBS(clock_gettime, [rt posix4])
- AC_SEARCH_LIBS(nanosleep, [rt posix4])
+ AC_SEARCH_LIBS(clock_gettime, [rt])
+ AC_SEARCH_LIBS(nanosleep, [rt])
else
- AC_SEARCH_LIBS(clock_gettime, [posix4])
- AC_SEARCH_LIBS(nanosleep, [posix4])
+ AC_CHECK_FUNC(clock_gettime)
+ AC_CHECK_FUNC(nanosleep)
fi
case "$ac_cv_search_clock_gettime" in
@@ -1485,13 +1483,9 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
;;
esac
- AC_SEARCH_LIBS(sched_yield, [rt posix4])
+ AC_SEARCH_LIBS(sched_yield, [rt])
case "$ac_cv_search_sched_yield" in
- -lposix4*)
- GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
- ac_has_sched_yield=yes
- ;;
-lrt*)
if test x"$enable_libstdcxx_time" = x"rt"; then
GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index a3d08310cf1..ae7d08508e3 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -2520,6 +2520,76 @@ rm -f conftest.val
} # ac_fn_c_compute_int
+# ac_fn_cxx_check_func LINENO FUNC VAR
+# ------------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_cxx_check_func ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test x$gcc_no_link = xyes; then
+ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $2 (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_cxx_check_func
+
# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
# -------------------------------------------
# Tests whether TYPE exists after having included INCLUDES, setting cache
@@ -12064,7 +12134,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12067 "configure"
+#line 12137 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12170,7 +12240,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12173 "configure"
+#line 12243 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15862,7 +15932,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
# Fake what AC_TRY_COMPILE does.
cat > conftest.$ac_ext << EOF
-#line 15865 "configure"
+#line 15935 "configure"
int main()
{
typedef bool atomic_type;
@@ -15897,7 +15967,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 15900 "configure"
+#line 15970 "configure"
int main()
{
typedef short atomic_type;
@@ -15932,7 +16002,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 15935 "configure"
+#line 16005 "configure"
int main()
{
// NB: _Atomic_word not necessarily int.
@@ -15968,7 +16038,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 15971 "configure"
+#line 16041 "configure"
int main()
{
typedef long long atomic_type;
@@ -16121,7 +16191,7 @@ $as_echo "mutex" >&6; }
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16124 "configure"
+#line 16194 "configure"
int main()
{
_Decimal32 d1;
@@ -16163,7 +16233,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16166 "configure"
+#line 16236 "configure"
template<typename T1, typename T2>
struct same
{ typedef T2 type; };
@@ -16197,7 +16267,7 @@ $as_echo "$enable_int128" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16200 "configure"
+#line 16270 "configure"
template<typename T1, typename T2>
struct same
{ typedef T2 type; };
@@ -21181,7 +21251,6 @@ fi
ac_has_nanosleep=yes
;;
solaris*)
- GLIBCXX_LIBS="$GLIBCXX_LIBS -lrt"
ac_has_clock_monotonic=yes
ac_has_clock_realtime=yes
ac_has_nanosleep=yes
@@ -21219,7 +21288,7 @@ return clock_gettime ();
return 0;
}
_ACEOF
-for ac_lib in '' rt posix4; do
+for ac_lib in '' rt; do
if test -z "$ac_lib"; then
ac_res="none required"
else
@@ -21278,7 +21347,7 @@ return nanosleep ();
return 0;
}
_ACEOF
-for ac_lib in '' rt posix4; do
+for ac_lib in '' rt; do
if test -z "$ac_lib"; then
ac_res="none required"
else
@@ -21314,121 +21383,13 @@ if test "$ac_res" != no; then :
fi
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5
-$as_echo_n "checking for library containing clock_gettime... " >&6; }
-if ${ac_cv_search_clock_gettime+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
+ ac_fn_cxx_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
+if test "x$ac_cv_func_clock_gettime" = xyes; then :
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char clock_gettime ();
-int
-main ()
-{
-return clock_gettime ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' posix4; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if test x$gcc_no_link = xyes; then
- as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
-fi
-if ac_fn_cxx_try_link "$LINENO"; then :
- ac_cv_search_clock_gettime=$ac_res
fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_clock_gettime+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_clock_gettime+:} false; then :
-else
- ac_cv_search_clock_gettime=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5
-$as_echo "$ac_cv_search_clock_gettime" >&6; }
-ac_res=$ac_cv_search_clock_gettime
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing nanosleep" >&5
-$as_echo_n "checking for library containing nanosleep... " >&6; }
-if ${ac_cv_search_nanosleep+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char nanosleep ();
-int
-main ()
-{
-return nanosleep ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' posix4; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if test x$gcc_no_link = xyes; then
- as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
-fi
-if ac_fn_cxx_try_link "$LINENO"; then :
- ac_cv_search_nanosleep=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_nanosleep+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_nanosleep+:} false; then :
-
-else
- ac_cv_search_nanosleep=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_nanosleep" >&5
-$as_echo "$ac_cv_search_nanosleep" >&6; }
-ac_res=$ac_cv_search_nanosleep
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+ ac_fn_cxx_check_func "$LINENO" "nanosleep" "ac_cv_func_nanosleep"
+if test "x$ac_cv_func_nanosleep" = xyes; then :
fi
@@ -21467,7 +21428,7 @@ return sched_yield ();
return 0;
}
_ACEOF
-for ac_lib in '' rt posix4; do
+for ac_lib in '' rt; do
if test -z "$ac_lib"; then
ac_res="none required"
else
@@ -21504,10 +21465,6 @@ fi
case "$ac_cv_search_sched_yield" in
- -lposix4*)
- GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
- ac_has_sched_yield=yes
- ;;
-lrt*)
if test x"$enable_libstdcxx_time" = x"rt"; then
GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
diff --git a/libstdc++-v3/doc/xml/manual/configure.xml b/libstdc++-v3/doc/xml/manual/configure.xml
index b84ac426244..cc9c8554c6c 100644
--- a/libstdc++-v3/doc/xml/manual/configure.xml
+++ b/libstdc++-v3/doc/xml/manual/configure.xml
@@ -171,8 +171,7 @@
<function>sched_yield</function> functions, used in the
implementation of [thread.thread.this] of the 2011 ISO C++ standard.
The choice OPTION=yes checks for the availability of the facilities
- in libc and libposix4. In case it's needed the latter is also linked
- to libstdc++ as part of the build process. OPTION=rt also checks in
+ in libc. OPTION=rt also checks in
librt (and, if it's needed, links to it). Note that linking to librt
is not always desirable because for glibc it requires linking to
libpthread too, which causes all reference counting to use atomic
More information about the Libstdc++-cvs
mailing list