diff --git a/Makefile.in b/Makefile.in index b1ed67d3d4f15..888cff66d5a7c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -656,7 +656,7 @@ STAGEautofeedback_TFLAGS = $(STAGE3_TFLAGS) # may result in additional warnings. STAGEautofeedback_CONFIGURE_FLAGS = $(filter-out --enable-werror-always,$(STAGE_CONFIGURE_FLAGS)) -do-compare = @do_compare@ +do-compare = $(srcdir)/contrib/compare-debug $$f1 $$f2 do-compare3 = $(do-compare) # ----------------------------------------------- diff --git a/README.md b/README.md new file mode 100644 index 0000000000000..fcb3d7f9570b2 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +This is the GCC used for compiling illumos. + +The `il-*` branches contain the the patches used for building illumos, which +are rebased versions of those used for Solaris/OpenSolaris, and then +additional changes. The versions actually in use are tagged with +`il-VERSION-ilN` where _N_ version the illumos changes over the GCC version in +question. + +The `wip/*` branches are works in progress and _should never be used_ + +The `codesourcery/*` and `sun/*` branches contain the original GCCs as patched by +CodeSourcery and Sun Microsystems for use compiling Solaris and OpenSolaris as +was, and the GCCFSS patches of Sun's + +When building the compilers for illumos use the flags generally used are: + +i386 +~~~sh +../../configure --prefix=/opt/gcc/$VER --with-as=/usr/bin/gas --with-gnu-as \ + --with-ld=/usr/bin/ld --without-gnu-ld --enable-languages="c,c++,objc" \ + --enable-shared --with-mpfr-include=/usr/include/mpfr \ + --with-gmp-include=/usr/include/gmp \ + --with-pkgversion="Illumos $(git describe --all)" \ + --with-bugurl="http://github.com/richlowe/gcc/issues" +~~~ + +sparc +~~~sh +../../configure --prefix=/opt/gcc/$VER --without-gnu-as --with-as=/usr/ccs/bin/as" \ + --with-ld=/usr/bin/ld --without-gnu-ld --enable-languages="c,c++,objc" \ + --enable-shared --with-mpfr-include=/usr/include/mpfr \ + --with-gmp-include=/usr/include/gmp \ + --with-pkgversion="Illumos $(git describe --all)" \ + --with-bugurl="http://github.com/richlowe/gcc/issues" +~~~ + +Please use the correct `--with-bugurl` and `--with-pkgversion` flags as +appropriate for any modifications you make, but please also be sure that they +accurately describe what is in use (ie, are not left at the defaults) either. diff --git a/c++tools/Makefile.in b/c++tools/Makefile.in index 5acc6d68195ae..ed0d3271062e0 100644 --- a/c++tools/Makefile.in +++ b/c++tools/Makefile.in @@ -35,6 +35,7 @@ CXXOPTS := $(CXXFLAGS) $(PICFLAG) -fno-exceptions -fno-rtti LDFLAGS := @LDFLAGS@ exeext := @EXEEXT@ LIBIBERTY := ../libiberty/libiberty.a +NETLIBS := @NETLIBS@ VERSION.O := ../gcc/version.o all:: @@ -98,7 +99,7 @@ MAPPER.O := server.o resolver.o CODYLIB = ../libcody/libcody.a CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I. -I../gcc g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB) - +$(CXX) $(LDFLAGS) $(PICFLAG) $(LD_PICFLAG) -o $@ $^ $(LIBIBERTY) + +$(CXX) $(LDFLAGS) $(PICFLAG) $(LD_PICFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS) # copy to gcc dir so tests there can run all::../gcc/g++-mapper-server$(exeext) diff --git a/c++tools/configure b/c++tools/configure index 1353479becaf4..006efe07b3543 100755 --- a/c++tools/configure +++ b/c++tools/configure @@ -622,6 +622,7 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS LIBOBJS +NETLIBS get_gcc_base_ver EGREP GREP @@ -1669,6 +1670,52 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile + +# ac_fn_cxx_try_link LINENO +# ------------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_link cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -3719,6 +3766,170 @@ fi +# Solaris needs libsocket and libnsl for socket functions before 11.4. +# libcody uses those. +save_LIBS="$LIBS" +LIBS= + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 +$as_echo_n "checking for library containing gethostbyname... " >&6; } +if ${ac_cv_search_gethostbyname+:} 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 gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +for ac_lib in '' nsl; 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_cxx_try_link "$LINENO"; then : + ac_cv_search_gethostbyname=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_gethostbyname+:} false; then : + break +fi +done +if ${ac_cv_search_gethostbyname+:} false; then : + +else + ac_cv_search_gethostbyname=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 +$as_echo "$ac_cv_search_gethostbyname" >&6; } +ac_res=$ac_cv_search_gethostbyname +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 socket" >&5 +$as_echo_n "checking for library containing socket... " >&6; } +if ${ac_cv_search_socket+:} 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 socket (); +int +main () +{ +return socket (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; 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_cxx_try_link "$LINENO"; then : + ac_cv_search_socket=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_socket+:} false; then : + break +fi +done +if ${ac_cv_search_socket+:} false; then : + +else + ac_cv_search_socket=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 +$as_echo "$ac_cv_search_socket" >&6; } +ac_res=$ac_cv_search_socket +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 +$as_echo_n "checking for socket in -lsocket... " >&6; } +if ${ac_cv_lib_socket_socket+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket -lnsl $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 socket (); +int +main () +{ +return socket (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_socket_socket=yes +else + ac_cv_lib_socket_socket=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 +$as_echo "$ac_cv_lib_socket_socket" >&6; } +if test "x$ac_cv_lib_socket_socket" = xyes; then : + LIBS="-lsocket -lnsl $LIBS" +fi + +fi + + +NETLIBS="$LIBS" +LIBS="$save_LIBS" + + ac_config_headers="$ac_config_headers config.h" ac_config_files="$ac_config_files Makefile" diff --git a/c++tools/configure.ac b/c++tools/configure.ac index db34ee678e033..31694bba48e83 100644 --- a/c++tools/configure.ac +++ b/c++tools/configure.ac @@ -22,6 +22,7 @@ # By default g++ uses an in-process mapper. sinclude(../config/acx.m4) +sinclude(../config/ax_lib_socket_nsl.m4) AC_INIT(c++tools) @@ -263,6 +264,15 @@ fi # Determine what GCC version number to use in filesystem paths. GCC_BASE_VER +# Solaris needs libsocket and libnsl for socket functions before 11.4. +# libcody uses those. +save_LIBS="$LIBS" +LIBS= +AX_LIB_SOCKET_NSL +NETLIBS="$LIBS" +LIBS="$save_LIBS" +AC_SUBST(NETLIBS) + AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile]) diff --git a/contrib/make_sunver.pl b/contrib/make_sunver.pl index 4dd184d64ea13..1d6980b61a996 100644 --- a/contrib/make_sunver.pl +++ b/contrib/make_sunver.pl @@ -66,7 +66,7 @@ # columns. # The path to elfdump. -my $elfdump = "/usr/ccs/bin/elfdump"; +my $elfdump = "/usr/bin/elfdump"; if (-f $elfdump) { open ELFDUMP,$elfdump.' -s '.(join ' ',@OBJECTS).'|' or die $!; diff --git a/fixincludes/fixinc.in b/fixincludes/fixinc.in index 0bd8027a55492..0ca234fcb9947 100755 --- a/fixincludes/fixinc.in +++ b/fixincludes/fixinc.in @@ -212,7 +212,7 @@ search_dirs="" while [ -n "$dirs" ] && [ $levels -gt 0 ] do - levels=`expr $levels - 1` + levels=`expr $levels - 1; true` newdirs= for d in $dirs do @@ -340,7 +340,7 @@ if $LINKS; then cd $LIB while [ x$dirname != x ]; do component=`echo $dirname | sed -e 's|/.*$||'` - mkdir $component >/dev/null 2>&1 + mkdir -p $component >/dev/null 2>&1 cd $component dirmade=$dirmade/$component dirname=`echo $dirname | sed -e 's|[^/]*//*||'` diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 55b4cd7dbed3f..c62ee1bb1a77e 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -451,6 +451,7 @@ CPPINC = -I$(srcdir)/../libcpp/include CODYLIB = ../libcody/libcody.a CODYINC = -I$(srcdir)/../libcody +NETLIBS = @NETLIBS@ # Where to find decNumber enable_decimal_float = @enable_decimal_float@ diff --git a/gcc/aclocal.m4 b/gcc/aclocal.m4 index 762e9490b6a86..c0fcbeb5f990e 100644 --- a/gcc/aclocal.m4 +++ b/gcc/aclocal.m4 @@ -68,6 +68,7 @@ m4_include([../ltsugar.m4]) m4_include([../ltversion.m4]) m4_include([../lt~obsolete.m4]) m4_include([../config/acx.m4]) +m4_include([../config/ax_lib_socket_nsl.m4]) m4_include([../config/cet.m4]) m4_include([../config/codeset.m4]) m4_include([../config/depstand.m4]) diff --git a/gcc/attribs.cc b/gcc/attribs.cc index 56dd18c2fa8ea..129588d67ecc5 100644 --- a/gcc/attribs.cc +++ b/gcc/attribs.cc @@ -713,6 +713,15 @@ decl_attributes (tree *node, tree attributes, int flags, attributes = tree_cons (get_identifier ("no_icf"), NULL, attributes); } + /* If the user passed -fno-clone-functions, all functions should be treated + as "noclone" */ + if (TREE_CODE (*node) == FUNCTION_DECL + && !flag_clone_functions) + { + if (lookup_attribute ("noclone", attributes) == NULL) + attributes = tree_cons (get_identifier ("noclone"), NULL, attributes); + } + targetm.insert_attributes (*node, &attributes); /* Note that attributes on the same declaration are not necessarily diff --git a/gcc/common.opt b/gcc/common.opt index e3fa0dacec4cf..f1d00cc6a4346 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1264,6 +1264,11 @@ fcode-hoisting Common Var(flag_code_hoisting) Optimization Enable code hoisting. +fclone-functions +Common Var(flag_clone_functions) Init(1) +Allow the compiler to clone functions to facilitate certain optimizations. +Enabled by default. + fcombine-stack-adjustments Common Var(flag_combine_stack_adjustments) Optimization Looks for opportunities to reduce stack adjustments and stack references. @@ -2427,6 +2432,10 @@ fomit-frame-pointer Common Var(flag_omit_frame_pointer) Optimization When possible do not generate stack frames. +fforce-omit-frame-pointer +Common Var(flag_force_omit_frame_pointer) Optimization +When possible, do not generate stack frames. Hinders debugging with mdb and dtrace. + fopenmp-target-simd-clone Common Alias(fopenmp-target-simd-clone=,any,none) @@ -3029,6 +3038,10 @@ fstrict-aliasing Common Var(flag_strict_aliasing) Optimization Assume strict aliasing rules apply. +fstrict-calling-conventions +Common Var(flag_strict_calling_conventions) Init(1) +Use strict ABI calling conventions even for static functions + fstrict-overflow Common Treat signed overflow as undefined. Negated as -fwrapv -fwrapv-pointer. diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc index 964449fa8cd78..5b9c5e119f80e 100644 --- a/gcc/config/i386/i386-options.cc +++ b/gcc/config/i386/i386-options.cc @@ -2775,6 +2775,11 @@ ix86_option_override_internal (bool main_args_p, opts->x_ix86_isa_flags2 |= avx512_isa_flags2; } + if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && TARGET_SAVE_ARGS) { + warning (0, "-msave-args only works in x32 or 64-bit mode; ignoring"); + opts->x_ix86_target_flags &= ~OPTION_MASK_SAVE_ARGS; + } + /* Validate -mpreferred-stack-boundary= value or default it to PREFERRED_STACK_BOUNDARY_DEFAULT. */ ix86_preferred_stack_boundary = PREFERRED_STACK_BOUNDARY_DEFAULT; @@ -3243,6 +3248,18 @@ ix86_option_override_internal (bool main_args_p, free (str); } + /* + * We never want to omit the frame pointer, regardless of the optimisation + * level or options to gcc - we like stack traces too much and it is of + * questionable benefit anyway, even on i386. + */ + + if (flag_force_omit_frame_pointer == 0) + { + flag_omit_frame_pointer = 0; + opts->x_flag_omit_frame_pointer = 0; + } + /* Save the initial options in case the user does function specific options. */ if (main_args_p) diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 08d0519ccd134..9b5b50dabe13f 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -447,6 +447,9 @@ static const char *ix86_ccmp_dfv_mapping[] = "{dfv=sf}", "{dfv=sf, of}", "{dfv=sf, of, zf}", "{dfv=sf, of}" }; +static int ix86_nsaved_args (void); +static rtx_def* pro_epilogue_adjust_stack (rtx, rtx, rtx, int, bool); + /* Whether -mtune= or -march= were specified */ int ix86_tune_defaulted; @@ -1241,6 +1244,7 @@ ix86_function_regparm (const_tree type, const_tree decl) and callee not, or vice versa. Instead look at whether the callee is optimized or not. */ if (target && opt_for_fn (target->decl, optimize) + && !flag_strict_calling_conventions && !(profile_flag && !flag_fentry)) { if (target->local && target->can_change_signature) @@ -1337,6 +1341,7 @@ ix86_function_sseregparm (const_tree type, const_tree decl, bool warn) /* TARGET_SSE_MATH */ && (target_opts_for_fn (target->decl)->x_ix86_fpmath & FPMATH_SSE) && opt_for_fn (target->decl, optimize) + && !flag_strict_calling_conventions && !(profile_flag && !flag_fentry)) { if (target->local && target->can_change_signature) @@ -5958,7 +5963,7 @@ ix86_can_use_return_insn_p (void) struct ix86_frame &frame = cfun->machine->frame; return (frame.stack_pointer_offset == UNITS_PER_WORD - && (frame.nregs + frame.nsseregs) == 0); + && (frame.nmsave_args + frame.nregs + frame.nsseregs) == 0); } /* Return stack frame size. get_frame_size () returns used stack slots @@ -5995,6 +6000,9 @@ ix86_frame_pointer_required (void) if (TARGET_32BIT_MS_ABI && cfun->calls_setjmp) return true; + if (TARGET_SAVE_ARGS) + return true; + /* Win64 SEH, very large frames need a frame-pointer as maximum stack allocation is 4GB. */ if (TARGET_64BIT_MS_ABI && ix86_get_frame_size () > SEH_MAX_FRAME_SIZE) @@ -6091,7 +6099,9 @@ indirect_thunk_name (char name[32], unsigned int regno, if (regno != INVALID_REGNUM && regno != CX_REG && ret_p) gcc_unreachable (); - if (USE_HIDDEN_LINKONCE) + if (USE_HIDDEN_LINKONCE || + (cfun && cfun->machine->indirect_branch_type == + indirect_branch_thunk_extern)) { const char *prefix; @@ -6936,6 +6946,7 @@ ix86_compute_frame_layout (void) frame->nregs = ix86_nsaved_regs (); frame->nsseregs = ix86_nsaved_sseregs (); + frame->nmsave_args = ix86_nsaved_args (); /* 64-bit MS ABI seem to require stack alignment to be always 16, except for function prologues, leaf functions and when the defult @@ -7021,7 +7032,8 @@ ix86_compute_frame_layout (void) } frame->save_regs_using_mov - = TARGET_PROLOGUE_USING_MOVE && m->use_fast_prologue_epilogue; + = TARGET_FORCE_SAVE_REGS_USING_MOV || + (TARGET_PROLOGUE_USING_MOVE && m->use_fast_prologue_epilogue); /* Skip return address and error code in exception handler. */ offset = INCOMING_FRAME_SP_OFFSET; @@ -7038,6 +7050,13 @@ ix86_compute_frame_layout (void) /* The traditional frame pointer location is at the top of the frame. */ frame->hard_frame_pointer_offset = offset; + if (TARGET_SAVE_ARGS) + { + offset += frame->nmsave_args * UNITS_PER_WORD; + offset += (frame->nmsave_args % 2) * UNITS_PER_WORD; + } + frame->arg_save_offset = offset; + /* Register save area */ offset += frame->nregs * UNITS_PER_WORD; frame->reg_save_offset = offset; @@ -7171,7 +7190,7 @@ ix86_compute_frame_layout (void) /* Size prologue needs to allocate. */ to_allocate = offset - frame->sse_reg_save_offset; - if ((!to_allocate && frame->nregs <= 1) + if ((!TARGET_SAVE_ARGS && !to_allocate && frame->nregs <= 1) || (TARGET_64BIT && to_allocate >= HOST_WIDE_INT_C (0x80000000)) /* If static stack checking is enabled and done with probes, the registers need to be saved before allocating the frame. */ @@ -7196,7 +7215,11 @@ ix86_compute_frame_layout (void) { frame->red_zone_size = to_allocate; if (frame->save_regs_using_mov) + { frame->red_zone_size += frame->nregs * UNITS_PER_WORD; + frame->red_zone_size += frame->nmsave_args * UNITS_PER_WORD; + frame->red_zone_size += (frame->nmsave_args % 2) * UNITS_PER_WORD; + } if (frame->red_zone_size > RED_ZONE_SIZE - RED_ZONE_RESERVE) frame->red_zone_size = RED_ZONE_SIZE - RED_ZONE_RESERVE; } @@ -7254,6 +7277,22 @@ ix86_compute_frame_layout (void) else frame->hard_frame_pointer_offset = frame->hfp_save_offset; } + + if (getenv("DEBUG_FRAME_STUFF") != NULL) + { + printf("nmsave_args: %d\n", frame->nmsave_args); + printf("nsseregs: %d\n", frame->nsseregs); + printf("nregs: %d\n", frame->nregs); + + printf("frame_pointer_offset: %llx\n", frame->frame_pointer_offset); + printf("hard_frame_pointer_offset: %llx\n", frame->hard_frame_pointer_offset); + printf("stack_pointer_offset: %llx\n", frame->stack_pointer_offset); + printf("hfp_save_offset: %llx\n", frame->hfp_save_offset); + printf("arg_save_offset: %llx\n", frame->arg_save_offset); + printf("reg_save_offset: %llx\n", frame->reg_save_offset); + printf("sse_reg_save_offset: %llx\n", frame->sse_reg_save_offset); + + } } /* This is semi-inlined memory_address_length, but simplified @@ -7467,9 +7506,26 @@ static void ix86_emit_save_regs (void) { int regno; + struct ix86_frame &frame = cfun->machine->frame; rtx_insn *insn; bool use_ppx = TARGET_APX_PPX && !crtl->calls_eh_return; + if (TARGET_SAVE_ARGS) + { + int i; + int start = cfun->returns_struct; + + for (i = start; i < start + frame.nmsave_args; i++) + { + regno = x86_64_int_parameter_registers[i]; + insn = emit_insn (gen_push (gen_rtx_REG (word_mode, regno))); + RTX_FRAME_RELATED_P (insn) = 1; + } + if (frame.nmsave_args % 2 != 0) + pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx, + GEN_INT (-UNITS_PER_WORD), -1, false); + } + if (!TARGET_APX_PUSH2POP2 || !ix86_can_use_push2pop2 () || cfun->machine->func_type != TYPE_NORMAL) @@ -7635,9 +7691,29 @@ ix86_emit_save_reg_using_mov (machine_mode mode, unsigned int regno, /* Emit code to save registers using MOV insns. First register is stored at CFA - CFA_OFFSET. */ static void -ix86_emit_save_regs_using_mov (HOST_WIDE_INT cfa_offset) +ix86_emit_save_regs_using_mov (const struct ix86_frame &frame) { unsigned int regno; + HOST_WIDE_INT cfa_offset = frame.arg_save_offset; + + if (TARGET_SAVE_ARGS) + { + int i; + int start = cfun->returns_struct; + + /* We deal with this twice? */ + if (frame.nmsave_args % 2 != 0) + cfa_offset -= UNITS_PER_WORD; + + for (i = start + frame.nmsave_args - 1; i >= start; i--) + { + regno = x86_64_int_parameter_registers[i]; + ix86_emit_save_reg_using_mov(word_mode, regno, cfa_offset); + cfa_offset -= UNITS_PER_WORD; + } + } + + cfa_offset = frame.reg_save_offset; for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) if (GENERAL_REGNO_P (regno) && ix86_save_reg (regno, true, true)) @@ -8995,7 +9071,7 @@ ix86_expand_prologue (void) } } - int_registers_saved = (frame.nregs == 0); + int_registers_saved = (frame.nregs == 0 && frame.nmsave_args == 0); sse_registers_saved = (frame.nsseregs == 0); save_stub_call_needed = (m->call_ms2sysv); gcc_assert (sse_registers_saved || !save_stub_call_needed); @@ -9038,7 +9114,7 @@ ix86_expand_prologue (void) && (! TARGET_STACK_PROBE || frame.stack_pointer_offset < CHECK_STACK_LIMIT)) { - ix86_emit_save_regs_using_mov (frame.reg_save_offset); + ix86_emit_save_regs_using_mov (frame); cfun->machine->red_zone_used = true; int_registers_saved = true; } @@ -9338,7 +9414,7 @@ ix86_expand_prologue (void) } if (!int_registers_saved) - ix86_emit_save_regs_using_mov (frame.reg_save_offset); + ix86_emit_save_regs_using_mov (frame); if (!sse_registers_saved) ix86_emit_save_sse_regs_using_mov (frame.sse_reg_save_offset); else if (save_stub_call_needed) @@ -9373,6 +9449,7 @@ ix86_expand_prologue (void) relative to the value of the stack pointer at the end of the function prologue, and moving instructions that access redzone area via frame pointer inside push sequence violates this assumption. */ + /* XXX: We may wish to do this when SAVE_ARGS in general */ if (frame_pointer_needed && frame.red_zone_size) emit_insn (gen_memory_blockage ()); @@ -9875,6 +9952,7 @@ ix86_expand_epilogue (int style) /* See the comment about red zone and frame pointer usage in ix86_expand_prologue. */ + /* XXX: We may wish to do this when SAVE_ARGS in general */ if (frame_pointer_needed && frame.red_zone_size) emit_insn (gen_memory_blockage ()); @@ -10122,6 +10200,32 @@ ix86_expand_epilogue (int style) ix86_emit_restore_regs_using_pop (TARGET_APX_PPX); } + /* + * For each saved argument, emit a restore note, to make sure it happens + * correctly within the shrink wrapping (I think). + * + * Note that 'restore' in this case merely means the rule is the same as + * it was on function entry, not that we have actually done a register + * restore (which of course, we haven't). + * + * If we do not do this, the DWARF code will emit sufficient restores to + * provide balance on its own initiative, which in the presence of + * -fshrink-wrap may actually _introduce_ unbalance (whereby we only + * .cfi_offset a register sometimes, but will always .cfi_restore it. + * This will trip an assert.) + */ + if (TARGET_SAVE_ARGS && frame.nmsave_args > 0) { + int start = cfun->returns_struct; + int i; + + for (i = start + frame.nmsave_args - 1; i >= start; i--) + queued_cfa_restores + = alloc_reg_note (REG_CFA_RESTORE, + gen_rtx_REG(Pmode, + x86_64_int_parameter_registers[i]), + queued_cfa_restores); + } + /* If we used a stack pointer and haven't already got rid of it, then do so now. */ if (m->fs.fp_valid) @@ -11279,8 +11383,19 @@ ix86_cannot_force_const_mem (machine_mode mode, rtx x) return !ix86_legitimate_constant_p (mode, x); } -/* Return a unique alias set for the GOT. */ +/* Return number of arguments to be saved on the stack with + -msave-args. */ +static int +ix86_nsaved_args (void) +{ + if (TARGET_SAVE_ARGS) + return crtl->args.info.regno - cfun->returns_struct; + else + return 0; +} + +/* Return a unique alias set for the GOT. */ alias_set_type ix86_GOT_alias_set (void) { diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index e850b618b8fac..04543016498be 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2643,6 +2643,11 @@ enum avx_u128_state saved frame pointer if frame_pointer_needed <- HARD_FRAME_POINTER + + [-msave-args] <- arg_save_offset + + [saveargs padding] + [saved regs] <- reg_save_offset [padding0] @@ -2676,6 +2681,7 @@ enum avx_u128_state */ struct GTY(()) ix86_frame { + int nmsave_args; int nsseregs; int nregs; int va_arg_size; @@ -2687,6 +2693,7 @@ struct GTY(()) ix86_frame HOST_WIDE_INT hard_frame_pointer_offset; HOST_WIDE_INT stack_pointer_offset; HOST_WIDE_INT hfp_save_offset; + HOST_WIDE_INT arg_save_offset; HOST_WIDE_INT reg_save_offset; HOST_WIDE_INT stack_realign_allocate; HOST_WIDE_INT stack_realign_offset; diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index 27d34bd64eaaf..90e88373908d8 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -537,6 +537,16 @@ mtls-direct-seg-refs Target Mask(TLS_DIRECT_SEG_REFS) Use direct references against %gs when accessing tls data. +msave-args +Target Mask(SAVE_ARGS) Var(ix86_target_flags) +Save integer arguments on the stack at function entry. + +mforce-save-regs-using-mov +Target Mask(FORCE_SAVE_REGS_USING_MOV) Var(ix86_target_flags) +Save registers using push in function prologues. This is intentionally +undocumented and used for msave-args testing. + + mtune= Target RejectNegative Negative(mtune=) Joined Var(ix86_tune_string) Schedule code for given CPU. diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h index 013e87f72a3a1..78a2abf2dce6a 100644 --- a/gcc/config/i386/sol2.h +++ b/gcc/config/i386/sol2.h @@ -252,3 +252,20 @@ along with GCC; see the file COPYING3. If not see /* We do not need NT_VERSION notes. */ #undef X86_FILE_START_VERSION_DIRECTIVE #define X86_FILE_START_VERSION_DIRECTIVE false + +/* + * As of 5788, the illumos libc includes support for the stack protector + * __stack_chk_fail() function and for the __stack_chk_guard variable. + * That means that, for most cases, no extra objects need to be linked in + * when compiling with one of the -fstack-protector options. + * However, for 32-bit PIC/PIE objects, the gcc stack protector emits a + * function call to __stack_chk_fail_local(); this symbol is provided in + * illumos via the libssp_ns.a object. The spec below includes this in the + * link when appropriate. + */ +#if defined(TARGET_LIBC_PROVIDES_SSP) +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all|" \ + "fstack-protector-strong|fstack-protector-explicit:" \ + DEF_ARCH32_SPEC("-lssp_ns") \ + "}" +#endif diff --git a/gcc/config/sol2-c.cc b/gcc/config/sol2-c.cc index 97c3db0436816..d22311b298e65 100644 --- a/gcc/config/sol2-c.cc +++ b/gcc/config/sol2-c.cc @@ -31,16 +31,23 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-pragma.h" -/* cmn_err only accepts "l" and "ll". */ +#define NO_FMT NULL, FMT_LEN_none, STD_C89 + static const format_length_info cmn_err_length_specs[] = { + { "h", FMT_LEN_h, STD_C89, "hh", FMT_LEN_hh, STD_C99, 0 }, { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C89, 0 }, - { NULL, FMT_LEN_none, STD_C89, NULL, FMT_LEN_none, STD_C89, 0 } + { "j", FMT_LEN_j, STD_C99, NO_FMT, 0 }, + { "z", FMT_LEN_z, STD_C99, NO_FMT, 0 }, + { NO_FMT, NO_FMT, 0 } }; static const format_flag_spec cmn_err_flag_specs[] = { + { '0', 0, 0, 0, N_("'0' flag"), N_("the '0' flag"), STD_C89 }, + { '-', 0, 0, 0, N_("'-' flag"), N_("the '-' flag"), STD_C89 }, { 'w', 0, 0, 0, N_("field width"), N_("field width in printf format"), STD_C89 }, + { 'p', 0, 0, 0, N_("precision"), N_("precision in printf format"), STD_C89 }, { 'L', 0, 0, 0, N_("length modifier"), N_("length modifier in printf format"), STD_C89 }, { 0, 0, 0, 0, NULL, NULL, STD_C89 } }; @@ -48,6 +55,7 @@ static const format_flag_spec cmn_err_flag_specs[] = static const format_flag_pair cmn_err_flag_pairs[] = { + { '0', '-', 1, 0 }, { 0, 0, 0, 0 } }; @@ -56,22 +64,22 @@ static const format_char_info bitfield_string_type = static const format_char_info cmn_err_char_table[] = { - /* C89 conversion specifiers. */ - { "dD", 0, STD_C89, { T89_I, BADLEN, BADLEN, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "", NULL }, - { "oOxX",0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "", NULL }, - { "u", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "", NULL }, - { "c", 0, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "", NULL }, - { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "c", NULL }, - { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "cR", NULL }, - { "b", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "", &bitfield_string_type }, + /* none hh h l ll L z t j H D DD */ + { "dD", 0, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, BADLEN, T99_IM , BADLEN, BADLEN, BADLEN }, "-wp0", "", NULL }, + { "oOxX",0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, BADLEN, T99_ST, BADLEN, T99_UIM, BADLEN, BADLEN, BADLEN }, "-wp0", "", NULL }, + { "u", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, BADLEN, T99_ST, BADLEN, T99_UIM, BADLEN, BADLEN, BADLEN }, "-wp0", "", NULL }, + { "c", 0, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN , BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, + { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN , BADLEN, BADLEN, BADLEN }, "-w", "c", NULL }, + { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN , BADLEN, BADLEN, BADLEN }, "-wp", "cR", NULL }, + { "b", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN , BADLEN, BADLEN, BADLEN }, "-w0", "", &bitfield_string_type }, { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; EXPORTED_CONST format_kind_info solaris_format_types[] = { - { "cmn_err", cmn_err_length_specs, cmn_err_char_table, "", NULL, + { "cmn_err", cmn_err_length_specs, cmn_err_char_table, "0-", NULL, cmn_err_flag_specs, cmn_err_flag_pairs, FMT_FLAG_ARG_CONVERT|FMT_FLAG_EMPTY_PREC_OK, - 'w', 0, 0, 0, 'L', 0, + 'w', 0, 'p', 0, 'L', 0, &integer_type_node, &integer_type_node } }; diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index 2405c101aee32..fb07e9e4aa59f 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -85,6 +85,7 @@ along with GCC; see the file COPYING3. If not see do { \ builtin_define_std ("unix"); \ builtin_define_std ("sun"); \ + builtin_define ("__illumos__"); \ builtin_define ("__svr4__"); \ builtin_define ("__SVR4"); \ builtin_assert ("system=unix"); \ @@ -195,16 +196,22 @@ along with GCC; see the file COPYING3. If not see executable programs. */ #undef STARTFILE_ARCH_SPEC #define STARTFILE_ARCH_SPEC \ - "%{!shared:%{!symbolic: \ - %{ansi|std=c*|std=iso9899\\:199409:values-Xc.o%s; :values-Xa.o%s} \ - %{std=c90|std=gnu90:values-xpg4.o%s; :values-xpg6.o%s}}}" + "%{!shared:%{!symbolic:%{!G: \ + %{ \ + std=c89|std=c90|std=gnu89|std=gnu90:values-Xa.o%s; \ + ansi|std=c*|std=iso9899\\:199409:values-Xc.o%s; \ + :values-Xa.o%s} \ + %{ \ + std=c89|std=c90|std=gnu89|std=gnu90:; \ + :values-xpg6.o%s \ + }}}}" #if defined(HAVE_LD_PIE) #define STARTFILE_CRTBEGIN_SPEC "%{static:crtbegin.o%s; \ - shared|" PIE_SPEC ":crtbeginS.o%s; \ + shared|G|" PIE_SPEC ":crtbeginS.o%s; \ :crtbegin.o%s}" #else -#define STARTFILE_CRTBEGIN_SPEC "crtbegin.o%s" +#define STARTFILE_CRTBEGIN_SPEC "%{shared|G:crtbeginS.o%s;:crtbegin.o%s}" #endif #if ENABLE_VTABLE_VERIFY @@ -247,10 +254,10 @@ along with GCC; see the file COPYING3. If not see #endif #define LIBASAN_EARLY_SPEC ASAN_REJECT_SPEC \ - " %{!shared:libasan_preinit%O%s} \ - %{static-libasan:%{!shared: -Bstatic "\ + " %{!shared:%{!G:libasan_preinit%O%s}} \ + %{static-libasan:%{!shared:%{!G: -Bstatic "\ LD_WHOLE_ARCHIVE_OPTION " -lasan " LD_NO_WHOLE_ARCHIVE_OPTION \ - " -Bdynamic}}%{!static-libasan:-z now -lasan}" + " -Bdynamic}}}%{!static-libasan:-z now -lasan}" /* Error out on -fsanitize=thread|leak. */ #define LIBTSAN_EARLY_SPEC "\ @@ -262,20 +269,20 @@ along with GCC; see the file COPYING3. If not see #undef STARTFILE_SPEC /* Since Solaris 11.4, 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: \ +#define STARTFILE_SPEC "%{!shared:%{!symbolic:%{!G: \ crt1.o%s \ %{p:%e-p is not supported; \ pg:crtpg.o%s gmon.o%s; \ - :crtp.o%s}}} \ + :crtp.o%s}}}} \ crti.o%s %(startfile_arch) %(startfile_crtbegin) \ %(startfile_vtv)" #if defined(HAVE_LD_PIE) #define ENDFILE_CRTEND_SPEC "%{static:crtend.o%s; \ - shared|" PIE_SPEC ":crtendS.o%s; \ + shared|G|" PIE_SPEC ":crtendS.o%s; \ :crtend.o%s}" #else -#define ENDFILE_CRTEND_SPEC "crtend.o%s" +#define ENDFILE_CRTEND_SPEC "%{shared|G:crtendS.o%s;:crtend.o%s}" #endif #undef ENDFILE_SPEC @@ -285,8 +292,7 @@ along with GCC; see the file COPYING3. If not see #undef LINK_ARCH32_SPEC_BASE #define LINK_ARCH32_SPEC_BASE \ - "%{G:-G} \ - %{YP,*} \ + "%{YP,*} \ %{R*} \ %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp%R/lib:%R/usr/lib} \ %{!p:%{!pg:-Y P,%R/lib:%R/usr/lib}}}" @@ -298,8 +304,7 @@ along with GCC; see the file COPYING3. If not see ARCH64_SUBDIR appended to the paths. */ #undef LINK_ARCH64_SPEC_BASE #define LINK_ARCH64_SPEC_BASE \ - "%{G:-G} \ - %{YP,*} \ + "%{YP,*} \ %{R*} \ %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp/" ARCH64_SUBDIR ":%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR "} \ %{!p:%{!pg:-Y P,%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR "}}}" @@ -382,7 +387,7 @@ along with GCC; see the file COPYING3. If not see #if !defined(USE_GLD) && defined(ENABLE_SHARED_LIBGCC) /* With Sun ld, use mapfile to enforce direct binding to libgcc_s unwinder. */ #define LINK_LIBGCC_MAPFILE_SPEC \ - "%{shared|shared-libgcc:-M %slibgcc-unwind.map}" + "%{shared|shared-libgcc|G:-M %slibgcc-unwind.map}" #else /* GNU ld doesn't support direct binding. */ #define LINK_LIBGCC_MAPFILE_SPEC "" @@ -399,9 +404,9 @@ along with GCC; see the file COPYING3. If not see #undef LINK_SPEC #define LINK_SPEC \ "%{h*} %{v:-V} \ - %{!shared:%{!static:%{rdynamic: " RDYNAMIC_SPEC "}}} \ + %{!shared:%{!static:%{!G:%{rdynamic: " RDYNAMIC_SPEC "}}}} \ %{static:-dn -Bstatic} \ - %{shared:-G -dy %{!mimpure-text:-z text}} " \ + %{shared|G:-G -dy %{!mimpure-text:-z text}} " \ LINK_LIBGCC_MAPFILE_SPEC LINK_CLEARCAP_SPEC " \ %{symbolic:-Bsymbolic -G -dy -z text} \ %(link_arch) \ diff --git a/gcc/configure b/gcc/configure index 16965953f0516..a22ea1f9b77e6 100755 --- a/gcc/configure +++ b/gcc/configure @@ -812,6 +812,7 @@ ZSTD_LIB ZSTD_INCLUDE DL_LIB LDEXP_LIB +NETLIBS EXTRA_GCC_LIBS GNAT_LIBEXC COLLECT2_LIBS @@ -10305,6 +10306,170 @@ EXTRA_GCC_LIBS="$LIBS" LIBS="$save_LIBS" +# Solaris needs libsocket and libnsl for socket functions before 11.4. +# C++ needs those for libcody. +save_LIBS="$LIBS" +LIBS= + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 +$as_echo_n "checking for library containing gethostbyname... " >&6; } +if ${ac_cv_search_gethostbyname+:} 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 gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +for ac_lib in '' nsl; 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_cxx_try_link "$LINENO"; then : + ac_cv_search_gethostbyname=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_gethostbyname+:} false; then : + break +fi +done +if ${ac_cv_search_gethostbyname+:} false; then : + +else + ac_cv_search_gethostbyname=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 +$as_echo "$ac_cv_search_gethostbyname" >&6; } +ac_res=$ac_cv_search_gethostbyname +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 socket" >&5 +$as_echo_n "checking for library containing socket... " >&6; } +if ${ac_cv_search_socket+:} 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 socket (); +int +main () +{ +return socket (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; 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_cxx_try_link "$LINENO"; then : + ac_cv_search_socket=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_socket+:} false; then : + break +fi +done +if ${ac_cv_search_socket+:} false; then : + +else + ac_cv_search_socket=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 +$as_echo "$ac_cv_search_socket" >&6; } +ac_res=$ac_cv_search_socket +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 +$as_echo_n "checking for socket in -lsocket... " >&6; } +if ${ac_cv_lib_socket_socket+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket -lnsl $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 socket (); +int +main () +{ +return socket (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_socket_socket=yes +else + ac_cv_lib_socket_socket=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 +$as_echo "$ac_cv_lib_socket_socket" >&6; } +if test "x$ac_cv_lib_socket_socket" = xyes; then : + LIBS="-lsocket -lnsl $LIBS" +fi + +fi + + +NETLIBS="$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" @@ -26132,11 +26297,12 @@ if test $in_tree_ld != yes ; then # numbers can be used in ld.so.1 feature checks even if a different # linker is configured. ld_ver=`$gcc_cv_ld -V 2>&1` - if echo "$ld_ver" | grep 'Solaris Link Editors' > /dev/null; then - ld_vers=`echo $ld_ver | sed -n \ - -e 's,^.*: 5\.[0-9][0-9]*-\([0-9]\.[0-9][0-9]*\).*$,\1,p'` + if echo "$ld_ver" | $EGREP 'Solaris Link Editors|Solaris ELF Utilities' > /dev/null; then + ld_vers=`echo $ld_ver | /bin/sed -n \ + -E 's,^.*: (5|1[0-9])\.[0-9][0-9]*-([0-9]\.[0-9][0-9]*).*$,\2,p'` ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'` ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'` + ld_vers_isillumos=`echo "$ld_ver" | grep '(illumos)'` fi ;; esac @@ -32404,6 +32570,8 @@ elif test x$gcc_cv_ld != x; then # Sun ld has various bugs in .eh_frame_hdr support before version 1.2251. if test "$ld_vers_major" -gt 1 || test "$ld_vers_minor" -ge 2251; then gcc_cv_ld_eh_frame_hdr=yes + elif test "$ld_vers_minor" -ge 1735 && test -n "$ld_vers_isillumos"; then + gcc_cv_ld_eh_frame_hdr=yes fi ;; esac @@ -33437,7 +33605,7 @@ fi # realistically usable GNU/Hurd configurations. # All supported versions of musl provide it as well gcc_cv_libc_provides_ssp=yes;; - *-*-darwin* | *-*-freebsd* | *-*-netbsd*) + *-*-darwin* | *-*-freebsd* | *-*-netbsd* | *-*-solaris2*) ac_fn_cxx_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail" if test "x$ac_cv_func___stack_chk_fail" = xyes; then : gcc_cv_libc_provides_ssp=yes diff --git a/gcc/configure.ac b/gcc/configure.ac index 9f67e62950a43..d725c8dc70493 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1446,6 +1446,15 @@ EXTRA_GCC_LIBS="$LIBS" LIBS="$save_LIBS" AC_SUBST(EXTRA_GCC_LIBS) +# Solaris needs libsocket and libnsl for socket functions before 11.4. +# C++ needs those for libcody. +save_LIBS="$LIBS" +LIBS= +AX_LIB_SOCKET_NSL +NETLIBS="$LIBS" +LIBS="$save_LIBS" +AC_SUBST(NETLIBS) + # 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" @@ -3199,11 +3208,12 @@ if test $in_tree_ld != yes ; then # numbers can be used in ld.so.1 feature checks even if a different # linker is configured. ld_ver=`$gcc_cv_ld -V 2>&1` - if echo "$ld_ver" | grep 'Solaris Link Editors' > /dev/null; then - ld_vers=`echo $ld_ver | sed -n \ - -e 's,^.*: 5\.[0-9][0-9]*-\([0-9]\.[0-9][0-9]*\).*$,\1,p'` + if echo "$ld_ver" | $EGREP 'Solaris Link Editors|Solaris ELF Utilities' > /dev/null; then + ld_vers=`echo $ld_ver | /bin/sed -n \ + -E 's,^.*: (5|1[0-9])\.[0-9][0-9]*-([0-9]\.[0-9][0-9]*).*$,\2,p'` ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'` ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'` + ld_vers_isillumos=`echo "$ld_ver" | grep '(illumos)'` fi ;; esac @@ -6114,6 +6124,8 @@ elif test x$gcc_cv_ld != x; then # Sun ld has various bugs in .eh_frame_hdr support before version 1.2251. if test "$ld_vers_major" -gt 1 || test "$ld_vers_minor" -ge 2251; then gcc_cv_ld_eh_frame_hdr=yes + elif test "$ld_vers_minor" -ge 1735 && test -n "$ld_vers_isillumos"; then + gcc_cv_ld_eh_frame_hdr=yes fi ;; esac @@ -6983,7 +6995,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library, # realistically usable GNU/Hurd configurations. # All supported versions of musl provide it as well gcc_cv_libc_provides_ssp=yes;; - *-*-darwin* | *-*-freebsd* | *-*-netbsd*) + *-*-darwin* | *-*-freebsd* | *-*-netbsd* | *-*-solaris2*) AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes], [echo "no __stack_chk_fail on this target"]) ;; diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 25143c820b077..ab1b1c7bad84d 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -143,7 +143,7 @@ cc1plus-checksum.cc : build/genchecksum$(build_exeext) checksum-options \ cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(CODYLIB) $(LIBDEPS) $(c++.prev) @$(call LINK_PROGRESS,$(INDEX.c++),start) +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ - $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(CODYLIB) \ + $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(CODYLIB) $(NETLIBS) \ $(LIBS) $(BACKENDLIBS) @$(call LINK_PROGRESS,$(INDEX.c++),end) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 64a3131c19068..a072627f9b49b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -574,6 +574,7 @@ Objective-C and Objective-C++ Dialects}. -fassociative-math -fauto-profile -fauto-profile[=@var{path}] -fauto-inc-dec -fbranch-probabilities -fcaller-saves +-fclone-functions -fcombine-stack-adjustments -fconserve-stack -ffold-mem-offsets -fcompare-elim -fcprop-registers -fcrossjumping @@ -8183,6 +8184,12 @@ with multiple statement cases using flow-sensitive points-to information. Only warns when the converted pointer is dereferenced. Does not warn about incomplete types. +@opindex fstrict-calling-conventions +@item -fstrict-calling-conventions +Use strict ABI calling conventions even with local functions. +This disable certain optimizations that may cause GCC to call local +functions in a manner other than that described by the ABI. + @opindex Wstrict-overflow @opindex Wno-strict-overflow @item -Wstrict-overflow @@ -13790,6 +13797,15 @@ and then tries to find ways to combine them. Enabled by default at @option{-O1} and higher. +@opindex fno-clone-functions +@item -fno-clone-functions +Forbid the implicit cloning of functions implicit in certain +optimizations. This also effectively will disable any optimization +which wishes to clone functions, equivalent to each function having +the ``noclone'' attribute. This allows the prevention of the +dissociation of a piece of text from an intelligible and expected +symbol name, which may hamper debugging and tracing. + @opindex fipa-ra @item -fipa-ra Use caller save registers for allocation if those registers are not used by @@ -21820,6 +21836,10 @@ The default setting is @samp{tpidr_el0}. It is recommended to compile all code intended to interoperate with the same value of this option to avoid accessing a different thread pointer from the wrong exception level. +@opindex msave-args +@item -msave-args +Save integer-sized arguments on the stack on function entry. + @opindex mstrict-align @opindex mno-strict-align @item -mstrict-align diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 2437610d48daa..4c58d37818515 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -24214,6 +24214,11 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) /* Add the calling convention attribute if requested. */ add_calling_convention_attribute (subr_die, decl); +#ifdef TARGET_SAVE_ARGS + if (declaration && TARGET_SAVE_ARGS) + add_AT_flag (subr_die, DW_AT_SUN_amd64_parmdump, 1); +#endif + /* Output Dwarf info for all of the stuff within the body of the function (if it has one - it may be just a declaration). diff --git a/gcc/gcc-ar.cc b/gcc/gcc-ar.cc index 2bf727a268dd8..2f533d6839ea5 100644 --- a/gcc/gcc-ar.cc +++ b/gcc/gcc-ar.cc @@ -197,10 +197,10 @@ main (int ac, char **av) #endif /* Find the wrapped binutils program. */ - exe_name = find_a_file (&target_path, PERSONALITY, X_OK); + exe_name = find_a_file (&target_path, "g" PERSONALITY, X_OK); if (!exe_name) { - const char *real_exe_name = PERSONALITY; + const char *real_exe_name = "g" PERSONALITY; #ifdef CROSS_DIRECTORY_STRUCTURE real_exe_name = concat (target_machine, "-", PERSONALITY, NULL); #endif diff --git a/gcc/gcc.cc b/gcc/gcc.cc index 4fd87f2c4a132..4da60ea2b4e9e 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -415,7 +415,7 @@ static int do_spec_2 (const char *, const char *); static void do_option_spec (const char *, const char *); static void do_self_spec (const char *); static const char *find_file (const char *); -static int is_directory (const char *); +static int is_directory (const char *, bool); static const char *validate_switches (const char *, bool, bool); static void validate_all_switches (void); static inline void validate_switches_from_spec (const char *, bool); @@ -2947,7 +2947,7 @@ add_to_obstack (char *path, void *data) { struct add_to_obstack_info *info = (struct add_to_obstack_info *) data; - if (info->check_dir && !is_directory (path)) + if (info->check_dir && !is_directory (path, false)) return NULL; if (!info->first_time) @@ -4599,7 +4599,7 @@ driver_handle_option (struct gcc_options *opts, if appending a directory separator actually makes a valid directory name. */ if (!IS_DIR_SEPARATOR (arg[len - 1]) - && is_directory (arg)) + && is_directory (arg, false)) { char *tmp = XNEWVEC (char, len + 2); strcpy (tmp, arg); @@ -6042,7 +6042,7 @@ spec_path (char *path, void *data) memcpy (path + len, info->append, info->append_len + 1); } - if (!is_directory (path)) + if (!is_directory (path, true)) return NULL; do_spec_1 (info->option, 1, NULL); @@ -8071,10 +8071,11 @@ find_file (const char *name) return newname ? newname : name; } -/* Determine whether a directory exists. */ +/* Determine whether a directory exists. If LINKER, return 0 for + certain fixed names not needed by the linker. */ static int -is_directory (const char *path1) +is_directory (const char *path1, bool linker) { int len1; char *path; @@ -8092,6 +8093,36 @@ is_directory (const char *path1) *cp++ = '.'; *cp = '\0'; + /* Exclude directories that the linker is known to search. */ + if (linker && IS_DIR_SEPARATOR (path[0])) { + size_t len = cp - path; + + if (len >= 6 && filename_ncmp (path + 1, "lib", 3) == 0) { + if (len == 6) + return 0; + if (multilib_os_dir != NULL + && len == 6 + strlen(multilib_os_dir) + 1 + && filename_ncmp(path + 5, multilib_os_dir, + strlen(multilib_os_dir)) == 0) { + return 0; + } + } + + if (len >= 10 + && filename_ncmp (path + 1, "usr", 3) == 0 + && IS_DIR_SEPARATOR (path[4]) + && filename_ncmp (path + 5, "lib", 3) == 0) { + if (len == 10) + return 0; + if (multilib_os_dir != NULL + && len == 10 + strlen(multilib_os_dir) + 1 + && filename_ncmp(path + 9, multilib_os_dir, + strlen(multilib_os_dir)) == 0) { + return 0; + } + } + } + return (stat (path, &st) >= 0 && S_ISDIR (st.st_mode)); } diff --git a/gcc/intl.cc b/gcc/intl.cc index 629614e31b744..3fb49a8568e6d 100644 --- a/gcc/intl.cc +++ b/gcc/intl.cc @@ -74,17 +74,11 @@ gcc_init_libintl (void) if (!strcmp (open_quote, "`") && !strcmp (close_quote, "'")) { - /* Untranslated quotes that it may be possible to replace with - U+2018 and U+2019; but otherwise use "'" instead of "`" as - opening quote. */ + /* + * open_quote is ` purely for ease of translation. If they aren't + * translated, use ' for both + */ open_quote = "'"; -#if defined HAVE_LANGINFO_CODESET - if (locale_utf8) - { - open_quote = "\xe2\x80\x98"; - close_quote = "\xe2\x80\x99"; - } -#endif } } @@ -145,6 +139,3 @@ get_spaces (const char *str) spaces[len] = '\0'; return spaces; } - - - diff --git a/gcc/objcp/Make-lang.in b/gcc/objcp/Make-lang.in index 94bb512074e75..02f48c2da7d4e 100644 --- a/gcc/objcp/Make-lang.in +++ b/gcc/objcp/Make-lang.in @@ -80,7 +80,7 @@ cc1objplus$(exeext): $(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) \ @$(call LINK_PROGRESS,$(INDEX.obj-c++),start) +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ $(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) \ - $(CODYLIB) $(LIBS) $(BACKENDLIBS) + $(CODYLIB) $(NETLIBS) $(LIBS) $(BACKENDLIBS) @$(call LINK_PROGRESS,$(INDEX.obj-c++),end) # Objective C++ language specific files. diff --git a/gcc/opts.cc b/gcc/opts.cc index ffcbdfef0bd99..86e6453e39c10 100644 --- a/gcc/opts.cc +++ b/gcc/opts.cc @@ -588,7 +588,7 @@ static const struct default_options default_options_table[] = { OPT_LEVELS_1_PLUS, OPT_fipa_reference, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fipa_reference_addressable, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fmerge_constants, NULL, 1 }, - { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 }, + { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 0 }, { OPT_LEVELS_1_PLUS, OPT_freorder_blocks, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fshrink_wrap, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fsplit_wide_types, NULL, 1 }, @@ -626,6 +626,7 @@ static const struct default_options default_options_table[] = { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_pta, NULL, 1 }, { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_sra, NULL, 1 }, + /* -O2 and -Os optimizations. */ { OPT_LEVELS_2_PLUS, OPT_fcaller_saves, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_fcode_hoisting, NULL, 1 }, diff --git a/gcc/testsuite/gcc.dg/fno-clone-preserves-unused-args.c b/gcc/testsuite/gcc.dg/fno-clone-preserves-unused-args.c new file mode 100644 index 0000000000000..0955381c84807 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fno-clone-preserves-unused-args.c @@ -0,0 +1,28 @@ +/* { dg-do compile { target { ilp32 } } } */ +/* { dg-options "-O2 -funit-at-a-time -fipa-sra -fno-clone-functions" } */ +/* { dg-final { scan-assembler "pushl.*\\\$1" } } */ +/* { dg-final { scan-assembler "pushl.*\\\$2" } } */ +/* { dg-final { scan-assembler "pushl.*\\\$3" } } */ +/* { dg-final { scan-assembler "pushl.*\\\$4" } } */ +/* { dg-final { scan-assembler "pushl.*\\\$5" } } */ + +#include + +/* + * Verify that preventing function cloning prevents constant prop/scalar + * reduction removing parameters + */ +static void +t(int, int, int, int, int) __attribute__ ((noinline)); + +int foo() +{ + t(1, 2, 3, 4, 5); +} + +/* Only use 3 params, bait constprop/sra into deleting the other two */ +static void +t(int a, int b, int c, int d, int e) +{ + printf("%d %d\n", a, b, c); +} diff --git a/gcc/testsuite/gcc.dg/format/cmn-err-1.c b/gcc/testsuite/gcc.dg/format/cmn-err-1.c index aea7779a2c3b4..cbb4a1f927c32 100644 --- a/gcc/testsuite/gcc.dg/format/cmn-err-1.c +++ b/gcc/testsuite/gcc.dg/format/cmn-err-1.c @@ -17,12 +17,21 @@ int main() int i = 1; long l = 2; llong ll = 3; + char hh = 4; + short h = 5; + size_t z = 6; + uintmax_t j = 7; cmn_err_func (0, "%s", string); cmn_err_func (0, "%d %D %o %O %x %X %u", i, i, i, i, i, i, i); cmn_err_func (0, "%ld %lD %lo %lO %lx %lX %lu", l, l, l, l, l, l, l); cmn_err_func (0, "%lld %llD %llo %llO %llx %llX %llu", ll, ll, ll, ll, ll, ll, ll); + cmn_err_func (0, "%hd %hD %ho %hO %hx %hX %hu", h, h, h, h, h, h, h); + cmn_err_func (0, "%hhd %hhD %hho %hhO %hhx %hhX %hhu", + hh, hh, hh, hh, hh, hh, hh); + cmn_err_func (0, "%jd %jD %jo %jO %jx %jX %ju", j, j, j, j, j, j, j); + cmn_err_func (0, "%zd %zD %zo %zO %zx %zX %zu", z, z, z, z, z, z, z); cmn_err_func (0, "%b %s", i, "\01Foo", string); cmn_err_func (0, "%p", string); cmn_err_func (0, "%16b", i, "\01Foo"); diff --git a/gcc/testsuite/gcc.dg/rtl/x86_64/pro_and_epilogue.c b/gcc/testsuite/gcc.dg/rtl/x86_64/pro_and_epilogue.c index b6f723a6e6020..ed5db9cace3b7 100644 --- a/gcc/testsuite/gcc.dg/rtl/x86_64/pro_and_epilogue.c +++ b/gcc/testsuite/gcc.dg/rtl/x86_64/pro_and_epilogue.c @@ -1,5 +1,6 @@ /* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */ /* { dg-options "-fdump-rtl-pro_and_epilogue" } */ +/* { dg-skip-if "RTL in test doesn't save arguments" { *-*-* } "-msave-args" "" } */ /* Lightly-modified dump of test.c.274r.split2 for x86_64. */ @@ -95,7 +96,7 @@ int __RTL (startwith ("pro_and_epilogue")) test_1 (int i, int j, int k) (cnote 31 NOTE_INSN_DELETED) ) ;; insn-chain (crtl - (return_rtx + (return_rtx (reg/i:SI ax) ) ;; return_rtx ) ;; crtl @@ -107,4 +108,3 @@ int __RTL (startwith ("pro_and_epilogue")) test_1 (int i, int j, int k) /* We expect a jump_insn to "simple_return". */ /* { dg-final { scan-rtl-dump-times "simple_return" 2 "pro_and_epilogue" } } */ - diff --git a/gcc/testsuite/gcc.target/i386/local.c b/gcc/testsuite/gcc.target/i386/local.c index f4444951e123e..3a487583d81f7 100644 --- a/gcc/testsuite/gcc.target/i386/local.c +++ b/gcc/testsuite/gcc.target/i386/local.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -funit-at-a-time" } */ +/* { dg-options "-O2 -funit-at-a-time -fno-strict-calling-conventions" { target ia32 } } */ +/* { dg-options "-O2 -funit-at-a-time" { target lp64 } } */ /* { dg-final { scan-assembler "magic\[^\\n\]*eax" { target ia32 } } } */ /* { dg-final { scan-assembler "magic\[^\\n\]*(edi|ecx)" { target { ! ia32 } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/msave-args-mov.c b/gcc/testsuite/gcc.target/i386/msave-args-mov.c new file mode 100644 index 0000000000000..a2ca76752a96e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/msave-args-mov.c @@ -0,0 +1,26 @@ +/* { dg-do run { target { { i?86-*-solaris2.* } && lp64 } } } */ +/* { dg-options "-msave-args -mforce-save-regs-using-mov -save-temps" } */ + +#include + +void t(int, int, int, int, int) __attribute__ ((noinline)); + +int +main(int argc, char **argv) +{ + t(1, 2, 3, 4, 5); + return (0); +} + +void +t(int a, int b, int c, int d, int e) +{ + printf("%d %d %d %d %d", a, b, c, d, e); +} + +/* { dg-final { scan-assembler "movq\t%rdi, -8\\(%rbp\\)" } } */ +/* { dg-final { scan-assembler "movq\t%rsi, -16\\(%rbp\\)" } } */ +/* { dg-final { scan-assembler "movq\t%rdx, -24\\(%rbp\\)" } } */ +/* { dg-final { scan-assembler "movq\t%rcx, -32\\(%rbp\\)" } } */ +/* { dg-final { scan-assembler "movq\t%r8, -40\\(%rbp\\)" } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/msave-args-push.c b/gcc/testsuite/gcc.target/i386/msave-args-push.c new file mode 100644 index 0000000000000..fbe053dadc8b9 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/msave-args-push.c @@ -0,0 +1,26 @@ +/* { dg-do run { target { { i?86-*-solaris2.* } && lp64 } } } */ +/* { dg-options "-msave-args -save-temps " } */ + +#include + +void t(int, int, int, int, int) __attribute__ ((noinline)); + +int +main(int argc, char **argv) +{ + t(1, 2, 3, 4, 5); + return (0); +} + +void +t(int a, int b, int c, int d, int e) +{ + printf("%d %d %d %d %d", a, b, c, d, e); +} + +/* { dg-final { scan-assembler "pushq\t%rdi" } } */ +/* { dg-final { scan-assembler "pushq\t%rsi" } } */ +/* { dg-final { scan-assembler "pushq\t%rdx" } } */ +/* { dg-final { scan-assembler "pushq\t%rcx" } } */ +/* { dg-final { scan-assembler "pushq\t%r8" } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr78691-i386.c b/gcc/testsuite/gcc.target/i386/pr78691-i386.c index f4b88559bc3e9..5f8c91bc370b4 100644 --- a/gcc/testsuite/gcc.target/i386/pr78691-i386.c +++ b/gcc/testsuite/gcc.target/i386/pr78691-i386.c @@ -1,5 +1,6 @@ /* PR tree-optimization/78691 */ /* { dg-options "-Os -m16" } */ +/* { dg-skip-if "" { *-*-* } "-msave-args" "" } */ int fn1(char *p1, char *p2) { int a; diff --git a/gcc/testsuite/gcc.target/i386/pr80569.c b/gcc/testsuite/gcc.target/i386/pr80569.c index 8314bc128ec58..92a86380f781c 100644 --- a/gcc/testsuite/gcc.target/i386/pr80569.c +++ b/gcc/testsuite/gcc.target/i386/pr80569.c @@ -1,8 +1,7 @@ /* PR target/80569 */ /* { dg-do assemble } */ /* { dg-options "-O2 -m16 -march=haswell" } */ -/* Non-gas assemblers choke on .code16gcc. */ -/* { dg-require-effective-target gas } */ +/* { dg-skip-if "" { *-*-* } "-msave-args" "" } */ void load_kernel(void *setup_addr) { diff --git a/gcc/testsuite/gcc.target/i386/retarg.c b/gcc/testsuite/gcc.target/i386/retarg.c index a69b60feaf4ec..3967ef76b1f2d 100644 --- a/gcc/testsuite/gcc.target/i386/retarg.c +++ b/gcc/testsuite/gcc.target/i386/retarg.c @@ -1,5 +1,6 @@ /* { dg-do compile { target { ! ia32 } } } */ /* { dg-options "-O2" } */ +/* { dg-skip-if "" { *-*-* } "-msave-args" "" } */ #include diff --git a/gcc/testsuite/gcc.target/i386/strict-cc.c b/gcc/testsuite/gcc.target/i386/strict-cc.c new file mode 100644 index 0000000000000..fa0543e52ff69 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/strict-cc.c @@ -0,0 +1,24 @@ +/* { dg-do compile { target { ilp32 } } } */ +/* { dg-options "-O2 -funit-at-a-time -fstrict-calling-conventions" } */ +/* { dg-final { scan-assembler "pushl.*\\\$1" } } */ +/* { dg-final { scan-assembler "pushl.*\\\$2" } } */ +/* { dg-final { scan-assembler "pushl.*\\\$3" } } */ +/* { dg-final { scan-assembler "pushl.*\\\$4" } } */ +/* { dg-final { scan-assembler "pushl.*\\\$5" } } */ + +#include + +/* Verify that local calling convention is not used if strict conventions. */ +static int t(int, int, int, int, int) __attribute__ ((noinline)); + +int +m() +{ + t(1, 2, 3, 4, 5); +} + +static int +t(int a, int b, int c, int d, int e) +{ + printf("%d\n", a, b, c, d, e); +} diff --git a/include/dwarf2.def b/include/dwarf2.def index 989f078041d4a..37f2477b400c2 100644 --- a/include/dwarf2.def +++ b/include/dwarf2.def @@ -470,6 +470,8 @@ DW_TAG (DW_AT_GNU_denominator, 0x2304) /* Biased integer extension. See https://gcc.gnu.org/wiki/DW_AT_GNU_bias . */ DW_TAG (DW_AT_GNU_bias, 0x2305) +/* Sun extension. */ +DW_AT (DW_AT_SUN_amd64_parmdump, 0x2224) /* UPC extension. */ DW_AT (DW_AT_upc_threads_scaled, 0x3210) /* PGI (STMicroelectronics) extensions. */ diff --git a/libgcc/config.host b/libgcc/config.host index 6a88ee5a2dd0b..618cd9f53a7e6 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -342,7 +342,7 @@ case ${host} in *-*-solaris2*) # Unless linker support and dl_iterate_phdr are present, # unwind-dw2-fde-dip.c automatically falls back to unwind-dw2-fde.c. - tmake_file="$tmake_file sol2/t-sol2 t-eh-dw2-dip t-crtstuff-pic t-libgcc-pic t-slibgcc t-slibgcc-elf-ver" + tmake_file="$tmake_file sol2/t-sol2 t-eh-dw2-dip t-crtstuff-pic t-libgcc-pic t-slibgcc t-slibgcc-elf-ver t-crtstuff-pic" if test $with_gnu_ld = yes; then tmake_file="$tmake_file t-slibgcc-gld" else diff --git a/libgo/go/cmd/go/internal/work/gccgo.go b/libgo/go/cmd/go/internal/work/gccgo.go index 3e07f8791ebc4..23954e0a3def1 100644 --- a/libgo/go/cmd/go/internal/work/gccgo.go +++ b/libgo/go/cmd/go/internal/work/gccgo.go @@ -46,7 +46,7 @@ func (gccgoToolchain) linker() string { } func (gccgoToolchain) ar() []string { - return envList("AR", "ar") + return envList("AR", "/usr/bin/gar") } func checkGccgoBin() { diff --git a/libgo/go/go/internal/gccgoimporter/importer_test.go b/libgo/go/go/internal/gccgoimporter/importer_test.go index 8a7ee1aa4ffa9..fecf181117092 100644 --- a/libgo/go/go/internal/gccgoimporter/importer_test.go +++ b/libgo/go/go/internal/gccgoimporter/importer_test.go @@ -180,7 +180,7 @@ func TestObjImporter(t *testing.T) { runImporterTest(t, imp, initmap, &test) - cmd = exec.Command("ar", "cr", afile, ofile) + cmd = exec.Command("/usr/bin/gar", "cr", afile, ofile) out, err = cmd.CombinedOutput() if err != nil { t.Logf("%s", out) diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index 3a30748d3291f..29efc3e26c9f0 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -12,6 +12,10 @@ #include "config.h" #ifdef HAVE_DL_ITERATE_PHDR +#ifdef __sun +#undef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 32 +#endif #include #endif diff --git a/libobjc/Makefile.in b/libobjc/Makefile.in index 3f4186deeaabb..e516072ef018b 100644 --- a/libobjc/Makefile.in +++ b/libobjc/Makefile.in @@ -308,14 +308,16 @@ $(srcdir)/configure: @MAINT@ configure.ac $(srcdir)/aclocal.m4 $(srcdir)/aclocal.m4: @MAINT@ $(aclocal_deps) cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -install: install-libs install-headers +install-strip: INSTALL_STRIP_FLAG = -s +install install-strip: install-libs install-headers install-libs: installdirs $(SHELL) $(multi_basedir)/mkinstalldirs $(DESTDIR)$(toolexeclibdir) - $(LIBTOOL_INSTALL) $(INSTALL) libobjc$(libsuffix).la $(DESTDIR)$(toolexeclibdir); + $(LIBTOOL_INSTALL) $(INSTALL) $(INSTALL_STRIP_FLAG) \ + libobjc$(libsuffix).la $(DESTDIR)$(toolexeclibdir); if [ "$(OBJC_BOEHM_GC)" ]; then \ - $(LIBTOOL_INSTALL) $(INSTALL) libobjc_gc$(libsuffix).la \ - $(DESTDIR)$(toolexeclibdir);\ + $(LIBTOOL_INSTALL) $(INSTALL) $(INSTALL_STRIP_FLAG) \ + libobjc_gc$(libsuffix).la $(DESTDIR)$(toolexeclibdir);\ fi $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO="$@" @-$(LIBTOOL) --mode=finish $(DESTDIR)$(toolexeclibdir) @@ -328,7 +330,7 @@ install-headers: $(INSTALL_DATA) $${realfile} $(DESTDIR)$(libsubdir)/$(includedirname)/objc; \ done -check uninstall install-strip dist installcheck installdirs: +check uninstall dist installcheck installdirs: mostlyclean: -$(LIBTOOL_CLEAN) rm -f libobjc$(libsuffix).la libobjc_gc$(libsuffix).la *.lo diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_solaris.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_solaris.h index 84a81265162c6..f9c9b84dcadda 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_solaris.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_solaris.h @@ -19,6 +19,9 @@ #include "sanitizer_internal_defs.h" #include "sanitizer_platform.h" +struct stat; +struct dirent; + namespace __sanitizer { extern unsigned struct_utsname_sz; extern unsigned struct_stat_sz; @@ -337,6 +340,14 @@ struct __sanitizer_glob_t { uptr gl_offs; char **gl_pathp; int gl_pathn; + int gl_matchc; + int gl_flags; + struct stat **gl_statv; + void (*gl_closedir)(void *); + struct dirent *(*gl_readdir)(void *); + void *(*gl_opendir)(const char *); + int (*gl_lstat)(const char *, struct stat *); + int (*gl_stat)(const char *, struct stat *); }; extern int glob_nomatch; diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index a0094c2dd95b4..5b9173610c0fe 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -2774,7 +2774,7 @@ dnl AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]], [use MODEL for target locale package], - [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto]) + [permit generic|gnu|ieee_1003.1-2001|newlib|dragonfly|yes|no|auto]) # Deal with gettext issues. Default to not using it (=no) until we detect # support for it later. Let the user turn it off via --e/d, but let that diff --git a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc b/libstdc++-v3/config/locale/dragonfly/ctype_members.cc index 880c8fc3e3182..afe1a3ee700d5 100644 --- a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc +++ b/libstdc++-v3/config/locale/dragonfly/ctype_members.cc @@ -135,6 +135,66 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __hi; } +/* + * Taken verbatim from config/locale/generic/ctype_members.cc. DragonFly + * implements these in config/os/bsd/dragonfly/ctype_inline.h. + */ +#if defined(__illumos__) + bool + ctype:: + do_is(mask __m, char_type __c) const + { + bool __ret = false; + // Generically, 15 (instead of 11) since we don't know the numerical + // encoding of the various categories in /usr/include/ctype.h. + const size_t __bitmasksize = 15; + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) + if (__m & _M_bit[__bitcur] + && iswctype(__c, _M_wmask[__bitcur])) + { + __ret = true; + break; + } + return __ret; + } + + const wchar_t* + ctype:: + do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const + { + for (;__lo < __hi; ++__vec, ++__lo) + { + // Generically, 15 (instead of 11) since we don't know the numerical + // encoding of the various categories in /usr/include/ctype.h. + const size_t __bitmasksize = 15; + mask __m = 0; + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) + if (iswctype(*__lo, _M_wmask[__bitcur])) + __m |= _M_bit[__bitcur]; + *__vec = __m; + } + return __hi; + } + + const wchar_t* + ctype:: + do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const + { + while (__lo < __hi && !this->do_is(__m, *__lo)) + ++__lo; + return __lo; + } + + const wchar_t* + ctype:: + do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const + { + while (__lo < __hi && this->do_is(__m, *__lo) != 0) + ++__lo; + return __lo; + } +#endif + wchar_t ctype:: do_widen(char __c) const diff --git a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc b/libstdc++-v3/config/locale/dragonfly/monetary_members.cc index 16e995a57dce1..ebce539e2d888 100644 --- a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc +++ b/libstdc++-v3/config/locale/dragonfly/monetary_members.cc @@ -37,10 +37,36 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + extern wchar_t lconv2wchar(char *conv, wchar_t def, locale_t __cloc); + extern char lconv2char(char *conv, char def); + // This file might be compiled twice, but we only want to define the members // of money_base once. #if ! _GLIBCXX_USE_CXX11_ABI + wchar_t lconv2wchar(char *conv, wchar_t def, locale_t __cloc) + { + wchar_t w = def; + const size_t tlen = strlen(conv); + if (tlen == 1) + w = (wchar_t) conv[0]; + + int clen = mbtowc_l(&w, conv, tlen, __cloc); + if (clen <= 0) + return def; + else + return w; + } + + char lconv2char(char *conv, char def) + { + wchar_t w = def; + const size_t tlen = strlen(conv); + if (tlen == 1) + w = (wchar_t) conv[0]; + return w; + } + // Construct and return valid pattern consisting of some combination of: // space none symbol sign value money_base::pattern @@ -283,7 +309,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - _M_data->_M_thousands_sep = lc->mon_thousands_sep[0]; + _M_data->_M_thousands_sep = lconv2char(lc->mon_thousands_sep, ','); __len = strlen(__cgroup); if (__len) @@ -437,7 +463,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - _M_data->_M_thousands_sep = lc->mon_thousands_sep[0]; + _M_data->_M_thousands_sep = lconv2char(lc->mon_thousands_sep, ','); __len = strlen(__cgroup); if (__len) @@ -624,8 +650,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - _M_data->_M_thousands_sep = - (wchar_t)lc->mon_thousands_sep[0]; + _M_data->_M_thousands_sep = lconv2wchar(lc->mon_thousands_sep, L',', (locale_t)__cloc); __len = strlen(__cgroup); if (__len) { @@ -784,8 +809,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - _M_data->_M_thousands_sep = - (wchar_t)lc->mon_thousands_sep[0]; + _M_data->_M_thousands_sep = lconv2wchar(lc->mon_thousands_sep, L',', (locale_t)__cloc); __len = strlen(__cgroup); if (__len) { diff --git a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc b/libstdc++-v3/config/locale/dragonfly/numeric_members.cc index c5df5b8c11b1f..731a349a63758 100644 --- a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc +++ b/libstdc++-v3/config/locale/dragonfly/numeric_members.cc @@ -37,6 +37,9 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + extern wchar_t lconv2wchar(char *conv, wchar_t def, locale_t __cloc); + extern char lconv2char(char *conv, char def); + template<> void numpunct::_M_initialize_numpunct(__c_locale __cloc) @@ -86,7 +89,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - _M_data->_M_thousands_sep = lc->thousands_sep[0]; + _M_data->_M_thousands_sep = lconv2char(lc->thousands_sep, ','); const char* __src = lc->grouping; const size_t __len = strlen(__src); @@ -185,7 +188,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - _M_data->_M_thousands_sep = (wchar_t)lc->thousands_sep[0]; + _M_data->_M_thousands_sep = lconv2wchar(lc->thousands_sep, L',', (locale_t)__cloc); const char* __src = lc->grouping; const size_t __len = strlen(__src); diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 819a1d82876a1..9887fcd171564 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -16636,7 +16636,7 @@ $as_echo "stdio (with POSIX read/write)" >&6; } if test "${enable_clocale+set}" = set; then : enableval=$enable_clocale; case "$enableval" in - generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto) ;; + generic|gnu|ieee_1003.1-2001|newlib|dragonfly|yes|no|auto) ;; *) as_fn_error $? "Unknown argument to enable/disable clocale" "$LINENO" 5 ;; esac @@ -55214,6 +55214,12 @@ done tmake_file="${tmake_file_}" +case "${target}" in *-*-solaris2*) + EXTRA_CFLAGS="$EXTRA_CFLAGS -D_TS_ERRNO" + EXTRA_CXX_FLAGS="$EXTRA_CXX_FLAGS -D_TS_ERRNO" +esac + + # Add CET specific flags if Intel CET is enabled. # Check whether --enable-cet was given. if test "${enable_cet+set}" = set; then : diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index a6c01b29e94b1..abf17951212c8 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -676,6 +676,11 @@ done tmake_file="${tmake_file_}" AC_SUBST(tmake_file) +case "${target}" in *-*-solaris2*) + EXTRA_CFLAGS="$EXTRA_CFLAGS -D_TS_ERRNO" + EXTRA_CXX_FLAGS="$EXTRA_CXX_FLAGS -D_TS_ERRNO" +esac + # Add CET specific flags if Intel CET is enabled. GCC_CET_FLAGS(CET_FLAGS) EXTRA_CXX_FLAGS="$EXTRA_CXX_FLAGS $CET_FLAGS" diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 937a8224756e8..0b6c26b89a677 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -296,7 +296,11 @@ proc add_options_for_no_pch { flags } { # Add to FLAGS all the target-specific flags needed for networking. proc add_options_for_net_ts { flags } { - if { [istarget *-*-rtems*] } { + # Before they were integrated into libc in Solaris 11.4, Solaris needs + # libsocket and libnsl for networking applications. + if { [istarget *-*-solaris2*] } { + return "$flags -lsocket -lnsl" + } elseif { [istarget *-*-rtems*] } { return "$flags -lbsd -Wl,--gc-sections" } return $flags