From e3b3fa45a4f948172b5a67c9b5c830e5519a6d24 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Mon, 8 Aug 2011 12:08:31 +0000 Subject: [PATCH] driver-sparc.c: New file. gcc: * config/sparc/driver-sparc.c: New file. * config/sparc/x-sparc: New file. * config.host: Use driver-sparc.o, sparc/x-sparc on sparc*-*-solaris2*. * config/sparc/sparc.opt (native): New value for enum processor_type. * config/sparc/sparc-opts.h (PROCESSOR_NATIVE): Declare. * config/sparc/sparc.c (sparc_option_override): Abort if PROCESSOR_NATIVE gets here. * config/sparc/sol2.h [__sparc__] (host_detect_local_cpu): Declare. (EXTRA_SPEC_FUNCTIONS, MCPU_MTUNE_NATIVE_SPECS, DRIVER_SELF_SPECS): Define. * doc/invoke.texi (SPARC Options, -mcpu): Document native. (SPARC Options, -mtune): Likewise. * configure.ac (EXTRA_GCC_LIBS): Check for libkstat. Substitute result. * configure: Regenerate. * Makefile.in (EXTRA_GCC_LIBS): Set. (xgcc$(exeext)): Add $(EXTRA_GCC_LIBS). (cpp$(exeext)): Likewise. gcc/cp: * Make-lang.in (g++$(exeext)): Add $(EXTRA_GCC_LIBS). gcc/fortran: * Make-lang.in (gfortran$(exeext)): Add $(EXTRA_GCC_LIBS). gcc/go: * Make-lang.in (gccgo$(exeext)): Add $(EXTRA_GCC_LIBS). gcc/java: * Make-lang.in ($(XGCJ)$(exeext)): Add $(EXTRA_GCC_LIBS). From-SVN: r177559 --- gcc/ChangeLog | 23 ++++++++++++ gcc/Makefile.in | 9 +++-- gcc/config.host | 8 +++++ gcc/config/sparc/sol2.h | 16 +++++++++ gcc/config/sparc/sparc-opts.h | 3 +- gcc/config/sparc/sparc.c | 2 ++ gcc/config/sparc/sparc.opt | 3 ++ gcc/configure | 68 +++++++++++++++++++++++++++++++++-- gcc/configure.ac | 8 +++++ gcc/cp/ChangeLog | 4 +++ gcc/cp/Make-lang.in | 3 +- gcc/doc/invoke.texi | 8 ++++- gcc/fortran/ChangeLog | 4 +++ gcc/fortran/Make-lang.in | 3 +- gcc/go/ChangeLog | 4 +++ gcc/go/Make-lang.in | 3 +- gcc/java/ChangeLog | 4 +++ gcc/java/Make-lang.in | 3 +- 18 files changed, 166 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e0391e26b3..f8f4ea608c0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,26 @@ +2011-08-08 Rainer Orth + + * config/sparc/driver-sparc.c: New file. + * config/sparc/x-sparc: New file. + * config.host: Use driver-sparc.o, sparc/x-sparc on + sparc*-*-solaris2*. + * config/sparc/sparc.opt (native): New value for enum + processor_type. + * config/sparc/sparc-opts.h (PROCESSOR_NATIVE): Declare. + * config/sparc/sparc.c (sparc_option_override): Abort if + PROCESSOR_NATIVE gets here. + * config/sparc/sol2.h [__sparc__] (host_detect_local_cpu): Declare. + (EXTRA_SPEC_FUNCTIONS, MCPU_MTUNE_NATIVE_SPECS, + DRIVER_SELF_SPECS): Define. + * doc/invoke.texi (SPARC Options, -mcpu): Document native. + (SPARC Options, -mtune): Likewise. + * configure.ac (EXTRA_GCC_LIBS): Check for libkstat. + Substitute result. + * configure: Regenerate. + * Makefile.in (EXTRA_GCC_LIBS): Set. + (xgcc$(exeext)): Add $(EXTRA_GCC_LIBS). + (cpp$(exeext)): Likewise. + 2011-08-08 Richard Guenther * tree-vrp.c (extract_range_from_unary_expr_1): New function, diff --git a/gcc/Makefile.in b/gcc/Makefile.in index ed96672aa94..368100b0835 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -714,6 +714,9 @@ EXTRA_OBJS = @extra_objs@ # the gcc driver. EXTRA_GCC_OBJS =@extra_gcc_objs@ +# List of extra libraries that should be linked with the gcc driver. +EXTRA_GCC_LIBS = @EXTRA_GCC_LIBS@ + # List of additional header files to install. EXTRA_HEADERS =@extra_headers_list@ @@ -1808,7 +1811,8 @@ libcommon.a: $(OBJS-libcommon) xgcc$(exeext): $(GCC_OBJS) gccspec.o libcommon-target.a $(LIBDEPS) \ $(EXTRA_GCC_OBJS) +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \ - gccspec.o $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBS) + gccspec.o $(EXTRA_GCC_OBJS) libcommon-target.a \ + $(EXTRA_GCC_LIBS) $(LIBS) # cpp is to cpp0 as gcc is to cc1. # The only difference from xgcc is that it's linked with cppspec.o @@ -1816,7 +1820,8 @@ xgcc$(exeext): $(GCC_OBJS) gccspec.o libcommon-target.a $(LIBDEPS) \ cpp$(exeext): $(GCC_OBJS) cppspec.o libcommon-target.a $(LIBDEPS) \ $(EXTRA_GCC_OBJS) +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \ - cppspec.o $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBS) + cppspec.o $(EXTRA_GCC_OBJS) libcommon-target.a \ + $(EXTRA_GCC_LIBS) $(LIBS) # Dump a specs file to make -B./ read these specs over installed ones. $(SPECS): xgcc$(exeext) diff --git a/gcc/config.host b/gcc/config.host index 85009d1b45c..61a00b57843 100644 --- a/gcc/config.host +++ b/gcc/config.host @@ -157,6 +157,14 @@ case ${host} in ;; esac ;; + sparc*-*-solaris2*) + case ${target} in + sparc*-*-solaris2*) + host_extra_gcc_objs="driver-sparc.o" + host_xmake_file="${host_xmake_file} sparc/x-sparc" + ;; + esac + ;; esac # Machine-specific settings. diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h index 64932f967cd..86afbbefe52 100644 --- a/gcc/config/sparc/sol2.h +++ b/gcc/config/sparc/sol2.h @@ -157,6 +157,22 @@ along with GCC; see the file COPYING3. If not see %{!m32:%{!m64:%(cpp_arch_default)}} \ " +/* -mcpu=native handling only makes sense with compiler running on + a SPARC chip. */ +#if defined(__sparc__) +extern const char *host_detect_local_cpu (int argc, const char **argv); +# define EXTRA_SPEC_FUNCTIONS \ + { "local_cpu_detect", host_detect_local_cpu }, + +# define MCPU_MTUNE_NATIVE_SPECS \ + " %{mcpu=native:%&5 +$as_echo_n "checking for library containing kstat_open... " >&6; } +if test "${ac_cv_search_kstat_open+set}" = set; 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 kstat_open (); +int +main () +{ +return kstat_open (); + ; + return 0; +} +_ACEOF +for ac_lib in '' kstat; 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 ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_kstat_open=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_kstat_open+set}" = set; then : + break +fi +done +if test "${ac_cv_search_kstat_open+set}" = set; then : + +else + ac_cv_search_kstat_open=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_kstat_open" >&5 +$as_echo "$ac_cv_search_kstat_open" >&6; } +ac_res=$ac_cv_search_kstat_open +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +EXTRA_GCC_LIBS="$LIBS" +LIBS="$save_LIBS" + + # Some systems put ldexp and frexp in libm instead of libc; assume # they're both in the same place. jcf-dump needs them. save_LIBS="$LIBS" @@ -17763,7 +17827,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17766 "configure" +#line 17830 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17869,7 +17933,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17872 "configure" +#line 17936 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 81345d6f328..a897b81943c 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -974,6 +974,14 @@ GNAT_LIBEXC="$LIBS" LIBS="$save_LIBS" AC_SUBST(GNAT_LIBEXC) +# To support -mcpu=native on Solaris/SPARC, we need libkstat. +save_LIBS="$LIBS" +LIBS= +AC_SEARCH_LIBS(kstat_open, kstat) +EXTRA_GCC_LIBS="$LIBS" +LIBS="$save_LIBS" +AC_SUBST(EXTRA_GCC_LIBS) + # Some systems put ldexp and frexp in libm instead of libc; assume # they're both in the same place. jcf-dump needs them. save_LIBS="$LIBS" diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 81c1d923e9b..8c74b2ddff8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2011-08-08 Rainer Orth + + * Make-lang.in (g++$(exeext)): Add $(EXTRA_GCC_LIBS). + 2011-08-05 Jason Merrill PR c++/48993 diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 21145b2c88a..6944ce972a8 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -63,7 +63,8 @@ g++spec.o: $(srcdir)/cp/g++spec.c $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H) \ GXX_OBJS = $(GCC_OBJS) g++spec.o g++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS) +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ - $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBS) + $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \ + $(EXTRA_GCC_LIBS) $(LIBS) # Create a version of the g++ driver which calls the cross-compiler. g++-cross$(exeext): g++$(exeext) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 6fd78d57951..30c58b229d5 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -17263,6 +17263,11 @@ for machine type @var{cpu_type}. Supported values for @var{cpu_type} are @samp{sparclet}, @samp{tsc701}, @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara} and @samp{niagara2}. +Native Solaris toolchains also support the value @samp{native}, +which selects the best architecture option for the host processor. +@option{-mcpu=native} has no effect if GCC does not recognize +the processor. + Default instruction scheduling parameters are used for values that select an architecture and not an implementation. These are @samp{v7}, @samp{v8}, @samp{sparclite}, @samp{sparclet}, @samp{v9}. @@ -17327,7 +17332,8 @@ The same values for @option{-mcpu=@var{cpu_type}} can be used for that select a particular CPU implementation. Those are @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon}, @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, @samp{ultrasparc3}, -@samp{niagara}, and @samp{niagara2}. +@samp{niagara}, and @samp{niagara2}. With native Solaris toolchains, +@samp{native} can also be used. @item -mv8plus @itemx -mno-v8plus diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a86afc6728d..2ead4fadebb 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2011-08-08 Rainer Orth + + * Make-lang.in (gfortran$(exeext)): Add $(EXTRA_GCC_LIBS). + 2011-08-07 Janus Weil Thomas Koenig diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in index a56a1f0da8e..9f524b3bce9 100644 --- a/gcc/fortran/Make-lang.in +++ b/gcc/fortran/Make-lang.in @@ -88,7 +88,8 @@ GFORTRAN_D_OBJS = $(GCC_OBJS) gfortranspec.o gfortran$(exeext): $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \ $(LIBDEPS) +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ - $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBS) + $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \ + $(EXTRA_GCC_LIBS) $(LIBS) # Create a version of the gfortran driver which calls the cross-compiler. gfortran-cross$(exeext): gfortran$(exeext) diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index dcf420e364c..549bc03712f 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,7 @@ +2011-08-08 Rainer Orth + + * Make-lang.in (gccgo$(exeext)): Add $(EXTRA_GCC_LIBS). + 2011-08-02 Roberto Lublinerman * Make-lang.in (GO_OBJS): Add go/ast-dump.o. diff --git a/gcc/go/Make-lang.in b/gcc/go/Make-lang.in index 40fa30ceb98..1fe43f57ce1 100644 --- a/gcc/go/Make-lang.in +++ b/gcc/go/Make-lang.in @@ -39,7 +39,8 @@ gospec.o: $(srcdir)/go/gospec.c $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H) \ GCCGO_OBJS = $(GCC_OBJS) gospec.o gccgo$(exeext): $(GCCGO_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS) $(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ - $(GCCGO_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBS) + $(GCCGO_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \ + $(EXTRA_GCC_LIBS) $(LIBS) # Use strict warnings. go-warn = $(STRICT_WARN) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 6f3aee6ee68..21d29e4b26f 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,7 @@ +2011-08-08 Rainer Orth + + * Make-lang.in ($(XGCJ)$(exeext)): Add $(EXTRA_GCC_LIBS). + 2011-07-19 Richard Guenther * builtins.c (static): Use fold_build_pointer_plus. diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in index bdd8b18342a..6dd2f09dca8 100644 --- a/gcc/java/Make-lang.in +++ b/gcc/java/Make-lang.in @@ -66,7 +66,8 @@ jvspec.o: $(srcdir)/java/jvspec.c $(SYSTEM_H) coretypes.h $(TM_H) \ $(XGCJ)$(exeext): $(GCC_OBJS) jvspec.o java/jcf-path.o \ libcommon-target.a $(LIBDEPS) $(EXTRA_GCC_OBJS) +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \ - jvspec.o java/jcf-path.o $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBS) + jvspec.o java/jcf-path.o $(EXTRA_GCC_OBJS) libcommon-target.a \ + $(EXTRA_GCC_LIBS) $(LIBS) # Create a version of the $(XGCJ) driver which calls the cross-compiler. $(XGCJ)-cross$(exeext): $(XGCJ)$(exeext) -- 2.30.2