diff --git a/lang/gcc7-libs/Makefile b/lang/gcc7-libs/Makefile index 80cc5f6fa90f..c70bde46d238 100644 --- a/lang/gcc7-libs/Makefile +++ b/lang/gcc7-libs/Makefile @@ -29,6 +29,9 @@ RELRO_SUPPORTED= no ## Depend on exactly ${GCC7_DIST_VERSION}. TOOL_DEPENDS+= ${GCC_PKGNAME}-${GCC7_DIST_VERSION}{,nb[0-9]*}:../../lang/gcc7 +# Finds libs from gcc7 due to rpath +CHECK_SHLIBS= no + .include "../../mk/bsd.prefs.mk" LIBGCC_SUBPREFIX= ${GCC_PKGNAME} @@ -47,23 +50,34 @@ SHLIB_EXT= so .endif LIBRARY_FILES= ${WRKDIR}/lib_files +OBJECT_FILES= ${WRKDIR}/obj_files GENERATE_PLIST+= ${SED} -e 's,^,${LIBGCC_SUBPREFIX}/${GCC_TARGET_MACHINE}/,' \ - ${LIBRARY_FILES}; + -e 's,gcc/${MACHINE_GNU_PLATFORM}/${GCC7_DIST_VERSION}/,,' \ + ${LIBRARY_FILES} ${OBJECT_FILES}; GENERATE_PLIST+= ${GREP} -q 'lib/' ${LIBRARY_FILES} || \ ${ECHO} '@pkgdir ${LIBGCC_SUBPREFIX}/${GCC_TARGET_MACHINE}/lib'; ${LIBRARY_FILES}: ${PKG_INFO} -qL '${GCC_PKGNAME}-${GCC7_DIST_VERSION}*' | \ ${SED} -n -e's,^${LIBGCC_PREFIX}/,,' -e'/libexec\//d' \ - -e'/libgij/d;/libgcj/d;/libjvm/d' \ + -e'/libgij/d;/libgcj/d;/libjvm/d;/libgo\./d' \ + -e'/libcc1plugin/d;/libcp1plugin/d;' \ -e'/lib.*\.${SHLIB_EXT}/p' >${LIBRARY_FILES} -do-install: ${LIBRARY_FILES} +${OBJECT_FILES}: + ${PKG_INFO} -qL '${GCC_PKGNAME}-${GCC7_DIST_VERSION}*' | \ + ${SED} -n -e 's,^${LIBGCC_PREFIX}/,,' \ + -e '/\.o/p' -e '/libgcc\.a/p' -e '/libssp_nonshared\.a/p' >${OBJECT_FILES} + +do-install: ${LIBRARY_FILES} ${OBJECT_FILES} ${TEST} -d ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/lib || \ ${MKDIR} ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/lib cd ${LIBGCC_PREFIX} && \ ${PAX} -rw ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE} <${LIBRARY_FILES} + cd ${LIBGCC_PREFIX} && \ + ${PAX} -r -s ',gcc/${MACHINE_GNU_PLATFORM}/${GCC7_DIST_VERSION}/,,' \ + -w ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE} <${OBJECT_FILES} .include "../../mk/dlopen.buildlink3.mk" .include "../../mk/pthread.buildlink3.mk" diff --git a/lang/gcc7/ALTERNATIVES b/lang/gcc7/ALTERNATIVES new file mode 100644 index 000000000000..44c2b65d94c2 --- /dev/null +++ b/lang/gcc7/ALTERNATIVES @@ -0,0 +1,20 @@ +bin/c++ @PREFIX@/gcc7/bin/c++ +bin/cc @PREFIX@/gcc7/bin/cc +bin/cpp @PREFIX@/gcc7/bin/cpp +bin/g++ @PREFIX@/gcc7/bin/g++ +bin/gcc @PREFIX@/gcc7/bin/gcc +bin/gcc-ar @PREFIX@/gcc7/bin/gcc-ar +bin/gcc-nm @PREFIX@/gcc7/bin/gcc-nm +bin/gcc-ranlib @PREFIX@/gcc7/bin/gcc-ranlib +bin/gcov @PREFIX@/gcc7/bin/gcov +bin/gcov-dump @PREFIX@/gcc7/bin/gcov-dump +bin/gcov-tool @PREFIX@/gcc7/bin/gcov-tool +bin/gfortran @PREFIX@/gcc7/bin/gfortran +bin/@MACHINE_GNU_PLATFORM@-c++ @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-c++ +bin/@MACHINE_GNU_PLATFORM@-g++ @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-g++ +bin/@MACHINE_GNU_PLATFORM@-gcc @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gcc +bin/@MACHINE_GNU_PLATFORM@-gcc-@GCC7_DIST_VERSION@ @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gcc-@GCC7_DIST_VERSION@ +bin/@MACHINE_GNU_PLATFORM@-gcc-ar @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gcc-ar +bin/@MACHINE_GNU_PLATFORM@-gcc-nm @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gcc-nm +bin/@MACHINE_GNU_PLATFORM@-gcc-ranlib @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gcc-ranlib +bin/@MACHINE_GNU_PLATFORM@-gfortran @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gfortran diff --git a/lang/gcc7/Makefile b/lang/gcc7/Makefile index e9b39be3000b..e735346ee9eb 100644 --- a/lang/gcc7/Makefile +++ b/lang/gcc7/Makefile @@ -50,6 +50,9 @@ FORCE_C_STD= gnu99 UNLIMIT_RESOURCES+= datasize UNLIMIT_RESOURCES+= stacksize +FILES_SUBST+= GCC7_DIST_VERSION=${GCC7_DIST_VERSION} +FILES_SUBST+= MACHINE_GNU_PLATFORM=${MACHINE_GNU_PLATFORM} + SUBST_CLASSES+= vars SUBST_MESSAGE.vars= Setting target machine name path in ${SUBST_FILES.vars} SUBST_STAGE.vars= pre-configure @@ -63,6 +66,28 @@ CHECK_PORTABILITY_SKIP+= \ .include "../../mk/bsd.prefs.mk" +# This includes some multiarch configuration but is left in the miscfix branch +# to ease merging. +SUBST_CLASSES+= rpaths +SUBST_STAGE.rpaths= pre-configure +SUBST_FILES.rpaths= gcc/config/sol2.h +SUBST_VARS.rpaths= PREFIX +.if !empty(MULTIARCH:M[Yy][Ee][Ss]) +SUBST_SED.rpaths= -e 's,@MARCH64_SUBDIR@,ARCH64_SUBDIR,g' +SUBST_SED.rpaths+= -e 's,@MARCH64_SLASH@,/,g' +.else +SUBST_SED.rpaths= -e 's,@MARCH64_SUBDIR@,,g' +SUBST_SED.rpaths+= -e 's,@MARCH64_SLASH@,,g' +.endif +# For the tools build (i.e. when not using USE_GCC_LOCALBASE_PREFIX) we +# do not want to include any of the PREFIX library paths added by +# patch-gcc_config_sol2.h, otherwise they would leak into the non-tools +# builds. The SUBST used here relies on SUBST_VARS coming after SUBST_SED. +.if ${USE_GCC_LOCALBASE_PREFIX:Uno:tl} == "no" +SUBST_SED.rpaths+= -e '/-R@PREFIX@/d' +SUBST_SED.rpaths+= -e 's/:%R@PREFIX@[^}]*//' +.endif + LANGS= c # In some cases LINKER_RPATH_FLAG needs a trailing space. @@ -122,7 +147,11 @@ CFLAGS+= -Wno-missing-attributes CONFIGURE_ARGS+= --enable-languages=${LANGS:Q} CONFIGURE_ARGS+= --enable-shared CONFIGURE_ARGS+= --enable-long-long +.if ${USE_GCC_LOCALBASE_PREFIX:Uno:tl} == "yes" +CONFIGURE_ARGS+= --with-local-prefix=${LOCALBASE:Q} +.else CONFIGURE_ARGS+= --with-local-prefix=${GCC_PREFIX:Q} +.endif CONFIGURE_ARGS+= --enable-threads=posix CONFIGURE_ARGS+= --with-boot-ldflags=${BOOT_LDFLAGS:Q} # multilib on Darwin requires fat-binaries @@ -163,6 +192,8 @@ MAKE_ENV+= lt_cv_path_SED=${TOOLS_SED} # Determine whether to use binutils .if ${OPSYS} == "SunOS" +# Disable --as-needed as it pulls in libgcc_s as a dependency. +MAKE_ENV+= gcc_cv_ld_as_needed=no . if exists(/usr/sfw/bin/gobjdump) CONFIGURE_ENV+= OBJDUMP=/usr/sfw/bin/gobjdump . endif @@ -213,6 +244,8 @@ GENERATE_PLIST+= \ cd ${DESTDIR}${PREFIX} && \ ${FIND} ${GCC_SUBPREFIX} \( -type f -o -type l \) -print | ${SORT}; +CTF_FILES_SKIP+= */gengtype + .include "../../mk/dlopen.buildlink3.mk" .include "../../mk/pthread.buildlink3.mk" .include "../../mk/bsd.pkg.mk" diff --git a/lang/gcc7/distinfo b/lang/gcc7/distinfo index 80267d859ca1..a0ddba6670f0 100644 --- a/lang/gcc7/distinfo +++ b/lang/gcc7/distinfo @@ -8,6 +8,8 @@ SHA512 (isl-0.18.tar.bz2) = 85d0b40f4dbf14cb99d17aa07048cdcab2dc3eb527d2fbb1e84c Size (isl-0.18.tar.bz2) = 1658291 bytes SHA1 (patch-contrib_download__prerequisites) = 86c6c16e0e3e3a0bcb38579a8b4004f603fac1ca SHA1 (patch-gcc_Makefile.in) = d96a57a098e49a2c5ea6478dd5d22aba584fc1bc +SHA1 (patch-gcc_caller-save.c) = 8b667a6d3129a912339c23a6ed64b10ccca7733f +SHA1 (patch-gcc_common.opt) = b7123b7119c524da1bc310429da9fd0338e17b55 SHA1 (patch-gcc_common_config_arm_arm-common.c) = 7c973cb9554a52f4b85f8fc98708f5e5cce8e8bd SHA1 (patch-gcc_config.gcc) = 20d1444cc2c031c8adc96289e1ccc6c1d29eb72f SHA1 (patch-gcc_config.host) = 1b1e11cd199eb93f49443d51c0063b09b7327858 @@ -22,26 +24,42 @@ SHA1 (patch-gcc_config_arm_netbsd-eabi.h) = 9c1d2148e306024e8de3bdc9802fb63b976e SHA1 (patch-gcc_config_arm_netbsd-elf.h) = 80a07645fab197969b4a6f518fdc81bda7376375 SHA1 (patch-gcc_config_darwin-driver.c) = d6e59feef5f6611aabd56028ca29db5919797f88 SHA1 (patch-gcc_config_host-netbsd.c) = 765295f07edb8a68f1910e3a9b4dd2a7dcd491a5 +SHA1 (patch-gcc_config_i386_i386.c) = cd11cff11c217eed3601da9cd209b5cb74fd0dad +SHA1 (patch-gcc_config_i386_i386.h) = b23863a9baf6d5aa20939e0d58ca343db15c8513 +SHA1 (patch-gcc_config_i386_i386.opt) = f0e325859409bd10a6fb60a85d659a23509f2f27 SHA1 (patch-gcc_config_netbsd-elf.h) = 5a9b5ef26c03bec3cd58e2f446224aa6e94a30d5 SHA1 (patch-gcc_config_netbsd-protos.h) = 6d28864b4ccc8c1a63fe28e43601b84b63a00633 SHA1 (patch-gcc_config_netbsd.h) = 662226f4491f94b641f78b1273a9047434d75aed +SHA1 (patch-gcc_config_sol2-c.c) = 7dac7d9a4111240fbff9099d7a9bcd08c898b07d +SHA1 (patch-gcc_config_sol2.h) = b948b5e02c5b5e8bc0f86a5e579f5e6c714cf6cd SHA1 (patch-gcc_config_sparc_sparc.c) = 7d37f33744d620faa5a2154056ba80bede0d67f6 SHA1 (patch-gcc_config_t-netbsd) = 802ad5706aa7ca9629f8e237f08fbb1569d28846 SHA1 (patch-gcc_config_x-netbsd) = 6dc3d78e26df62054ea29f98ca51592858e671e3 -SHA1 (patch-gcc_configure) = 15fb7af267b79965f83bc64ce8aad1279b0ea52d +SHA1 (patch-gcc_configure) = 1b66a9ac0af5e3be39410f82b1de84f217f5c2ef +SHA1 (patch-gcc_dojump.c) = 8b6f5263e7ce251aa0a00f24cc06daf84d290eec +SHA1 (patch-gcc_dwarf2out.c) = 1cd7645095205b340305094fd31ed475fa1cc927 SHA1 (patch-gcc_ggc-common.c) = a5d2dba635859f5d680c3f80d7c30b42461c752b SHA1 (patch-gcc_ginclude_stddef.h) = fb1f83801e0f5bcec110667dc868c47ff2d10343 +SHA1 (patch-gcc_ira.c) = aa4b8d35356201f307f568238817e870a0527542 SHA1 (patch-gcc_lto_lto.c) = 825b632e2a7ff5777d4fbfdcf6f0ea3f64c4742b SHA1 (patch-gcc_plugin.c) = 7a7ebc6650fe327fa7be1f7a4d26e8edc7597fcf +SHA1 (patch-gcc_symtab.c) = a84091f6892e421081546ce3ea381e771f0041db SHA1 (patch-gcc_system.h) = 4c959a6b1c4d524cbdf44cfb80f0e5758ec20783 SHA1 (patch-gcc_targhooks.c) = 6268d548058b6325ead1115f78c2c17c6d786296 +SHA1 (patch-gcc_testsuite_gcc.dg_fno-clone-preserves-unused-args.c) = e3b58e623df14d01fdcdb7ae1978b1876cedf657 +SHA1 (patch-gcc_testsuite_gcc.target_i386_local.c) = a6f2f056cb742f8723d775746e0394b7ada02c37 +SHA1 (patch-gcc_testsuite_gcc.target_i386_msave-args-mov.c) = 1b48c98ea87a6e2370e6379e63f6f318bfe019d0 +SHA1 (patch-gcc_testsuite_gcc.target_i386_msave-args-push.c) = 65afdee3521d29cbcd9a06d602bed34a53465d7e +SHA1 (patch-gcc_testsuite_gcc.target_i386_strict-cc.c) = f99944d55366c609def436f997c24e90664ec859 +SHA1 (patch-gcc_tree-inline.c) = f646054b34b4dd953c1d372c8f42f82055b092f4 +SHA1 (patch-include_dwarf2.def) = 52e6977b842ca3257ed2ef9f7ff9d0c914a06505 SHA1 (patch-isl_configure) = 36b37778ee13c0b364fb24d5864d6a9e65b29b7d SHA1 (patch-libcilkrts_configure) = ec76313d8103e0c525ebd26e9013ee3ca9e93391 SHA1 (patch-libcilkrts_runtime_os-unix.c) = b25632587d9fbe8ff38377fe34cb16225355b521 SHA1 (patch-libdecnumber_decNumber.c) = cec90e49c829bfc6ba1ec605d2fac7daaad62762 SHA1 (patch-libffi_configure) = bcfbfe8abddc378e2de4a39ad0669583b37e0292 SHA1 (patch-libffi_testsuite_libffi.call_float2.c) = 6321dde308579448c27c2b6e1e30633699dd145f -SHA1 (patch-libgcc_config.host) = 4fa15e83a446e026507ac4f16c4f7ef686544c43 +SHA1 (patch-libgcc_config.host) = a6cc52ef4e4529d7bf77f1c7cf892a7a2d0b6e00 SHA1 (patch-libgcc_config_arm_t-netbsd) = fe986b09ccbfc253aaaca263e8e38f06da4891cc SHA1 (patch-libgcc_config_arm_t-netbsd-eabi) = 1e818e92fe79f57d305ff42ce3449dddf87c3179 SHA1 (patch-libgcc_config_i386_cpuinfo.h) = d217e3c65178c96c7314cb88c740b9586d4e8fed diff --git a/lang/gcc7/options.mk b/lang/gcc7/options.mk index ed55d226e755..a43967c22b11 100644 --- a/lang/gcc7/options.mk +++ b/lang/gcc7/options.mk @@ -148,7 +148,9 @@ LANGS+= fortran .if !empty(PKG_OPTIONS:Mgcc-c++) LANGS+= c++ +.if ${OPSYS} != "SunOS" CONFIGURE_ARGS+= --enable-__cxa_atexit +.endif CONFIGURE_ARGS+= --with-gxx-include-dir=${GCC_PREFIX}/include/c++/ .else CONFIGURE_ARGS+= --disable-build-with-cxx diff --git a/lang/gcc7/patches/patch-gcc_caller-save.c b/lang/gcc7/patches/patch-gcc_caller-save.c new file mode 100644 index 000000000000..c61499cc7796 --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_caller-save.c @@ -0,0 +1,15 @@ +$NetBSD$ + +Disable -fomit-frame-pointer. + +--- gcc/caller-save.c.orig 2017-01-01 12:07:43.905435000 +0000 ++++ gcc/caller-save.c +@@ -378,7 +378,7 @@ saved_hard_reg_compare_func (const void + const struct saved_hard_reg *p1 = *(struct saved_hard_reg * const *) v1p; + const struct saved_hard_reg *p2 = *(struct saved_hard_reg * const *) v2p; + +- if (flag_omit_frame_pointer) ++ if (0) + { + if (p1->call_freq - p2->call_freq != 0) + return p1->call_freq - p2->call_freq; diff --git a/lang/gcc7/patches/patch-gcc_common.opt b/lang/gcc7/patches/patch-gcc_common.opt new file mode 100644 index 000000000000..18a2e34f161b --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_common.opt @@ -0,0 +1,29 @@ +$NetBSD$ + +Support -fclone-functions and -fstrict-calling-conventions. + +--- gcc/common.opt.orig 2017-06-22 11:38:22.113724000 +0000 ++++ gcc/common.opt +@@ -1076,6 +1076,11 @@ fcode-hoisting + Common Report Var(flag_code_hoisting) Optimization + Enable code hoisting. + ++fclone-functions ++Common Report Var(flag_clone_functions) Init(1) ++Allow the compiler to clone functions to facilitate certain optimizations. ++Enabled by default. ++ + fcombine-stack-adjustments + Common Report Var(flag_combine_stack_adjustments) Optimization + Looks for opportunities to reduce stack adjustments and stack references. +@@ -2341,6 +2346,10 @@ fstrict-aliasing + Common Report Var(flag_strict_aliasing) Optimization + Assume strict aliasing rules apply. + ++fstrict-calling-conventions ++Common Report Var(flag_strict_calling_conventions) Init(1) ++Use strict ABI calling conventions even for static functions ++ + fstrict-overflow + Common Report Var(flag_strict_overflow) Optimization + Treat signed overflow as undefined. diff --git a/lang/gcc7/patches/patch-gcc_config_i386_i386.c b/lang/gcc7/patches/patch-gcc_config_i386_i386.c new file mode 100644 index 000000000000..19470da25f82 --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_config_i386_i386.c @@ -0,0 +1,293 @@ +$NetBSD$ + +Disable -fomit-frame-pointer. +Support -fstrict-calling-conventions and -msave-args. + +--- gcc/config/i386/i386.c.orig 2018-01-16 12:49:29.534125000 +0000 ++++ gcc/config/i386/i386.c +@@ -2572,6 +2572,9 @@ static unsigned int ix86_minimum_incomin + + static enum calling_abi ix86_function_abi (const_tree); + ++static int ix86_nsaved_args (void); ++static void pro_epilogue_adjust_stack (rtx, rtx, rtx, int, bool); ++ + + #ifndef SUBTARGET32_DEFAULT_CPU + #define SUBTARGET32_DEFAULT_CPU "i386" +@@ -5847,7 +5850,7 @@ ix86_option_override_internal (bool main + } + + /* Keep nonleaf frame pointers. */ +- if (opts->x_flag_omit_frame_pointer) ++ if (0) + opts->x_target_flags &= ~MASK_OMIT_LEAF_FRAME_POINTER; + else if (TARGET_OMIT_LEAF_FRAME_POINTER_P (opts->x_target_flags)) + opts->x_flag_omit_frame_pointer = 1; +@@ -5896,6 +5899,9 @@ ix86_option_override_internal (bool main + &= ~((OPTION_MASK_ISA_BMI | OPTION_MASK_ISA_BMI2 | OPTION_MASK_ISA_TBM) + & ~opts->x_ix86_isa_flags_explicit); + ++ if (!TARGET_64BIT && TARGET_SAVE_ARGS) ++ warning (0, "-msave-args is ignored in 32-bit mode"); ++ + /* Validate -mpreferred-stack-boundary= value or default it to + PREFERRED_STACK_BOUNDARY_DEFAULT. */ + ix86_preferred_stack_boundary = PREFERRED_STACK_BOUNDARY_DEFAULT; +@@ -8015,6 +8021,7 @@ ix86_function_regparm (const_tree type, + 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)) + { + cgraph_local_info *i = &target->local; +@@ -8112,6 +8119,7 @@ ix86_function_sseregparm (const_tree typ + /* 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)) + { + cgraph_local_info *i = &target->local; +@@ -11964,7 +11972,7 @@ ix86_can_use_return_insn_p (void) + ix86_compute_frame_layout (); + 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); + } + + /* Value should be nonzero if functions must have frame pointers. +@@ -11988,6 +11996,9 @@ ix86_frame_pointer_required (void) + if (TARGET_32BIT_MS_ABI && cfun->calls_setjmp) + return true; + ++ if (TARGET_64BIT && 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 && get_frame_size () > SEH_MAX_FRAME_SIZE) +@@ -12781,6 +12792,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 +@@ -12843,7 +12855,8 @@ ix86_compute_frame_layout (void) + } + + frame->save_regs_using_mov +- = (TARGET_PROLOGUE_USING_MOVE && cfun->machine->use_fast_prologue_epilogue ++ = ((TARGET_FORCE_SAVE_REGS_USING_MOV || ++ (TARGET_PROLOGUE_USING_MOVE && cfun->machine->use_fast_prologue_epilogue)) + /* If static stack checking is enabled and done with probes, + the registers need to be saved before allocating the frame. */ + && flag_stack_check != STATIC_BUILTIN_STACK_CHECK); +@@ -12863,6 +12876,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_64BIT && 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; +@@ -12945,7 +12965,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))) + frame->save_regs_using_mov = false; + +@@ -12957,7 +12977,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->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; + } +@@ -12988,6 +13012,20 @@ ix86_compute_frame_layout (void) + frame->hard_frame_pointer_offset = frame->stack_pointer_offset - 128; + } + } ++ 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 +@@ -13096,6 +13134,23 @@ ix86_emit_save_regs (void) + unsigned int regno; + rtx_insn *insn; + ++ if (TARGET_64BIT && TARGET_SAVE_ARGS) ++ { ++ int i; ++ int nsaved = ix86_nsaved_args (); ++ int start = cfun->returns_struct; ++ ++ for (i = start; i < start + nsaved; 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 (nsaved % 2 != 0) ++ pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx, ++ GEN_INT (-UNITS_PER_WORD), -1, false); ++ } ++ + for (regno = FIRST_PSEUDO_REGISTER - 1; regno-- > 0; ) + if (GENERAL_REGNO_P (regno) && ix86_save_reg (regno, true)) + { +@@ -13174,9 +13229,30 @@ ix86_emit_save_reg_using_mov (machine_mo + /* 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_64BIT && TARGET_SAVE_ARGS) ++ { ++ int i; ++ int nsaved = ix86_nsaved_args (); ++ int start = cfun->returns_struct; ++ ++ /* We deal with this twice? */ ++ if (nsaved % 2 != 0) ++ cfa_offset -= UNITS_PER_WORD; ++ ++ for (i = start + nsaved - 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)) +@@ -13960,7 +14036,7 @@ ix86_finalize_stack_realign_flags (void) + if (stack_realign + && frame_pointer_needed + && crtl->is_leaf +- && flag_omit_frame_pointer ++ && 0 + && crtl->sp_is_unchanging + && !ix86_current_function_calls_tls_descriptor + && !crtl->accesses_prior_frames +@@ -14235,7 +14311,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); + + if (frame_pointer_needed && !m->fs.fp_valid) +@@ -14286,7 +14362,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); + int_registers_saved = true; + } + } +@@ -14529,7 +14605,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); + +@@ -14968,6 +15044,35 @@ ix86_expand_epilogue (int style) + ix86_emit_restore_regs_using_pop (); + } + ++ if (TARGET_64BIT && TARGET_SAVE_ARGS) { ++ /* ++ * 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.) ++ */ ++ int start = cfun->returns_struct; ++ int nsaved = ix86_nsaved_args(); ++ int i; ++ ++ for (i = start + nsaved - 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); ++ ++ gcc_assert(m->fs.fp_valid); ++ } ++ + /* If we used a stack pointer and haven't already got rid of it, + then do so now. */ + if (m->fs.fp_valid) +@@ -15979,6 +16084,18 @@ ix86_cannot_force_const_mem (machine_mod + return !ix86_legitimate_constant_p (mode, x); + } + ++/* Return number of arguments to be saved on the stack with ++ -msave-args. */ ++ ++static int ++ix86_nsaved_args (void) ++{ ++ if (TARGET_64BIT && TARGET_SAVE_ARGS) ++ return crtl->args.info.regno - cfun->returns_struct; ++ else ++ return 0; ++} ++ + /* Nonzero if the symbol is marked as dllimport, or as stub-variable, + otherwise zero. */ + diff --git a/lang/gcc7/patches/patch-gcc_config_i386_i386.h b/lang/gcc7/patches/patch-gcc_config_i386_i386.h new file mode 100644 index 000000000000..6328a3aafd31 --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_config_i386_i386.h @@ -0,0 +1,22 @@ +$NetBSD$ + +Support -msave-args. + +--- gcc/config/i386/i386.h.orig 2018-01-16 11:10:44.253204000 +0000 ++++ gcc/config/i386/i386.h +@@ -2480,6 +2480,7 @@ enum avx_u128_state + */ + struct GTY(()) ix86_frame + { ++ int nmsave_args; + int nsseregs; + int nregs; + int va_arg_size; +@@ -2491,6 +2492,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 sse_reg_save_offset; + diff --git a/lang/gcc7/patches/patch-gcc_config_i386_i386.opt b/lang/gcc7/patches/patch-gcc_config_i386_i386.opt new file mode 100644 index 000000000000..16aa2178adab --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_config_i386_i386.opt @@ -0,0 +1,22 @@ +$NetBSD$ + +Support -msave-args. + +--- gcc/config/i386/i386.opt.orig 2018-01-16 11:17:49.509247000 +0000 ++++ gcc/config/i386/i386.opt +@@ -505,6 +505,15 @@ mtls-direct-seg-refs + Target Report Mask(TLS_DIRECT_SEG_REFS) + Use direct references against %gs when accessing tls data. + ++msave-args ++Target Report Mask(SAVE_ARGS) ++Save integer arguments on the stack at function entry ++ ++mforce-save-regs-using-mov ++Target Report Mask(FORCE_SAVE_REGS_USING_MOV) ++Save registers using push in function prologues. This is intentionally ++undocumented and used for msave-args testing. ++ + mtune= + Target RejectNegative Joined Var(ix86_tune_string) + Schedule code for given CPU. diff --git a/lang/gcc7/patches/patch-gcc_config_sol2-c.c b/lang/gcc7/patches/patch-gcc_config_sol2-c.c new file mode 100644 index 000000000000..a9fd6b0ff4ee --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_config_sol2-c.c @@ -0,0 +1,56 @@ +$NetBSD$ + +Update cmn_err format specifier. + +--- gcc/config/sol2-c.c.orig 2017-01-01 12:07:43.905435000 +0000 ++++ gcc/config/sol2-c.c +@@ -40,7 +40,10 @@ static const format_length_info cmn_err_ + + static const format_flag_spec cmn_err_flag_specs[] = + { ++ { '0', 0, 0, N_("'0' flag"), N_("the '0' flag"), STD_C89 }, ++ { '-', 0, 0, N_("'-' flag"), N_("the '-' flag"), STD_C89 }, + { 'w', 0, 0, N_("field width"), N_("field width in printf format"), STD_C89 }, ++ { 'p', 0, 0, N_("precision"), N_("precision in printf format"), STD_C89 }, + { 'L', 0, 0, N_("length modifier"), N_("length modifier in printf format"), STD_C89 }, + { 0, 0, 0, NULL, NULL, STD_C89 } + }; +@@ -48,6 +51,7 @@ static const format_flag_spec cmn_err_fl + + static const format_flag_pair cmn_err_flag_pairs[] = + { ++ { '0', '-', 1, 0 }, + { 0, 0, 0, 0 } + }; + +@@ -57,21 +61,21 @@ static const format_char_info bitfield_s + 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 }, ++ { "dD", 0, STD_C89, { T89_I, BADLEN, BADLEN, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0", "", NULL }, ++ { "oOxX",0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0", "", NULL }, ++ { "u", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0", "", 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 }, "-wp", "cR", NULL }, ++ { "b", 0, STD_C89, { T89_I, 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/lang/gcc7/patches/patch-gcc_config_sol2.h b/lang/gcc7/patches/patch-gcc_config_sol2.h new file mode 100644 index 000000000000..07394f161e11 --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_config_sol2.h @@ -0,0 +1,30 @@ +$NetBSD$ + +Pull in ${PREFIX}/lib by default and handle for multiarch. + +--- gcc/config/sol2.h.orig 2017-11-21 09:31:12.000000000 +0000 ++++ gcc/config/sol2.h +@@ -241,8 +241,9 @@ along with GCC; see the file COPYING3. + "%{G:-G} \ + %{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}}}" ++ -R@PREFIX@/lib \ ++ %{!YP,*:%{p|pg:-Y P,%R/lib:%R/usr/lib:%R@PREFIX@/lib} \ ++ %{!p:%{!pg:-Y P,%R/lib:%R/usr/lib:%R@PREFIX@/lib}}}" + + #undef LINK_ARCH32_SPEC + #define LINK_ARCH32_SPEC LINK_ARCH32_SPEC_BASE +@@ -254,8 +255,9 @@ along with GCC; see the file COPYING3. + "%{G:-G} \ + %{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 "}}}" ++ -R@PREFIX@/lib@MARCH64_SLASH@" @MARCH64_SUBDIR@ " \ ++ %{!YP,*:%{p|pg:-Y P,%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR ":%R@PREFIX@/lib@MARCH64_SLASH@" @MARCH64_SUBDIR@ "} \ ++ %{!p:%{!pg:-Y P,%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR ":%R@PREFIX@/lib@MARCH64_SLASH@" @MARCH64_SUBDIR@ "}}}" + + #undef LINK_ARCH64_SPEC + #ifndef USE_GLD diff --git a/lang/gcc7/patches/patch-gcc_configure b/lang/gcc7/patches/patch-gcc_configure index 4d1ded0e9b77..d28e259b08fe 100644 --- a/lang/gcc7/patches/patch-gcc_configure +++ b/lang/gcc7/patches/patch-gcc_configure @@ -1,8 +1,19 @@ $NetBSD: patch-gcc_configure,v 1.1 2017/05/03 00:21:03 maya Exp $ ---- gcc/configure.orig 2015-09-30 23:06:11.000000000 +0000 +Fix detection of native TLS on SunOS, joyent/pkgsrc#264 + +--- gcc/configure.orig 2017-11-21 09:31:12.135035000 +0000 +++ gcc/configure -@@ -28321,7 +28321,7 @@ case "$target" in +@@ -23957,7 +23958,7 @@ $as_echo "#define TLS_SECTION_ASM_FLAG ' + tls_first_major=2 + tls_first_minor=14 + tls_section_flag=T +- tls_as_opt="--fatal-warnings" ++ tls_as_opt="-32 --fatal-warnings" + fi + case "$target" in + i[34567]86-*-*) +@@ -29111,7 +29114,7 @@ case "$target" in gcc_cv_target_dl_iterate_phdr=no fi ;; diff --git a/lang/gcc7/patches/patch-gcc_dojump.c b/lang/gcc7/patches/patch-gcc_dojump.c new file mode 100644 index 000000000000..dfa43523ead6 --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_dojump.c @@ -0,0 +1,15 @@ +$NetBSD$ + +Disable -fomit-frame-pointer. + +--- gcc/dojump.c.orig 2017-01-01 12:07:43.905435000 +0000 ++++ gcc/dojump.c +@@ -82,7 +82,7 @@ void + clear_pending_stack_adjust (void) + { + if (optimize > 0 +- && (! flag_omit_frame_pointer || cfun->calls_alloca) ++ && (! 0 || cfun->calls_alloca) + && EXIT_IGNORE_STACK) + discard_pending_stack_adjust (); + } diff --git a/lang/gcc7/patches/patch-gcc_dwarf2out.c b/lang/gcc7/patches/patch-gcc_dwarf2out.c new file mode 100644 index 000000000000..2c05799f944c --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_dwarf2out.c @@ -0,0 +1,18 @@ +$NetBSD$ + +Support -msave-args. + +--- gcc/dwarf2out.c.orig 2017-11-15 11:54:11.986064000 +0000 ++++ gcc/dwarf2out.c +@@ -22432,6 +22432,11 @@ gen_subprogram_die (tree decl, dw_die_re + /* Add the calling convention attribute if requested. */ + add_calling_convention_attribute (subr_die, decl); + ++#ifdef TARGET_SAVE_ARGS ++ if (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/lang/gcc7/patches/patch-gcc_ira.c b/lang/gcc7/patches/patch-gcc_ira.c new file mode 100644 index 000000000000..7ef3f90e1258 --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_ira.c @@ -0,0 +1,24 @@ +$NetBSD$ + +Disable -fomit-frame-pointer. + +--- gcc/ira.c.orig 2017-10-18 21:13:16.833810000 +0000 ++++ gcc/ira.c +@@ -1720,7 +1720,7 @@ ira_init (void) + { + this_target_ira_int->free_register_move_costs (); + setup_reg_mode_hard_regset (); +- setup_alloc_regs (flag_omit_frame_pointer != 0); ++ setup_alloc_regs (0 != 0); + setup_class_subset_and_memory_move_costs (); + setup_reg_class_nregs (); + setup_prohibited_class_mode_regs (); +@@ -2275,7 +2275,7 @@ ira_setup_eliminable_regset (void) + case. At some point, we should improve this by emitting the + sp-adjusting insns for this case. */ + frame_pointer_needed +- = (! flag_omit_frame_pointer ++ = (! 0 + || (cfun->calls_alloca && EXIT_IGNORE_STACK) + /* We need the frame pointer to catch stack overflow exceptions if + the stack pointer is moving (as for the alloca case just above). */ diff --git a/lang/gcc7/patches/patch-gcc_symtab.c b/lang/gcc7/patches/patch-gcc_symtab.c new file mode 100644 index 000000000000..9635f4fe1b59 --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_symtab.c @@ -0,0 +1,17 @@ +$NetBSD$ + +Support -fclone-functions. + +--- gcc/symtab.c.orig 2017-04-28 11:42:14.556427000 +0000 ++++ gcc/symtab.c +@@ -1744,6 +1744,10 @@ symtab_node::noninterposable_alias (void + tree new_decl; + symtab_node *new_node = NULL; + ++ /* Do not allow a clone to be created if function-cloning is disabled */ ++ if (!flag_clone_functions) ++ return NULL; ++ + /* First try to look up existing alias or base object + (if that is already non-overwritable). */ + symtab_node *node = ultimate_alias_target (); diff --git a/lang/gcc7/patches/patch-gcc_testsuite_gcc.dg_fno-clone-preserves-unused-args.c b/lang/gcc7/patches/patch-gcc_testsuite_gcc.dg_fno-clone-preserves-unused-args.c new file mode 100644 index 000000000000..c9d2190ee5da --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_testsuite_gcc.dg_fno-clone-preserves-unused-args.c @@ -0,0 +1,34 @@ +$NetBSD$ + +Test -fclone-functions. + +--- /dev/null 2018-05-21 12:23:16.000000000 +0000 ++++ gcc/testsuite/gcc.dg/fno-clone-preserves-unused-args.c 2018-05-21 12:14:37.563084208 +0000 +@@ -0,0 +1,27 @@ ++/* { 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 void() ++{ ++ t(1, 2, 3, 4, 5); ++} ++ ++/* Only use 3 params, bait constprop/sra into deleting the other two */ ++static void(int a, int b, int c, int d, int e) ++{ ++ printf("%d %d\n", a, b, c); ++} diff --git a/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_local.c b/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_local.c new file mode 100644 index 000000000000..67dce519ea2e --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_local.c @@ -0,0 +1,14 @@ +$NetBSD$ + +Test -fstrict-calling-conventions. + +--- gcc/testsuite/gcc.target/i386/local.c.orig 2015-12-29 10:32:21.184118000 +0000 ++++ 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/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_msave-args-mov.c b/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_msave-args-mov.c new file mode 100644 index 000000000000..bfd20a89906c --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_msave-args-mov.c @@ -0,0 +1,33 @@ +$NetBSD$ + +Test -msave-args. + +--- /dev/null 2018-05-21 12:23:16.000000000 +0000 ++++ gcc/testsuite/gcc.target/i386/msave-args-mov.c 2018-05-21 12:31:14.365772073 +0000 +@@ -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/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_msave-args-push.c b/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_msave-args-push.c new file mode 100644 index 000000000000..a4cd80d3cfdf --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_msave-args-push.c @@ -0,0 +1,33 @@ +$NetBSD$ + +Test -msave-args. + +--- /dev/null 2018-05-21 12:23:16.000000000 +0000 ++++ gcc/testsuite/gcc.target/i386/msave-args-push.c 2018-05-21 12:31:39.048591314 +0000 +@@ -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/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_strict-cc.c b/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_strict-cc.c new file mode 100644 index 000000000000..1c721430ed58 --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_testsuite_gcc.target_i386_strict-cc.c @@ -0,0 +1,31 @@ +$NetBSD$ + +Test -fstrict-calling-conventions. + +--- /dev/null 2018-05-21 12:23:16.000000000 +0000 ++++ gcc/testsuite/gcc.target/i386/strict-cc.c 2018-05-21 12:11:48.087972286 +0000 +@@ -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/lang/gcc7/patches/patch-gcc_tree-inline.c b/lang/gcc7/patches/patch-gcc_tree-inline.c new file mode 100644 index 000000000000..fa34b1489d22 --- /dev/null +++ b/lang/gcc7/patches/patch-gcc_tree-inline.c @@ -0,0 +1,14 @@ +$NetBSD$ + +Support -fclone-functions. + +--- gcc/tree-inline.c.orig 2017-10-27 20:33:35.593168000 +0000 ++++ gcc/tree-inline.c +@@ -5714,6 +5714,7 @@ bool + tree_versionable_function_p (tree fndecl) + { + return (!lookup_attribute ("noclone", DECL_ATTRIBUTES (fndecl)) ++ && flag_clone_functions + && copy_forbidden (DECL_STRUCT_FUNCTION (fndecl)) == NULL); + } + diff --git a/lang/gcc7/patches/patch-include_dwarf2.def b/lang/gcc7/patches/patch-include_dwarf2.def new file mode 100644 index 000000000000..c6178a7cd2dc --- /dev/null +++ b/lang/gcc7/patches/patch-include_dwarf2.def @@ -0,0 +1,15 @@ +$NetBSD$ + +Support -msave-args. + +--- include/dwarf2.def.orig 2017-02-25 08:18:24.431993000 +0000 ++++ include/dwarf2.def +@@ -457,6 +457,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/lang/gcc7/patches/patch-libgcc_config.host b/lang/gcc7/patches/patch-libgcc_config.host index 1f9b281367a5..7aaeb44cdc51 100644 --- a/lang/gcc7/patches/patch-libgcc_config.host +++ b/lang/gcc7/patches/patch-libgcc_config.host @@ -19,7 +19,7 @@ arm64 support aarch64*-*-linux*) extra_parts="$extra_parts crtfastmath.o" md_unwind_header=aarch64/linux-unwind.h -@@ -396,7 +402,16 @@ +@@ -396,7 +396,16 @@ arm*-*-freebsd*) # ARM Fr tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp" ;; arm*-*-netbsdelf*)