From 2d11044217edd9168eafea1c8c60603f87b0e00d Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Thu, 24 Sep 2015 08:51:39 +0000 Subject: Use CRTs provided by Solaris gcc: * configure.ac (gcc_cv_solaris_crts): New test. * configure. Regenerate. * config.in: Regenerate. * config/sol2.h (STARTFILE_SPEC): Simplify, provide HAVE_SOLARIS_CRTS variant. libgcc: * configure.ac (libgcc_cv_solaris_crts): New test. * configure: Regenerate. * config.in: Regenerate. * config/sol2/crtp.c, config/sol2/crtpg.c: New files. * config/gmon-sol2.c: Rename to ... * config/sol2/gmon.c: ... this. Include auto-target.h. (internal_mcount): Wrap setup handling in !HAVE_SOLARIS_CRTS. * config/t-sol2: Rename to ... * config/sol2/t-sol2: ... this. (gmon.o): Reflect renaming. (crtp.o, crtpg.o): New rules. * config.host (*-*-solaris2*): Reflect renaming. Use system CRTs if present. Remove default CRT case. From-SVN: r228077 --- gcc/ChangeLog | 8 ++++++++ gcc/config.in | 6 ++++++ gcc/config/sol2.h | 22 ++++++++++++++++------ gcc/configure | 38 ++++++++++++++++++++++++++++++++++++++ gcc/configure.ac | 31 +++++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 6 deletions(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e3120f3..e549506 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-09-24 Rainer Orth + + * configure.ac (gcc_cv_solaris_crts): New test. + * configure. Regenerate. + * config.in: Regenerate. + * config/sol2.h (STARTFILE_SPEC): Simplify, provide + HAVE_SOLARIS_CRTS variant. + 2015-09-24 Kyrylo Tkachov * tree-inline.h (count_insns_seq): Delete prototype. diff --git a/gcc/config.in b/gcc/config.in index c5c1be4..a1987cc 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1631,6 +1631,12 @@ #endif +/* Define if the system-provided CRTs are present on Solaris. */ +#ifndef USED_FOR_TARGET +#undef HAVE_SOLARIS_CRTS +#endif + + /* Define to 1 if you have the header file. */ #ifndef USED_FOR_TARGET #undef HAVE_STDDEF_H diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index adf6f3b..d31a251 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -156,14 +156,24 @@ along with GCC; see the file COPYING3. If not see /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */ #undef STARTFILE_SPEC -#define STARTFILE_SPEC "%{!shared: \ - %{!symbolic: \ - %{p:mcrt1.o%s} \ - %{!p: \ - %{pg:gcrt1.o%s gmon.o%s} \ - %{!pg:crt1.o%s}}}} \ +#ifdef HAVE_SOLARIS_CRTS +/* Since Solaris 11.x and Solaris 12, the OS delivers crt1.o, crti.o, and + crtn.o, with a hook for compiler-dependent stuff like profile handling. */ +#define STARTFILE_SPEC "%{!shared:%{!symbolic: \ + crt1.o%s \ + %{p:%e-p is not supported; \ + pg:crtpg.o%s gmon.o%s; \ + :crtp.o%s}}} \ crti.o%s %(startfile_arch) \ crtbegin.o%s" +#else +#define STARTFILE_SPEC "%{!shared:%{!symbolic: \ + %{p:mcrt1.o%s; \ + pg:gcrt1.o%s gmon.o%s; \ + :crt1.o%s}}} \ + crti.o%s %(startfile_arch) \ + crtbegin.o%s" +#endif #undef ENDFILE_SPEC #define ENDFILE_SPEC \ diff --git a/gcc/configure b/gcc/configure index 7493c80..a32bb64 100755 --- a/gcc/configure +++ b/gcc/configure @@ -28025,6 +28025,44 @@ $as_echo "#define HAVE_LD_SYSROOT 1" >>confdefs.h fi +case $target in +*-*-solaris2*) + # Check for system-provided CRTs on Solaris 11.x and Solaris 12. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking system-provided CRTs on Solaris" >&5 +$as_echo_n "checking system-provided CRTs on Solaris... " >&6; } +if test "${gcc_cv_solaris_crts+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_solaris_crts=no + if test x$host != x$target; then + if test "x$with_sysroot" = xyes; then + target_sysroot="${test_exec_prefix}/${target_noncanonical}/sys-root" + else + target_sysroot="${with_sysroot}" + fi + fi + target_libdir="$target_sysroot/usr/lib" + # At the time they were added, gcrt1.o became a symlink for backwards + # compatibility on x86, while crt1.o was added on sparc, so check for that. + case $target in + i?86-*-solaris2* | x86_64-*-solaris2*) + if test -h "$target_libdir/gcrt1.o"; then gcc_cv_solaris_crts=yes; fi + ;; + sparc*-*-solaris2*) + if test -f "$target_libdir/crt1.o"; then gcc_cv_solaris_crts=yes; fi + ;; + esac +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_solaris_crts" >&5 +$as_echo "$gcc_cv_solaris_crts" >&6; } + ;; +esac +if test x$gcc_cv_solaris_crts = xyes; then + +$as_echo "#define HAVE_SOLARIS_CRTS 1" >>confdefs.h + +fi + # Test for stack protector support in target C library. { $as_echo "$as_me:${as_lineno-$LINENO}: checking __stack_chk_fail in target C library" >&5 $as_echo_n "checking __stack_chk_fail in target C library... " >&6; } diff --git a/gcc/configure.ac b/gcc/configure.ac index 9d1f6f1..4f8a44e 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5281,6 +5281,37 @@ if test x"$gcc_cv_ld_sysroot" = xyes; then [Define if your linker supports --sysroot.]) fi +case $target in +*-*-solaris2*) + # Check for system-provided CRTs on Solaris 11.x and Solaris 12. + AC_CACHE_CHECK([system-provided CRTs on Solaris], + gcc_cv_solaris_crts, + [gcc_cv_solaris_crts=no + if test x$host != x$target; then + if test "x$with_sysroot" = xyes; then + target_sysroot="${test_exec_prefix}/${target_noncanonical}/sys-root" + else + target_sysroot="${with_sysroot}" + fi + fi + target_libdir="$target_sysroot/usr/lib" + # At the time they were added, gcrt1.o became a symlink for backwards + # compatibility on x86, while crt1.o was added on sparc, so check for that. + case $target in + i?86-*-solaris2* | x86_64-*-solaris2*) + if test -h "$target_libdir/gcrt1.o"; then gcc_cv_solaris_crts=yes; fi + ;; + sparc*-*-solaris2*) + if test -f "$target_libdir/crt1.o"; then gcc_cv_solaris_crts=yes; fi + ;; + esac]) + ;; +esac +if test x$gcc_cv_solaris_crts = xyes; then + AC_DEFINE(HAVE_SOLARIS_CRTS, 1, + [Define if the system-provided CRTs are present on Solaris.]) +fi + # Test for stack protector support in target C library. AC_CACHE_CHECK(__stack_chk_fail in target C library, gcc_cv_libc_provides_ssp, -- cgit v1.1