Index: Makefile.in --- Makefile.in.orig +++ Makefile.in @@ -434,7 +434,7 @@ TFLAGS = # Defaults for all stages; some are overridden below. -STAGE_CFLAGS = $(BOOT_CFLAGS) +STAGE_CFLAGS = $(CFLAGS) STAGE_TFLAGS = $(TFLAGS) STAGE_CONFIGURE_FLAGS=@stage2_werror_flag@ @@ -2553,7 +2553,7 @@ install: @: $(MAKE); $(unstage) @r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ - $(MAKE) $(RECURSE_FLAGS_TO_PASS) installdirs install-host install-target + $(MAKE) $(RECURSE_FLAGS_TO_PASS) -j1 installdirs install-host install-target .PHONY: install-host-nogcc install-host-nogcc: \ @@ -2854,7 +2854,7 @@ configure-build-libiberty: esac; \ module_srcdir=libiberty; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(BUILD_CONFIGARGS) --build=${build_alias} --host=${build_alias} \ @@ -2911,7 +2911,7 @@ configure-build-bison: esac; \ module_srcdir=bison; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(BUILD_CONFIGARGS) --build=${build_alias} --host=${build_alias} \ @@ -2968,7 +2968,7 @@ configure-build-flex: esac; \ module_srcdir=flex; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(BUILD_CONFIGARGS) --build=${build_alias} --host=${build_alias} \ @@ -3025,7 +3025,7 @@ configure-build-m4: esac; \ module_srcdir=m4; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(BUILD_CONFIGARGS) --build=${build_alias} --host=${build_alias} \ @@ -3082,7 +3082,7 @@ configure-build-texinfo: esac; \ module_srcdir=texinfo; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(BUILD_CONFIGARGS) --build=${build_alias} --host=${build_alias} \ @@ -3139,7 +3139,7 @@ configure-build-fixincludes: esac; \ module_srcdir=fixincludes; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(BUILD_CONFIGARGS) --build=${build_alias} --host=${build_alias} \ @@ -3196,7 +3196,7 @@ configure-build-libcpp: esac; \ module_srcdir=libcpp; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(BUILD_CONFIGARGS) --build=${build_alias} --host=${build_alias} \ @@ -39267,7 +39267,7 @@ configure-target-libstdc++-v3: esac; \ module_srcdir=libstdc++-v3; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -40510,7 +40510,7 @@ configure-target-libsanitizer: esac; \ module_srcdir=libsanitizer; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -41753,7 +41753,7 @@ configure-target-libvtv: esac; \ module_srcdir=libvtv; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -42997,7 +42997,7 @@ configure-target-liboffloadmic: esac; \ module_srcdir=liboffloadmic; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -43455,7 +43455,7 @@ configure-target-libssp: esac; \ module_srcdir=libssp; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -43913,7 +43913,7 @@ configure-target-newlib: esac; \ module_srcdir=newlib; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -44370,7 +44370,7 @@ configure-target-libgcc: esac; \ module_srcdir=libgcc; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -45609,7 +45609,7 @@ configure-target-libbacktrace: esac; \ module_srcdir=libbacktrace; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -46067,7 +46067,7 @@ configure-target-libquadmath: esac; \ module_srcdir=libquadmath; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -46525,7 +46525,7 @@ configure-target-libgfortran: esac; \ module_srcdir=libgfortran; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -46983,7 +46983,7 @@ configure-target-libobjc: esac; \ module_srcdir=libobjc; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -47441,7 +47441,7 @@ configure-target-libgo: esac; \ module_srcdir=libgo; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -47899,7 +47899,7 @@ configure-target-libhsail-rt: esac; \ module_srcdir=libhsail-rt; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -48357,7 +48357,7 @@ configure-target-libphobos: esac; \ module_srcdir=libphobos; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -48815,7 +48815,7 @@ configure-target-libtermcap: esac; \ module_srcdir=libtermcap; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -49208,7 +49208,7 @@ configure-target-winsup: esac; \ module_srcdir=winsup; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -49666,7 +49666,7 @@ configure-target-libgloss: esac; \ module_srcdir=libgloss; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -50119,7 +50119,7 @@ configure-target-libffi: esac; \ module_srcdir=libffi; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -50567,7 +50567,7 @@ configure-target-zlib: esac; \ module_srcdir=zlib; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -51025,7 +51025,7 @@ configure-target-rda: esac; \ module_srcdir=rda; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -51483,7 +51483,7 @@ configure-target-libada: esac; \ module_srcdir=libada; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -51940,7 +51940,7 @@ configure-target-libgomp: esac; \ module_srcdir=libgomp; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -53184,7 +53184,7 @@ configure-target-libitm: esac; \ module_srcdir=libitm; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ @@ -53642,7 +53642,7 @@ configure-target-libatomic: esac; \ module_srcdir=libatomic; \ rm -f no-such-file || : ; \ - CONFIG_SITE=no-such-file $(SHELL) \ + $(SHELL) \ $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ Index: fixincludes/fixincl.x --- fixincludes/fixincl.x.orig +++ fixincludes/fixincl.x @@ -7113,11 +7113,11 @@ static const char* apzSolaris_Complex_CxxPatch[] = { s "-e", "/#if[ \t]*!defined(__cplusplus)/c\\\n\ #ifdef\t__cplusplus\\\n\ extern \"C\" {\\\n\ -#endif", +#endif\\\n", "-e", "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n\ #ifdef\t__cplusplus\\\n\ }\\\n\ -#endif", +#endif\\\n", (char*)NULL }; /* * * * * * * * * * * * * * * * * * * * * * * * * * Index: fixincludes/inclhack.def --- fixincludes/inclhack.def.orig +++ fixincludes/inclhack.def @@ -3539,9 +3539,9 @@ fix = { mach = "*-*-solaris2.*"; files = complex.h; sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n" - "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif"; + "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif\\\n"; sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n" - "#ifdef\t__cplusplus\\\n}\\\n#endif"; + "#ifdef\t__cplusplus\\\n}\\\n#endif\\\n"; test_text = "#if !defined(__cplusplus)\n" "#endif /* !defined(__cplusplus) */"; }; Disable fixincludes madness Index: gcc/Makefile.in --- gcc/Makefile.in.orig +++ gcc/Makefile.in @@ -265,9 +265,6 @@ endif NO_PIE_CFLAGS = @NO_PIE_CFLAGS@ NO_PIE_FLAG = @NO_PIE_FLAG@ -# We don't want to compile the compilers with -fPIE, it make PCH fail. -COMPILER += $(NO_PIE_CFLAGS) - # Link with -no-pie since we compile the compiler with -fno-PIE. LINKER += $(NO_PIE_FLAG) @@ -788,8 +785,6 @@ NO_PIE_FLAG_FOR_BUILD = @NO_PIE_FLAG_FOR_BUILD@ BUILD_CFLAGS= @BUILD_CFLAGS@ $(GENERATOR_CFLAGS) -DGENERATOR_FILE BUILD_CXXFLAGS = @BUILD_CXXFLAGS@ $(GENERATOR_CFLAGS) -DGENERATOR_FILE BUILD_NO_PIE_CFLAGS = @BUILD_NO_PIE_CFLAGS@ -BUILD_CFLAGS += $(BUILD_NO_PIE_CFLAGS) -BUILD_CXXFLAGS += $(BUILD_NO_PIE_CFLAGS) # Native compiler that we use. This may be C++ some day. COMPILER_FOR_BUILD = $(CXX_FOR_BUILD) @@ -2178,6 +2173,12 @@ DRIVER_DEFINES = \ CFLAGS-gcc.o += $(DRIVER_DEFINES) -DBASEVER=$(BASEVER_s) gcc.o: $(BASEVER) +ISCLANG = $(shell $(CC) --version | grep -c clang) + +ifeq ($(ISCLANG),1) +CFLAGS-insn-attrtab.o += -fbracket-depth=512 +endif + specs.h : s-specs ; @true s-specs : Makefile lsf="$(lang_specs_files)"; for f in $$lsf; do \ @@ -3088,7 +3089,7 @@ stmp-fixinc: gsyslimits.h macro_list fixinc_list \ gcc_dir=`${PWD_COMMAND}` ; \ export TARGET_MACHINE srcdir SHELL MACRO_LIST && \ cd $(build_objdir)/fixincludes && \ - $(SHELL) ./fixinc.sh "$${gcc_dir}/$${fix_dir}" \ + $(SHELL) -c true "$${gcc_dir}/$${fix_dir}" \ $(BUILD_SYSTEM_HEADER_DIR) $(OTHER_FIXINCLUDES_DIRS) ); \ rm -f $${fix_dir}/syslimits.h; \ if [ -f $${fix_dir}/limits.h ]; then \ Index: gcc/builtins.c --- gcc/builtins.c.orig +++ gcc/builtins.c @@ -130,10 +130,12 @@ static rtx expand_builtin_memory_copy_args (tree dest, static rtx expand_builtin_memmove (tree, rtx); static rtx expand_builtin_mempcpy (tree, rtx); static rtx expand_builtin_mempcpy_args (tree, tree, tree, rtx, tree, memop_ret); +#ifndef NO_UNSAFE_BUILTINS static rtx expand_builtin_strcat (tree, rtx); static rtx expand_builtin_strcpy (tree, rtx); static rtx expand_builtin_strcpy_args (tree, tree, tree, rtx); static rtx expand_builtin_stpcpy (tree, rtx, machine_mode); +#endif static rtx expand_builtin_stpncpy (tree, rtx); static rtx expand_builtin_strncat (tree, rtx); static rtx expand_builtin_strncpy (tree, rtx); @@ -3944,6 +3946,7 @@ expand_builtin_mempcpy_args (tree dest, tree src, tree retmode); } +#ifndef NO_UNSAFE_BUILTINS /* Expand into a movstr instruction, if one is available. Return NULL_RTX if we failed, the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient. @@ -4181,6 +4184,7 @@ expand_builtin_stpcpy (tree exp, rtx target, machine_m return NULL_RTX; } +#endif /* Check a call EXP to the stpncpy built-in for validity. Return NULL_RTX on both success and failure. */ @@ -7559,15 +7563,19 @@ expand_builtin (tree exp, rtx target, rtx subtarget, m break; case BUILT_IN_STRCAT: +#ifndef NO_UNSAFE_BUILTINS target = expand_builtin_strcat (exp, target); if (target) return target; +#endif break; case BUILT_IN_STRCPY: +#ifndef NO_UNSAFE_BUILTINS target = expand_builtin_strcpy (exp, target); if (target) return target; +#endif break; case BUILT_IN_STRNCAT: @@ -7583,9 +7591,11 @@ expand_builtin (tree exp, rtx target, rtx subtarget, m break; case BUILT_IN_STPCPY: +#ifndef NO_UNSAFE_BUILTINS target = expand_builtin_stpcpy (exp, target, mode); if (target) return target; +#endif break; case BUILT_IN_STPNCPY: Index: gcc/c-family/c-format.c --- gcc/c-family/c-format.c.orig +++ gcc/c-family/c-format.c @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see format_type_error. Target-specific format types do not have matching enum values. */ enum format_type { printf_format_type, asm_fprintf_format_type, + kprintf_format_type, syslog_format_type, gcc_diag_format_type, gcc_tdiag_format_type, gcc_cdiag_format_type, gcc_cxxdiag_format_type, gcc_gfc_format_type, @@ -479,6 +480,16 @@ static const format_length_info gcc_diag_length_specs[ { NO_FMT, NO_FMT, 0 } }; +static const format_length_info kprintf_length_specs[] = +{ + { "h", FMT_LEN_h, STD_C89, NO_FMT, 0 }, + { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C9L, 0 }, + { "q", FMT_LEN_ll, STD_EXT, NO_FMT, 0 }, + { "z", FMT_LEN_z, STD_C99, NO_FMT, 0 }, + { "t", FMT_LEN_t, STD_C99, NO_FMT, 0 }, + { NO_FMT, NO_FMT, 0 } +}; + /* The custom diagnostics all accept the same length specifiers. */ #define gcc_tdiag_length_specs gcc_diag_length_specs #define gcc_cdiag_length_specs gcc_diag_length_specs @@ -724,6 +735,44 @@ static const format_char_info asm_fprintf_char_table[] { "m", 0, STD_C89, NOARGUMENTS, "q", "", NULL }, \ { "Z", 1, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "", &gcc_diag_char_table[0] } +static const format_char_info kprint_char_table[] = +{ + /* C89 conversion specifiers. */ + { "di", 0, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +'I", "i", NULL }, + { "oxX", 0, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, BADLEN, T99_ST, T99_UPD, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0#", "i", NULL }, + { "u", 0, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, BADLEN, T99_ST, T99_UPD, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0'I", "i", NULL }, + { "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, + { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR", NULL }, + { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, T89_UL, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0", "c", NULL }, +/* Kernel bitmap formatting */ + { "b", 0, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "", kprint_char_table + 8 }, + { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL }, +/* Kernel bitmap formatting, second part - similar to "s" except for types[] */ + { "b", 1, STD_C89, { T89_C, BADLEN, T89_C, T89_C, T89_C, BADLEN, T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, NULL, "cR", NULL } +}; + +static const format_char_info syslog_char_table[] = +{ + /* C89 conversion specifiers. */ + { "di", 0, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, TEX_LL, T99_SST, T99_PD, T99_IM }, "-wp0 +'I", "i", NULL }, + { "oxX", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0#", "i", NULL }, + { "u", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0'I", "i", NULL }, + { "fgG", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "", NULL }, + { "eE", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "", NULL }, + { "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, T94_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, + { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR", NULL }, + { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "c", NULL }, + { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, T99_IM }, "", "W", NULL }, + /* C99 conversion specifiers. */ + { "F", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "", NULL }, + { "aA", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "", NULL }, + /* X/Open conversion specifiers. */ + { "C", 0, STD_EXT, { TEX_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, + { "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "R", NULL }, + { "m", 0, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "", NULL }, + { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } +}; + static const format_char_info gcc_diag_char_table[] = { /* The conversion specifiers implemented within pp_format. */ @@ -901,6 +950,18 @@ static const format_kind_info format_types_orig[] = FMT_FLAG_ARG_CONVERT|FMT_FLAG_EMPTY_PREC_OK, 'w', 0, 'p', 0, 'L', 0, NULL, NULL + }, + { "kprintf", kprintf_length_specs, kprint_char_table, " +#0-'I", NULL, + printf_flag_specs, printf_flag_pairs, + FMT_FLAG_ARG_CONVERT|FMT_FLAG_EMPTY_PREC_OK, + 'w', 0, 'p', 0, 'L', 0, + &integer_type_node, &integer_type_node + }, + { "syslog", printf_length_specs, syslog_char_table, " +#0-'I", NULL, + printf_flag_specs, printf_flag_pairs, + FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK, + 'w', 0, 'p', 0, 'L', 0, + &integer_type_node, &integer_type_node }, { "gcc_diag", gcc_diag_length_specs, gcc_diag_char_table, "q+#", NULL, gcc_diag_flag_specs, gcc_diag_flag_pairs, Index: gcc/c-family/c.opt --- gcc/c-family/c.opt.orig +++ gcc/c-family/c.opt @@ -979,7 +979,7 @@ C ObjC C++ ObjC++ Var(warn_pointer_arith) Warning Lang Warn about function pointer arithmetic. Wpointer-sign -C ObjC Var(warn_pointer_sign) Warning LangEnabledBy(C ObjC,Wall || Wpedantic) +C ObjC Var(warn_pointer_sign) Warning LangEnabledBy(C ObjC,Wpedantic) Warn when a pointer differs in signedness in an assignment. Wpointer-compare Index: gcc/c/c-decl.c --- gcc/c/c-decl.c.orig +++ gcc/c/c-decl.c @@ -5740,6 +5740,8 @@ warn_variable_length_array (tree name, tree size) pedwarn_c90 (input_location, OPT_Wvla, "ISO C90 forbids variable " "length array"); } + if (warn_variable_decl) + warning (OPT_Wvariable_decl, "variable-sized array %qE", name); } /* Print warning about defaulting to int if necessary. */ Index: gcc/common/config/aarch64/aarch64-common.c --- gcc/common/config/aarch64/aarch64-common.c.orig +++ gcc/common/config/aarch64/aarch64-common.c @@ -52,8 +52,6 @@ /* Set default optimization options. */ static const struct default_options aarch_option_optimization_table[] = { - /* Enable section anchors by default at -O1 or higher. */ - { OPT_LEVELS_1_PLUS, OPT_fsection_anchors, NULL, 1 }, /* Disable fomit-frame-pointer by default. */ { OPT_LEVELS_ALL, OPT_fomit_frame_pointer, NULL, 0 }, /* Enable -fsched-pressure by default when optimizing. */ Index: gcc/common/config/rs6000/rs6000-common.c --- gcc/common/config/rs6000/rs6000-common.c.orig +++ gcc/common/config/rs6000/rs6000-common.c @@ -46,10 +46,6 @@ rs6000_option_init_struct (struct gcc_options *opts) avoid calling them when that's the only reason we would. */ opts->x_flag_errno_math = 0; - /* Enable section anchors by default. */ - if (!TARGET_MACHO) - opts->x_flag_section_anchors = 1; - /* By default, always emit DWARF-2 unwind info. This allows debugging without maintaining a stack frame back-chain. It also allows the debugger to find out where on-entry register values are stored at any Index: gcc/common.opt --- gcc/common.opt.orig +++ gcc/common.opt @@ -649,6 +649,10 @@ Wnull-dereference Common Var(warn_null_dereference) Warning Warn if dereferencing a NULL pointer may lead to erroneous or undefined behavior. +Wstack-larger-than- +Common RejectNegative Joined UInteger +-Wstack-larger-than- Warn if a function is using more than bytes of stack space for its local variables. + Wunsafe-loop-optimizations Common Ignore Warning Does nothing. Preserved for backward compatibility. @@ -764,7 +768,7 @@ Warn about statements between switch's controlling exp case. Wsystem-headers -Common Var(warn_system_headers) Warning +Common Var(warn_system_headers) Init(1) Warning Do not suppress warnings from system headers. Wtrampolines @@ -819,6 +823,10 @@ Wunused-variable Common Var(warn_unused_variable) Warning EnabledBy(Wunused) Warn when a variable is unused. +Wvariable-decl +Common Var(warn_variable_decl) +Warn about variable-sized declarations + Wcoverage-mismatch Common Var(warn_coverage_mismatch) Init(1) Warning Warn in case profiles in -fprofile-use do not match. @@ -1829,7 +1837,7 @@ Common Report Var(flag_ivopts) Init(1) Optimization Optimize induction variables on trees. fjump-tables -Common Var(flag_jump_tables) Init(1) Optimization +Common Var(flag_jump_tables) Init(0) Optimization Use jump tables for sufficiently large switch statements. fkeep-inline-functions @@ -3129,6 +3137,9 @@ no-canonical-prefixes Driver nodefaultlibs +Driver + +nopie Driver nostartfiles Index: gcc/config/aarch64/openbsd.h --- gcc/config/aarch64/openbsd.h.orig +++ gcc/config/aarch64/openbsd.h @@ -0,0 +1,116 @@ +/* Definitions of target machine for GNU compiler, OpenBSD/aarch64 ELF version. + Copyright (C) 2002 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Run-time Target Specification. */ +//#undef TARGET_VERSION +//#define TARGET_VERSION fputs (" (OpenBSD/arm)", stderr); + +/* This is used in ASM_FILE_START. */ +//#undef ARM_OS_NAME +//#define ARM_OS_NAME "OpenBSD" + +/* This defaults us to little-endian. */ +#ifndef TARGET_ENDIAN_DEFAULT +#define TARGET_ENDIAN_DEFAULT 0 +#endif + +#undef MULTILIB_DEFAULTS + +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0"); \ + OPENBSD_OS_CPP_BUILTINS_ELF(); \ + } \ + while (0) + +#undef SUBTARGET_CPP_SPEC +#define SUBTARGET_CPP_SPEC OBSD_CPP_SPEC + +#define LINK_SPEC \ + "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \ + %{shared:-shared} %{R*} \ + %{static:-Bstatic} \ + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ + %{!static:-dynamic-linker /usr/libexec/ld.so} \ + %{!nostdlib:-L/usr/lib}" + +#define OPENBSD_ENTRY_POINT "__start" + +/* Make GCC agree with . */ + +#undef SIZE_TYPE +#define SIZE_TYPE "long unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "long int" + +#undef INTMAX_TYPE +#define INTMAX_TYPE "long long int" + +#undef UINTMAX_TYPE +#define UINTMAX_TYPE "long long unsigned int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 32 + +/* Provide a STARTFILE_SPEC appropriate for OpenBSD ELF. Here we + provide support for the special GCC option -static. On ELF + targets, we also add the crtbegin.o file, which provides part + of the support for getting C++ file-scope static objects + constructed before entering "main". */ + +#define OPENBSD_STARTFILE_SPEC \ + "%{!shared: \ + %{pg:gcrt0%O%s} \ + %{!pg: \ + %{p:gcrt0%O%s} \ + %{!p:%{!static:crt0%O%s} %{static:%{nopie:crt0%O%s} \ + %{!nopie:rcrt0%O%s}}}}} \ + %:if-exists(crti%O%s) \ + %{static:%:if-exists-else(crtbeginT%O%s crtbegin%O%s)} \ + %{!static: \ + %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}" + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC OPENBSD_STARTFILE_SPEC + +/* Provide an ENDFILE_SPEC appropriate for OpenBSD ELF. Here we +add crtend.o, which provides part of the support for getting +C++ file-scope static objects deconstructed after exiting "main". */ + +#define OPENBSD_ENDFILE_SPEC \ + "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \ + %:if-exists(crtn%O%s)" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC OPENBSD_ENDFILE_SPEC + +/* Remove -mcpu=native handling which is Linux specific */ +#undef DRIVER_SELF_SPECS +#define DRIVER_SELF_SPECS "" + +/* dito */ +#undef EXTRA_SPEC_FUNCTIONS Index: gcc/config/alpha/alpha.c --- gcc/config/alpha/alpha.c.orig +++ gcc/config/alpha/alpha.c @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "varasm.h" #include "output.h" #include "insn-attr.h" +#include "flags.h" #include "explow.h" #include "expr.h" #include "reload.h" @@ -581,11 +582,17 @@ alpha_option_override (void) if (!global_options_set.x_g_switch_value) g_switch_value = 8; +#ifdef OPENBSD_NATIVE + /* Make -fpic behave as -fPIC unless -msmall-data is specified. */ + if (flag_pic == 2 && TARGET_SMALL_DATA) + warning (0, "-fPIC used with -msmall-data"); +#else /* Infer TARGET_SMALL_DATA from -fpic/-fPIC. */ if (flag_pic == 1) target_flags |= MASK_SMALL_DATA; else if (flag_pic == 2) target_flags &= ~MASK_SMALL_DATA; +#endif alpha_override_options_after_change (); @@ -4060,11 +4067,11 @@ alpha_expand_block_clear (rtx operands[]) if (a > align) { if (a >= 64) - align = a, alignofs = 8 - c % 8; + align = a, alignofs = 8 - (c & 7); else if (a >= 32) - align = a, alignofs = 4 - c % 4; + align = a, alignofs = 4 - (c & 3); else if (a >= 16) - align = a, alignofs = 2 - c % 2; + align = a, alignofs = 2 - (c & 1); } } @@ -7416,8 +7423,6 @@ alpha_initial_elimination_offset (unsigned int from, switch (from) { case FRAME_POINTER_REGNUM: - break; - case ARG_POINTER_REGNUM: ret += (ALPHA_ROUND (get_frame_size () + crtl->args.pretend_args_size) @@ -7732,6 +7737,9 @@ alpha_expand_prologue (void) HOST_WIDE_INT reg_offset; rtx sa_reg; + if (warn_stack_larger_than && frame_size > stack_larger_than_size) + warning (OPT_Wstack_larger_than_, "stack usage is %ld bytes", frame_size); + if (flag_stack_usage_info) current_function_static_stack_size = frame_size; @@ -7768,6 +7776,8 @@ alpha_expand_prologue (void) if (flag_stack_check || flag_stack_clash_protection) probed_size += get_stack_check_protect (); +if (flag_stack_check || STACK_CHECK_BUILTIN) + { if (probed_size <= 32768) { if (probed_size > 4096) @@ -7848,6 +7858,34 @@ alpha_expand_prologue (void) plus_constant (Pmode, stack_pointer_rtx, -frame_size))); } + } + else + { + if (frame_size <= 32768) + { + if (frame_size != 0) + FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx, + GEN_INT (-frame_size)))); + } + else + { + rtx count = gen_rtx_REG (DImode, 23); + rtx seq; + + emit_move_insn (count, GEN_INT (-frame_size)); + seq = emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx, + count)); + + /* This alternative is special, because the DWARF code cannot + possibly intuit through the loop above. So we invent this + note it looks at instead. */ + RTX_FRAME_RELATED_P (seq) = 1; + add_reg_note (seq, REG_FRAME_RELATED_EXPR, + gen_rtx_SET (stack_pointer_rtx, + plus_constant (Pmode, stack_pointer_rtx, + -frame_size))); + } + } /* Cope with very large offsets to the register save area. */ sa_bias = 0; @@ -8653,11 +8691,15 @@ summarize_insn (rtx x, struct shadow_summary *sum, int result of an instruction that might generate an UNPREDICTABLE result. - (c) Within the trap shadow, no register may be used more than once + (c) Within the trap shadow, the destination register of the potentially + trapping instruction may not be used as an input, for its value would be + UNPREDICTABLE. + + (d) Within the trap shadow, no register may be used more than once as a destination register. (This is to make life easier for the trap-handler.) - (d) The trap shadow may not include any branch instructions. */ + (e) The trap shadow may not include any branch instructions. */ static void alpha_handle_trap_shadows (void) @@ -8729,7 +8771,7 @@ alpha_handle_trap_shadows (void) if ((sum.defd.i & shadow.defd.i) || (sum.defd.fp & shadow.defd.fp)) { - /* (c) would be violated */ + /* (d) would be violated */ goto close_shadow; } @@ -8752,6 +8794,13 @@ alpha_handle_trap_shadows (void) goto close_shadow; } + + if ((sum.used.i & shadow.defd.i) + || (sum.used.fp & shadow.defd.fp)) + { + /* (c) would be violated */ + goto close_shadow; + } break; case BARRIER: @@ -8762,6 +8811,7 @@ alpha_handle_trap_shadows (void) case JUMP_INSN: case CALL_INSN: case CODE_LABEL: + /* (e) would be violated */ goto close_shadow; default: Index: gcc/config/alpha/alpha.h --- gcc/config/alpha/alpha.h.orig +++ gcc/config/alpha/alpha.h @@ -491,7 +491,7 @@ enum reg_class { is at the high-address end of the local variables; that is, each additional local variable allocated goes at a more negative offset in the frame. */ -/* #define FRAME_GROWS_DOWNWARD 0 */ +#define FRAME_GROWS_DOWNWARD 1 /* If we generate an insn to push BYTES bytes, this says how many the stack pointer really advances by. Index: gcc/config/alpha/alpha.md --- gcc/config/alpha/alpha.md.orig +++ gcc/config/alpha/alpha.md @@ -4827,7 +4827,8 @@ if (CONST_INT_P (operands[1]) && INTVAL (operands[1]) < 32768) { - if (INTVAL (operands[1]) >= 4096) + if (INTVAL (operands[1]) >= 4096 + && (flag_stack_check || STACK_CHECK_BUILTIN)) { /* We do this the same way as in the prologue and generate explicit probes. Then we update the stack by the constant. */ Index: gcc/config/alpha/alpha.opt --- gcc/config/alpha/alpha.opt.orig +++ gcc/config/alpha/alpha.opt @@ -38,6 +38,10 @@ mieee Target Report RejectNegative Mask(IEEE) Emit IEEE-conformant code, without inexact exceptions. +mno-ieee +Target Report RejectNegative InverseMask(IEEE) +Emit non-IEEE-conformant code + mieee-with-inexact Target Report RejectNegative Mask(IEEE_WITH_INEXACT) Index: gcc/config/alpha/openbsd.h --- gcc/config/alpha/openbsd.h.orig +++ gcc/config/alpha/openbsd.h @@ -41,6 +41,28 @@ along with GCC; see the file COPYING3. If not see #undef ENDFILE_SPEC #define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}" +#undef TARGET_DEFAULT +#define TARGET_DEFAULT \ + (MASK_FPREGS | MASK_IEEE | MASK_IEEE_CONFORMANT) + +#define LINK_SPEC \ + "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \ + %{shared:-shared} %{R*} \ + %{static:-Bstatic} \ + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ + %{!static:-dynamic-linker /usr/libexec/ld.so}" + +/* As an elf system, we need crtbegin/crtend stuff. */ +#undef STARTFILE_SPEC +#define STARTFILE_SPEC "\ + %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} \ + %{!p:%{!static:crt0%O%s} %{static:%{nopie:crt0%O%s} \ + %{!nopie:rcrt0%O%s}}}} crtbegin%O%s} %{shared:crtbeginS%O%s}" +#undef ENDFILE_SPEC +#define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}" + /* run-time target specifications */ #define TARGET_OS_CPP_BUILTINS() \ do { \ --- gcc/config/exec-stack.h.orig Wed Oct 18 13:49:09 2006 +++ gcc/config/exec-stack.h Wed Oct 18 13:49:04 2006 @@ -0,0 +1,40 @@ +/* Enable stack execute around trampoline address. + Copyright (C) 2002 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#undef FINALIZE_TRAMPOLINE +#define FINALIZE_TRAMPOLINE(TRAMP) \ + emit_library_call(gen_rtx_SYMBOL_REF (Pmode, "__enable_execute_stack"), \ + 0, VOIDmode, 1, memory_address (SImode, (TRAMP)), Pmode) + +#undef TRANSFER_FROM_TRAMPOLINE +#define TRANSFER_FROM_TRAMPOLINE \ +extern void __enable_execute_stack (void *); \ +void \ +__enable_execute_stack (addr) \ + void *addr; \ +{ \ + long size = getpagesize (); \ + long mask = ~(size-1); \ + char *page = (char *) (((long) addr) & mask); \ + char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \ + \ + if (mprotect (page, end - page, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) \ + perror ("mprotect of trampoline code"); \ +} Index: gcc/config.gcc --- gcc/config.gcc.orig +++ gcc/config.gcc @@ -850,6 +850,14 @@ case ${target} in default_gnu_indirect_function=yes ;; esac + case ${target} in + *-*-openbsd[0-3].*|*-*-openbsd4.[012]) + # keep default of no cxa_atexit support for these older releases + ;; + *) + default_use_cxa_atexit=yes + ;; + esac ;; *-*-openbsd*) tmake_file="t-openbsd" @@ -1021,6 +1029,13 @@ aarch64*-*-freebsd*) tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-freebsd" tm_defines="${tm_defines} TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1" ;; +aarch64-*-openbsd*) + tm_file="${tm_file} dbxelf.h elfos.h" + tm_file="${tm_file} aarch64/aarch64-elf.h openbsd-stdint.h" + tm_file="${tm_file} openbsd.h aarch64/openbsd.h openbsd-libpthread.h" + tmake_file="${tmake_file} aarch64/t-aarch64" + extra_options="${extra_options} openbsd.opt" + ;; aarch64*-*-linux*) tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h" tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-linux.h" @@ -1062,7 +1077,7 @@ alpha*-*-netbsd*) alpha/elf.opt" ;; alpha*-*-openbsd*) - tm_defines="${tm_defines} OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_FUNCTION_SIZE OBSD_HAS_DECLARE_OBJECT" + tm_defines="${tm_defines} OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_FUNCTION_SIZE OBSD_HAS_DECLARE_OBJECT DEFAULT_FLAG_PIE=2" tm_file="elfos.h alpha/alpha.h alpha/elf.h openbsd.h openbsd-stdint.h alpha/openbsd.h openbsd-libpthread.h" tmake_file="${tmake_file} alpha/t-alpha" extra_options="${extra_options} openbsd.opt alpha/elf.opt" @@ -1505,10 +1520,11 @@ hppa*-*-linux*) ;; hppa*-*-openbsd*) target_cpu_default="MASK_PA_11" + tm_defines="${tm_defines} DEFAULT_FLAG_PIE=1" tm_file="${tm_file} dbxelf.h elfos.h openbsd.h openbsd-stdint.h openbsd-libpthread.h \ pa/pa-openbsd.h pa/pa32-regs.h pa/pa32-openbsd.h" extra_options="${extra_options} openbsd.opt" - tmake_file="pa/t-pa" + tmake_file="${tmake_file} pa/t-pa" d_target_objs="${d_target_objs} pa-d.o" gas=yes gnu_ld=yes @@ -1689,6 +1705,7 @@ x86_64-*-netbsd*) extra_options="${extra_options} netbsd.opt netbsd-elf.opt" ;; i[34567]86-*-openbsd*) + tm_defines="${tm_defines} DEFAULT_FLAG_PIE=1" tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h" tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h i386/openbsdelf.h" extra_options="${extra_options} openbsd.opt" @@ -1696,12 +1713,25 @@ i[34567]86-*-openbsd*) gnu_ld=yes ;; x86_64-*-openbsd*) + tm_defines="${tm_defines} DEFAULT_FLAG_PIE=1 CF_DEFAULT=CF_BRANCH" tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h" tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h i386/x86-64.h i386/openbsdelf.h" extra_options="${extra_options} openbsd.opt" gas=yes gnu_ld=yes ;; +mips64-*-openbsd*) + set + tm_file="dbxelf.h elfos.h openbsd.h openbsd-stdint.h mips/mips.h mips/openbsd.h openbsd-libpthread.h" + tm_defines="MIPS_ISA_DEFAULT=3 MIPS_ABI_DEFAULT=ABI_64 DEFAULT_FLAG_PIE=1" + extra_options="${extra_options} openbsd.opt" + ;; +mips64el-*-openbsd*) + set + tm_file="dbxelf.h elfos.h openbsd.h openbsd-stdint.h mips/mips.h mips/openbsd.h openbsd-libpthread.h" + tm_defines="MIPS_ISA_DEFAULT=3 MIPS_ABI_DEFAULT=ABI_64 TARGET_ENDIAN_DEFAULT=0 DEFAULT_FLAG_PIE=1" + extra_options="${extra_options} openbsd.opt" + ;; i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-gnu* | i[34567]86-*-kopensolaris*-gnu) # Intel 80386's running GNU/* # with ELF format using glibc 2 @@ -2266,6 +2296,19 @@ mips*-*-netbsd*) # NetBSD/mips, either endian. tm_file="elfos.h ${tm_file} mips/elf.h ${nbsd_tm_file} mips/netbsd.h" extra_options="${extra_options} netbsd.opt netbsd-elf.opt" ;; +riscv64-*-openbsd*) + tm_file="${tm_file} dbxelf.h elfos.h" + tm_file="${tm_file} openbsd-stdint.h" + tm_file="${tm_file} openbsd.h riscv/openbsd.h openbsd-libpthread.h" + tmake_file="${tmake_file} riscv/t-riscv" + extra_options="${extra_options} openbsd.opt" + # Force .init_array support. The configure script cannot always + # automatically detect that GAS supports it, yet we require it. + gcc_cv_initfini_array=yes + # Also force this, shouldn't hurt... + gnu_ld=yes + gas=yes + ;; mips*-img-linux*) tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/linux.h mips/linux-common.h mips/mti-linux.h" extra_options="${extra_options} linux-android.opt" @@ -2604,6 +2647,18 @@ pdp11-*-*) # tmake_file="${tmake_file} rs6000/t-fprules" # extra_headers= # ;; +powerpc-*-openbsd*) + tm_defines="${tm_defines} DEFAULT_FLAG_PIE=2" + tm_file="rs6000/secureplt.h ${tm_file} dbxelf.h elfos.h gnu-user.h openbsd.h openbsd-stdint.h openbsd-libpthread.h freebsd-spec.h rs6000/sysv4.h rs6000/openbsd.h" + tmake_file="${tmake_file} rs6000/t-openbsd" + extra_options="${extra_options} rs6000/sysv4.opt openbsd.opt" + ;; +powerpc64*-*-openbsd*) + tm_defines="${tm_defines} DEFAULT_FLAG_PIE=2" + tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h openbsd.h openbsd-stdint.h openbsd-libpthread.h freebsd-spec.h rs6000/sysv4.h rs6000/default64.h rs6000/openbsd64.h" + tmake_file="${tmake_file} rs6000/t-openbsd64" + extra_options="${extra_options} rs6000/sysv4.opt rs6000/linux64.opt openbsd.opt" + ;; powerpc-*-darwin*) extra_options="${extra_options} rs6000/darwin.opt" case ${target} in @@ -3122,10 +3177,10 @@ sparc64-*-netbsd*) tmake_file="${tmake_file} sparc/t-sparc sparc/t-netbsd64" ;; sparc64-*-openbsd*) + tm_defines="${tm_defines} DEFAULT_FLAG_PIE=2" tm_file="sparc/openbsd1-64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h sparc/sp64-elf.h" tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h sparc/openbsd64.h" extra_options="${extra_options} openbsd.opt" - extra_options="${extra_options}" gas=yes gnu_ld=yes with_cpu=ultrasparc tmake_file="${tmake_file} sparc/t-sparc" @@ -3359,6 +3414,12 @@ case ${target} in else arch=i386 fi + cpu=generic + arch_without_sse2=yes + arch_without_64bit=yes + ;; + i386-*-openbsd*) + arch=pentium cpu=generic arch_without_sse2=yes arch_without_64bit=yes Index: gcc/config/i386/i386.c --- gcc/config/i386/i386.c.orig +++ gcc/config/i386/i386.c @@ -5876,6 +5876,7 @@ ix86_compute_frame_layout (void) } } + frame->local_size = size; frame->nregs = ix86_nsaved_regs (); frame->nsseregs = ix86_nsaved_sseregs (); @@ -7936,6 +7937,9 @@ ix86_expand_prologue (void) RTX_FRAME_RELATED_P (insn) = 1; } } + + if (warn_stack_larger_than && frame.local_size > stack_larger_than_size) + warning (OPT_Wstack_larger_than_, "stack usage is %lld bytes", frame.local_size); int_registers_saved = (frame.nregs == 0); sse_registers_saved = (frame.nsseregs == 0); Index: gcc/config/i386/i386.h --- gcc/config/i386/i386.h.orig +++ gcc/config/i386/i386.h @@ -2589,6 +2589,8 @@ struct GTY(()) ix86_frame HOST_WIDE_INT stack_realign_offset; HOST_WIDE_INT sse_reg_save_offset; + HOST_WIDE_INT local_size; + /* When save_regs_using_mov is set, emit prologue using move instead of push instructions. */ bool save_regs_using_mov; Index: gcc/config/i386/openbsdelf.h --- gcc/config/i386/openbsdelf.h.orig +++ gcc/config/i386/openbsdelf.h @@ -91,14 +91,18 @@ along with GCC; see the file COPYING3. If not see %{shared:-shared} %{R*} \ %{static:-Bstatic} \ %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ %{assert*} \ - -dynamic-linker /usr/libexec/ld.so" + %{!static:-dynamic-linker /usr/libexec/ld.so} \ + %{!nostdlib:-L/usr/lib}" #undef STARTFILE_SPEC -#define STARTFILE_SPEC "\ - %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} %{!p:crt0%O%s}} \ - crtbegin%O%s} %{shared:crtbeginS%O%s}" +#define SUBTARGET32_DEFAULT_CPU "i586" +#define STARTFILE_SPEC "\ + %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} \ + %{!p:%{!static:crt0%O%s} %{static:%{nopie:crt0%O%s} \ + %{!nopie:rcrt0%O%s}}}} crtbegin%O%s} %{shared:crtbeginS%O%s}" #undef ENDFILE_SPEC #define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}" Index: gcc/config/mips/mips.h --- gcc/config/mips/mips.h.orig +++ gcc/config/mips/mips.h @@ -1460,7 +1460,9 @@ FP_ASM_SPEC "\ #define SUBTARGET_CPP_SPEC "" #endif +#ifndef CPP_SPEC #define CPP_SPEC "%(subtarget_cpp_spec)" +#endif /* This macro defines names of additional specifications to put in the specs that can be used in various specifications like CC1_SPEC. Its definition @@ -3443,16 +3445,6 @@ struct GTY(()) machine_function { with arguments ARGS. */ #define PMODE_INSN(NAME, ARGS) \ (Pmode == SImode ? NAME ## _si ARGS : NAME ## _di ARGS) - -/* If we are *not* using multilibs and the default ABI is not ABI_32 we - need to change these from /lib and /usr/lib. */ -#if MIPS_ABI_DEFAULT == ABI_N32 -#define STANDARD_STARTFILE_PREFIX_1 "/lib32/" -#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib32/" -#elif MIPS_ABI_DEFAULT == ABI_64 -#define STANDARD_STARTFILE_PREFIX_1 "/lib64/" -#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib64/" -#endif /* Load store bonding is not supported by micromips and fix_24k. The performance can be degraded for those targets. Hence, do not bond for Index: gcc/config/mips/openbsd.h --- gcc/config/mips/openbsd.h.orig +++ gcc/config/mips/openbsd.h @@ -0,0 +1,227 @@ +/* Configuration file for a mips64 OpenBSD target. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING. If not, write to +the Free Software Foundation, 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ + +/* This must agree with */ +#undef SIZE_TYPE +#define SIZE_TYPE "long unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "long int" + +#undef INTMAX_TYPE +#define INTMAX_TYPE "long long int" + +#undef UINTMAX_TYPE +#define UINTMAX_TYPE "long long unsigned int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 32 + +#if 0 +/* dropped in 2007 in 311f69621cc28f7a626407f55cf2d60392856ccf + * See also 2f14b1f9d493c8f64d5ff6b284bfe91ad8433d37 */ + +/* If defined, a C expression whose value is a string containing the + assembler operation to identify the following data as + uninitialized global data. If not defined, and neither + `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined, + uninitialized global data will be output in the data section if + `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be + used. */ +#define BSS_SECTION_ASM_OP "\t.section\t.bss" + +#define ASM_OUTPUT_ALIGNED_BSS mips_output_aligned_bss +#endif + +#undef ASM_DECLARE_OBJECT_NAME +#define ASM_DECLARE_OBJECT_NAME mips_declare_object_name + +#undef MD_EXEC_PREFIX +#undef MD_STARTFILE_PREFIX + +/* If we don't set MASK_ABICALLS, we can't default to PIC. */ +#undef TARGET_DEFAULT +#define TARGET_DEFAULT MASK_ABICALLS + +#define TARGET_OS_CPP_BUILTINS() \ + do { \ + OPENBSD_OS_CPP_BUILTINS(); \ + \ + if (TARGET_64BIT) \ + builtin_define ("__mips64__"); \ + \ + if (TARGET_ABICALLS) \ + builtin_define ("__ABICALLS__"); \ + \ + if (mips_abi == ABI_EABI) \ + builtin_define ("__mips_eabi"); \ + else if (mips_abi == ABI_N32) \ + builtin_define ("__mips_n32"); \ + else if (mips_abi == ABI_64) \ + builtin_define ("__mips_n64"); \ + else if (mips_abi == ABI_O64) \ + builtin_define ("__mips_o64"); \ + \ + if (mips_abi == ABI_N32) \ + { \ + builtin_define ("_ABIN32=2"); \ + builtin_define ("_MIPS_SIM=_ABIN32"); \ + builtin_define ("_MIPS_SZLONG=32"); \ + builtin_define ("_MIPS_SZPTR=32"); \ + } \ + else if (mips_abi == ABI_64) \ + { \ + builtin_define ("_ABI64=3"); \ + builtin_define ("_MIPS_SIM=_ABI64"); \ + builtin_define ("_MIPS_SZLONG=64"); \ + builtin_define ("_MIPS_SZPTR=64"); \ + } \ + else \ + { \ + builtin_define ("_ABIO32=1"); \ + builtin_define ("_MIPS_SIM=_ABIO32"); \ + builtin_define ("_MIPS_SZLONG=32"); \ + builtin_define ("_MIPS_SZPTR=32"); \ + } \ + if (TARGET_FLOAT64) \ + builtin_define ("_MIPS_FPSET=32"); \ + else \ + builtin_define ("_MIPS_FPSET=16"); \ + \ + builtin_define ("_MIPS_SZINT=32"); \ + } while (0) + +#undef SUBTARGET_CPP_SPEC +#define SUBTARGET_CPP_SPEC OBSD_CPP_SPEC + +/* A standard GNU/Linux mapping. On most targets, it is included in + CC1_SPEC itself by config/linux.h, but mips.h overrides CC1_SPEC + and provides this hook instead. */ +#undef SUBTARGET_CC1_SPEC +#define SUBTARGET_CC1_SPEC "%{profile:-p}" + +/* From iris5.h */ +/* -G is incompatible with -KPIC which is the default, so only allow objects + in the small data section if the user explicitly asks for it. */ +#undef MIPS_DEFAULT_GVALUE +#define MIPS_DEFAULT_GVALUE 0 + +/* Borrowed from sparc/linux.h */ +#undef LINK_SPEC +#define LINK_SPEC \ + "%(endian_spec) \ + %{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \ + %{shared:-shared} %{R*} \ + %{static:-Bstatic} \ + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ + %{!static:-dynamic-linker /usr/libexec/ld.so}" + +/* As an elf system, we need crtbegin/crtend stuff. */ +#undef STARTFILE_SPEC +#define STARTFILE_SPEC "\ + %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} \ + %{!p:%{!static:crt0%O%s} %{static:%{nopie:crt0%O%s} \ + %{!nopie:rcrt0%O%s}}}} \ + crtbegin%O%s} %{shared:crtbeginS%O%s}" +#undef ENDFILE_SPEC +#define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}" + +#undef SUBTARGET_ASM_SPEC +#define SUBTARGET_ASM_SPEC "%{mabi=64: -64} %{!mno-abicalls:-KPIC}" + +/* The MIPS assembler has different syntax for .set. We set it to + .dummy to trap any errors. */ +#undef SET_ASM_OP +#define SET_ASM_OP "\t.dummy\t" + +#undef ASM_OUTPUT_DEF +#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ + do { \ + fputc ( '\t', FILE); \ + assemble_name (FILE, LABEL1); \ + fputs ( " = ", FILE); \ + assemble_name (FILE, LABEL2); \ + fputc ( '\n', FILE); \ + } while (0) + + +#if 0 +gone with a8cceccd90827cb0920c0af1ed823e37d8d72e2a + +#undef ASM_DECLARE_FUNCTION_NAME +#define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \ + do { \ + if (!flag_inhibit_size_directive) \ + { \ + fputs ("\t.ent\t", STREAM); \ + assemble_name (STREAM, NAME); \ + putc ('\n', STREAM); \ + } \ + ASM_OUTPUT_TYPE_DIRECTIVE (STREAM, NAME, "function"); \ + assemble_name (STREAM, NAME); \ + fputs (":\n", STREAM); \ + } while (0) + +#undef ASM_DECLARE_FUNCTION_SIZE +#define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \ + do { \ + if (!flag_inhibit_size_directive) \ + { \ + fputs ("\t.end\t", STREAM); \ + assemble_name (STREAM, NAME); \ + putc ('\n', STREAM); \ + } \ + } while (0) + +/* Tell function_prologue in mips.c that we have already output the .ent/.end + pseudo-ops. */ +#undef FUNCTION_NAME_ALREADY_DECLARED +#define FUNCTION_NAME_ALREADY_DECLARED 1 +#endif + +#undef LOCAL_LABEL_PREFIX +#define LOCAL_LABEL_PREFIX "." + +/* The glibc _mcount stub will save $v0 for us. Don't mess with saving + it, since ASM_OUTPUT_REG_PUSH/ASM_OUTPUT_REG_POP do not work in the + presence of $gp-relative calls. */ +#undef ASM_OUTPUT_REG_PUSH +#undef ASM_OUTPUT_REG_POP + +#undef LIB_SPEC +#define LIB_SPEC OBSD_LIB_SPEC + +/* #undef ENABLE_EXECUTE_STACK */ + +/* Default to -mfix-r4000 -mfix-r4400 when compiling big endian. */ +#undef SUBTARGET_OVERRIDE_OPTIONS +#define SUBTARGET_OVERRIDE_OPTIONS \ + do { \ + if (TARGET_BIG_ENDIAN) \ + { \ + target_flags |= MASK_FIX_R4000 | MASK_FIX_R4400; \ + } \ + } while (0) --- gcc/config/openbsd-libpthread.h.orig Sun Sep 27 09:20:23 2009 +++ gcc/config/openbsd-libpthread.h Sat Aug 25 09:50:23 2012 @@ -18,5 +18,5 @@ along with GCC; see the file COPYING3. If not see . */ -#define OBSD_LIB_SPEC "%{!shared:%{pthread:-lpthread} -lc}" +#define OBSD_LIB_SPEC "%{pthread:-lpthread%{!shared:%{p|pg:_p}}} %{!shared:-lc%{p:_p}%{!p:%{pg:_p}}}" Index: gcc/config/openbsd.h --- gcc/config/openbsd.h.orig +++ gcc/config/openbsd.h @@ -40,6 +40,10 @@ along with GCC; see the file COPYING3. If not see intended as common ground for arch that don't provide anything suitable. */ +/* Make sure that gcc will not look for .h files in /usr/local/include + unless user explicitly requests it. */ +#undef LOCAL_INCLUDE_DIR + /* OPENBSD_NATIVE is defined only when gcc is configured as part of the OpenBSD source tree, specifically through Makefile.bsd-wrapper. @@ -108,9 +112,9 @@ while (0) This two-stage defines makes it easy to pick that for targets that have subspecs. */ #ifdef CPP_CPU_SPEC -#define OBSD_CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}" +#define OBSD_CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" #else -#define OBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}" +#define OBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" #endif #undef LIB_SPEC @@ -284,6 +288,12 @@ do { \ #endif /* Storage layout. */ + +/* + * Disable the use of unsafe builtin functions, (strcat, strcpy, stpcpy), + * making them easier to spot in the object files. + */ +#define NO_UNSAFE_BUILTINS #define HAVE_ENABLE_EXECUTE_STACK --- gcc/config/openbsd.opt.orig Sat Jun 8 22:49:21 2013 +++ gcc/config/openbsd.opt Sat Jun 8 22:49:33 2013 @@ -32,4 +32,7 @@ Driver pthread Driver +rdynamic +Driver + ; This comment is to ensure we retain the blank line above. Index: gcc/config/pa/pa-openbsd.h --- gcc/config/pa/pa-openbsd.h.orig +++ gcc/config/pa/pa-openbsd.h @@ -138,14 +138,15 @@ along with GCC; see the file COPYING3. If not see %{shared:-shared} %{R*} \ %{static:-Bstatic} \ %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ %{assert*} \ - -dynamic-linker /usr/libexec/ld.so" + %{!static:-dynamic-linker /usr/libexec/ld.so}" #undef STARTFILE_SPEC #define STARTFILE_SPEC "\ - %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} %{!p:crt0%O%s}} \ - crtbegin%O%s} %{shared:crtbeginS%O%s}" - + %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} \ + %{!p:%{!static:crt0%O%s} %{static:%{nopie:crt0%O%s} \ + %{!nopie:rcrt0%O%s}}}} crtbegin%O%s} %{shared:crtbeginS%O%s}" #undef ENDFILE_SPEC #define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}" Index: gcc/config/pa/pa.c --- gcc/config/pa/pa.c.orig +++ gcc/config/pa/pa.c @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see #include "recog.h" #include "diagnostic-core.h" #include "insn-attr.h" +#include "flags.h" #include "alias.h" #include "fold-const.h" #include "stor-layout.h" @@ -3933,6 +3934,9 @@ pa_expand_prologue (void) actual_fsize = pa_compute_frame_size (size, &save_fregs); if (flag_stack_usage_info) current_function_static_stack_size = actual_fsize; + + if (warn_stack_larger_than && actual_fsize > stack_larger_than_size) + warning (OPT_Wstack_larger_than_, "stack usage is %lld bytes", actual_fsize); /* Compute a few things we will use often. */ tmpreg = gen_rtx_REG (word_mode, 1); Index: gcc/config/pa/pa.h --- gcc/config/pa/pa.h.orig +++ gcc/config/pa/pa.h @@ -317,6 +317,9 @@ typedef struct GTY(()) machine_function && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \ && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN)) +/* Make local arrays of chars word-aligned for the same reasons. */ +#define LOCAL_ALIGNMENT(TYPE, ALIGN) DATA_ALIGNMENT (TYPE, ALIGN) + /* Set this nonzero if move instructions will actually fail to work when given unaligned data. */ #define STRICT_ALIGNMENT 1 Index: gcc/config/riscv/openbsd.h --- gcc/config/riscv/openbsd.h.orig +++ gcc/config/riscv/openbsd.h @@ -0,0 +1,121 @@ +/* Definitions of target machine for GNU compiler, OpenBSD/riscv64 ELF version. + Copyright (C) 2002 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This defaults us to little-endian. */ +#ifndef TARGET_ENDIAN_DEFAULT +#define TARGET_ENDIAN_DEFAULT 0 +#endif + +#undef MULTILIB_DEFAULTS +/* The default STARTFILE_PREFIX_SPEC for riscv adds some multilib-aware + paths that we don't provide, instead of /usr/local/lib which is + needed to get at various files shipped by this port (libatomic.so, + libgfortran.spec, etc). +*/ +#undef STARTFILE_PREFIX_SPEC + +/* + * Without linker relaxation in lld(1) we have to use the most generic + * code model. XXX check lld 15.0 support for relaxation. + */ +#undef TARGET_DEFAULT_CMODEL +#define TARGET_DEFAULT_CMODEL CM_MEDANY + +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0"); \ + OPENBSD_OS_CPP_BUILTINS_ELF(); \ + } \ + while (0) + +#undef SUBTARGET_CPP_SPEC +#define SUBTARGET_CPP_SPEC OBSD_CPP_SPEC + +#define LINK_SPEC \ + "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \ + %{shared:-shared} %{R*} \ + %{static:-Bstatic} \ + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ + %{!static:-dynamic-linker /usr/libexec/ld.so} \ + %{!nostdlib:-L/usr/lib}" + +#define OPENBSD_ENTRY_POINT "__start" + +/* Make GCC agree with . */ + +#undef SIZE_TYPE +#define SIZE_TYPE "long unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "long int" + +#undef INTMAX_TYPE +#define INTMAX_TYPE "long long int" + +#undef UINTMAX_TYPE +#define UINTMAX_TYPE "long long unsigned int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 32 + +/* Provide a STARTFILE_SPEC appropriate for OpenBSD ELF. Here we + provide support for the special GCC option -static. On ELF + targets, we also add the crtbegin.o file, which provides part + of the support for getting C++ file-scope static objects + constructed before entering "main". */ + +#define OPENBSD_STARTFILE_SPEC \ + "%{!shared: \ + %{pg:gcrt0%O%s} \ + %{!pg: \ + %{p:gcrt0%O%s} \ + %{!p:%{!static:crt0%O%s} %{static:%{nopie:crt0%O%s} \ + %{!nopie:rcrt0%O%s}}}}} \ + %:if-exists(crti%O%s) \ + %{static:%:if-exists-else(crtbeginT%O%s crtbegin%O%s)} \ + %{!static: \ + %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}" + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC OPENBSD_STARTFILE_SPEC + +/* Provide an ENDFILE_SPEC appropriate for OpenBSD ELF. Here we +add crtend.o, which provides part of the support for getting +C++ file-scope static objects deconstructed after exiting "main". */ + +#define OPENBSD_ENDFILE_SPEC \ + "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \ + %:if-exists(crtn%O%s)" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC OPENBSD_ENDFILE_SPEC + +/* Remove -mcpu=native handling which is Linux specific */ +#undef DRIVER_SELF_SPECS +#define DRIVER_SELF_SPECS "" + +/* dito */ +#undef EXTRA_SPEC_FUNCTIONS lld doesn't support -mrelax. XXX check lld 15 Index: gcc/config/riscv/riscv.opt --- gcc/config/riscv/riscv.opt.orig +++ gcc/config/riscv/riscv.opt @@ -110,7 +110,7 @@ Target Report Mask(EXPLICIT_RELOCS) Use %reloc() operators, rather than assembly macros, to load addresses. mrelax -Target Bool Var(riscv_mrelax) Init(1) +Target Bool Var(riscv_mrelax) Init(0) Take advantage of linker relaxations to reduce the number of instructions required to materialize symbol addresses. Index: gcc/config/rs6000/driver-rs6000.c --- gcc/config/rs6000/driver-rs6000.c.orig +++ gcc/config/rs6000/driver-rs6000.c @@ -82,6 +82,8 @@ const char *host_detect_local_cpu (int argc, const cha #if GCC_VERSION >= 0 +#if defined(_AIX) || defined(__APPLE__) || defined(__FreeBSD__) || \ + defined(__linux__) /* Returns parameters that describe L1_ASSOC associative cache of size L1_SIZEKB with lines of size L1_LINE, and L2_SIZEKB. */ @@ -100,6 +102,7 @@ describe_cache (unsigned l1_sizekb, unsigned l1_line, return concat (l1size, " ", line, " ", l2size, " ", NULL); } +#endif #ifdef __APPLE__ --- gcc/config/rs6000/openbsd1.h.orig Tue Jun 12 14:05:16 2007 +++ gcc/config/rs6000/openbsd1.h Tue Jun 12 14:05:16 2007 @@ -0,0 +1,24 @@ +/* Configuration file for an rs6000 OpenBSD target. + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define OBSD_HAS_CORRECT_SPECS +#define OBSD_HAS_DECLARE_FUNCTION_NAME +#define OBSD_HAS_DECLARE_FUNCTION_SIZE +#define OBSD_HAS_DECLARE_OBJECT Index: gcc/config/rs6000/openbsd64.h --- gcc/config/rs6000/openbsd64.h.orig +++ gcc/config/rs6000/openbsd64.h @@ -0,0 +1,413 @@ +/* Definitions for 64-bit PowerPC running OpenBSD using the ELF format + Copyright (C) 2012-2021 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +/* Override the defaults, which exist to force the proper definition. */ + +#ifdef IN_LIBGCC2 +#undef TARGET_64BIT +#ifdef __powerpc64__ +#define TARGET_64BIT 1 +#else +#define TARGET_64BIT 0 +#endif +#endif + +#undef TARGET_AIX +#define TARGET_AIX TARGET_64BIT + +#ifdef HAVE_LD_NO_DOT_SYMS +/* New ABI uses a local sym for the function entry point. */ +extern int dot_symbols; +#undef DOT_SYMBOLS +#define DOT_SYMBOLS dot_symbols +#endif + +#define TARGET_USES_LINUX64_OPT 1 +#ifdef HAVE_LD_LARGE_TOC +#undef TARGET_CMODEL +#define TARGET_CMODEL rs6000_current_cmodel +#define SET_CMODEL(opt) rs6000_current_cmodel = opt +#else +#define SET_CMODEL(opt) do {} while (0) +#endif + +#undef PROCESSOR_DEFAULT +#define PROCESSOR_DEFAULT PROCESSOR_POWER7 +#undef PROCESSOR_DEFAULT64 +#define PROCESSOR_DEFAULT64 PROCESSOR_POWER8 + +/* We don't need to generate entries in .fixup, except when + -mrelocatable or -mrelocatable-lib is given. */ +#undef RELOCATABLE_NEEDS_FIXUP +#define RELOCATABLE_NEEDS_FIXUP \ + (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE) + +#undef RS6000_ABI_NAME +#define RS6000_ABI_NAME "openbsd" + +#define INVALID_64BIT "%<-m%s%> not supported in this configuration" +#define INVALID_32BIT INVALID_64BIT + +/* OpenBSD/powerpc64 uses the ELF v2 ABI by default. */ +#define ELFv2_ABI_CHECK (rs6000_elf_abi != 1) + +#undef SUBSUBTARGET_OVERRIDE_OPTIONS +#define SUBSUBTARGET_OVERRIDE_OPTIONS \ + do \ + { \ + if (!global_options_set.x_rs6000_alignment_flags) \ + rs6000_alignment_flags = MASK_ALIGN_NATURAL; \ + if (TARGET_64BIT) \ + { \ + if (DEFAULT_ABI != ABI_AIX) \ + { \ + rs6000_current_abi = ABI_AIX; \ + error (INVALID_64BIT, "call"); \ + } \ + dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \ + if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \ + { \ + rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \ + error (INVALID_64BIT, "relocatable"); \ + } \ + if (ELFv2_ABI_CHECK) \ + { \ + rs6000_current_abi = ABI_ELFv2; \ + if (dot_symbols) \ + error ("-mcall-aixdesc incompatible with -mabi=elfv2"); \ + } \ + if (rs6000_isa_flags & OPTION_MASK_EABI) \ + { \ + rs6000_isa_flags &= ~OPTION_MASK_EABI; \ + error (INVALID_64BIT, "eabi"); \ + } \ + if (TARGET_PROTOTYPE) \ + { \ + target_prototype = 0; \ + error (INVALID_64BIT, "prototype"); \ + } \ + if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \ + { \ + rs6000_isa_flags |= OPTION_MASK_POWERPC64; \ + error ("-m64 requires a PowerPC64 cpu"); \ + } \ + if ((rs6000_isa_flags_explicit \ + & OPTION_MASK_MINIMAL_TOC) != 0) \ + { \ + if (global_options_set.x_rs6000_current_cmodel \ + && rs6000_current_cmodel != CMODEL_SMALL) \ + error ("-mcmodel incompatible with other toc options"); \ + SET_CMODEL (CMODEL_SMALL); \ + } \ + else \ + { \ + if (!global_options_set.x_rs6000_current_cmodel) \ + SET_CMODEL (CMODEL_MEDIUM); \ + if (rs6000_current_cmodel != CMODEL_SMALL) \ + { \ + TARGET_NO_FP_IN_TOC = 0; \ + TARGET_NO_SUM_IN_TOC = 0; \ + } \ + } \ + } \ + } \ + while (0) + +#undef ASM_DEFAULT_SPEC +#undef ASM_SPEC + +#define ASM_DEFAULT_SPEC "-mppc%{!m32:64}" +#define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)" + +#define ASM_SPEC32 "-a32 \ +%{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \ +%{memb} %{!memb: %{msdata=eabi: -memb}} \ +%{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \ + %{mcall-freebsd: -mbig} \ + %{mcall-i960-old: -mlittle} \ + %{mcall-linux: -mbig} \ + %{mcall-gnu: -mbig} \ + %{mcall-netbsd: -mbig} \ +}}}}" + +#define ASM_SPEC64 "-a64" + +#define ASM_SPEC_COMMON "%(asm_cpu) \ +%{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \ +%{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}" + +#undef SUBSUBTARGET_EXTRA_SPECS +#define SUBSUBTARGET_EXTRA_SPECS \ + { "asm_spec_common", ASM_SPEC_COMMON }, \ + { "asm_spec32", ASM_SPEC32 }, \ + { "asm_spec64", ASM_SPEC64 }, + +#undef MULTILIB_DEFAULTS +#define MULTILIB_DEFAULTS { "m64" } + +/* OpenBSD/powerpc64 increases natural record alignment to doubleword if + the first field is an FP double, only if in power alignment mode. */ +#undef ROUND_TYPE_ALIGN +#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ + ((TARGET_64BIT \ + && (TREE_CODE (STRUCT) == RECORD_TYPE \ + || TREE_CODE (STRUCT) == UNION_TYPE \ + || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ + && TARGET_ALIGN_NATURAL == 0) \ + ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \ + : MAX ((COMPUTED), (SPECIFIED))) + +/* Use the default for compiling target libs. */ +#ifdef IN_TARGET_LIBS +#undef TARGET_ALIGN_NATURAL +#define TARGET_ALIGN_NATURAL 1 +#endif + +/* Indicate that jump tables go in the text section. */ +#undef JUMP_TABLES_IN_TEXT_SECTION +#define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT + +/* The linux ppc64 ABI isn't explicit on whether aggregates smaller + than a doubleword should be padded upward or downward. You could + reasonably assume that they follow the normal rules for structure + layout treating the parameter area as any other block of memory, + then map the reg param area to registers. i.e. pad upward. + Setting both of the following defines results in this behavior. + Setting just the first one will result in aggregates that fit in a + doubleword being padded downward, and others being padded upward. + Not a bad idea as this results in struct { int x; } being passed + the same way as an int. */ +#define AGGREGATE_PADDING_FIXED TARGET_64BIT +#define AGGREGATES_PAD_UPWARD_ALWAYS 0 + +/* Specify padding for the last element of a block move between + registers and memory. FIRST is nonzero if this is the only + element. */ +#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \ + (!(FIRST) ? PAD_UPWARD : targetm.calls.function_arg_padding (MODE, TYPE)) + +/* OpenBSD doesn't support saving and restoring 64-bit regs with a 32-bit + kernel. */ +#define OS_MISSING_POWERPC64 !TARGET_64BIT + +#undef TARGET_OS_CPP_BUILTINS +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + OPENBSD_OS_CPP_BUILTINS_ELF(); \ + builtin_define ("__PPC__"); \ + builtin_define ("__ppc__"); \ + builtin_define ("__powerpc__"); \ + if (TARGET_64BIT) \ + { \ + builtin_define ("__arch64__"); \ + builtin_define ("__LP64__"); \ + builtin_define ("__PPC64__"); \ + builtin_define ("__powerpc64__"); \ + builtin_assert ("cpu=powerpc64"); \ + builtin_assert ("machine=powerpc64"); \ + } \ + else \ + { \ + builtin_define_std ("PPC"); \ + builtin_define_std ("powerpc"); \ + builtin_assert ("cpu=powerpc"); \ + builtin_assert ("machine=powerpc"); \ + TARGET_OS_SYSV_CPP_BUILTINS (); \ + } \ + } \ + while (0) + +#undef CPP_OS_DEFAULT_SPEC +#define CPP_OS_DEFAULT_SPEC "%(cpp_os_openbsd)" + +#undef LINK_SPEC +#define LINK_SPEC \ + "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \ + %{shared:-shared} %{R*} \ + %{static:-Bstatic} \ + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ + %{!static:-dynamic-linker /usr/libexec/ld.so} \ + %{!nostdlib:-L/usr/lib}" + +#undef LIB_DEFAULT_SPEC +#define LIB_DEFAULT_SPEC "%(lib_openbsd)" + +#undef STARTFILE_DEFAULT_SPEC +#define STARTFILE_DEFAULT_SPEC "%(startfile_openbsd)" + +#undef ENDFILE_DEFAULT_SPEC +#define ENDFILE_DEFAULT_SPEC "%(endfile_openbsd)" + +#undef LINK_START_DEFAULT_SPEC +#define LINK_START_DEFAULT_SPEC "%(link_start_openbsd)" + +#undef LINK_OS_DEFAULT_SPEC +#define LINK_OS_DEFAULT_SPEC "%(link_os_openbsd)" + +/************************[ Target stuff ]***********************************/ + +/* Define the actual types of some ANSI-mandated types. + Needs to agree with . GCC defaults come from c-decl.c, + c-common.c, and config//.h. */ + + +#undef SIZE_TYPE +#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int") + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") + +/* This must agree with */ +#undef SIZE_TYPE +#define SIZE_TYPE "long unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "long int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 32 + +/* Override rs6000.h definition. */ +#undef ASM_APP_ON +#define ASM_APP_ON "#APP\n" + +/* Override rs6000.h definition. */ +#undef ASM_APP_OFF +#define ASM_APP_OFF "#NO_APP\n" + +/* Function profiling bits */ +#undef RS6000_MCOUNT +#define RS6000_MCOUNT "_mcount" + +#define PROFILE_HOOK(LABEL) \ + do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0) + +/* _init and _fini functions are built from bits spread across many + object files, each potentially with a different TOC pointer. For + that reason, place a nop after the call so that the linker can + restore the TOC pointer if a TOC adjusting call stub is needed. */ +#ifdef __powerpc64__ +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ + asm (SECTION_OP "\n" \ +" bl " #FUNC "\n" \ +" nop\n" \ +" .previous"); +#endif + +/* FP save and restore routines. */ +#undef SAVE_FP_PREFIX +#define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_") +#undef SAVE_FP_SUFFIX +#define SAVE_FP_SUFFIX "" +#undef RESTORE_FP_PREFIX +#define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_") +#undef RESTORE_FP_SUFFIX +#define RESTORE_FP_SUFFIX "" + +/* Select a format to encode pointers in exception handling data. CODE + is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is + true if the symbol may be affected by dynamic relocations. */ +#undef ASM_PREFERRED_EH_DATA_FORMAT +#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ + (TARGET_64BIT || flag_pic \ + ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \ + | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \ + : DW_EH_PE_absptr) + +/* Static stack checking is supported by means of probes. */ +#define STACK_CHECK_STATIC_BUILTIN 1 + +/* The default value isn't sufficient in 64-bit mode. */ +#define STACK_CHECK_PROTECT (TARGET_64BIT ? 16 * 1024 : 12 * 1024) + +/* Use standard DWARF numbering for DWARF debugging information. */ +#define RS6000_USE_DWARF_NUMBERING + +/* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */ +#undef ADJUST_FIELD_ALIGN +#define ADJUST_FIELD_ALIGN(FIELD, TYPE, COMPUTED) \ + (rs6000_special_adjust_field_align_p ((TYPE), (COMPUTED)) \ + ? 128 \ + : (TARGET_64BIT \ + && TARGET_ALIGN_NATURAL == 0 \ + && TYPE_MODE (strip_array_types (TYPE)) == DFmode) \ + ? MIN ((COMPUTED), 32) \ + : (COMPUTED)) + +#undef TOC_SECTION_ASM_OP +#define TOC_SECTION_ASM_OP \ + (TARGET_64BIT \ + ? "\t.section\t\".toc\",\"aw\"" \ + : "\t.section\t\".got\",\"aw\"") + +#undef MINIMAL_TOC_SECTION_ASM_OP +#define MINIMAL_TOC_SECTION_ASM_OP \ + (TARGET_64BIT \ + ? "\t.section\t\".toc1\",\"aw\"" \ + : (flag_pic \ + ? "\t.section\t\".got2\",\"aw\"" \ + : "\t.section\t\".got1\",\"aw\"")) + +/* This is how to declare the size of a function. */ +#undef ASM_DECLARE_FUNCTION_SIZE +#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ + do \ + { \ + if (!flag_inhibit_size_directive) \ + { \ + fputs ("\t.size\t", (FILE)); \ + if (TARGET_64BIT && DOT_SYMBOLS) \ + putc ('.', (FILE)); \ + assemble_name ((FILE), (FNAME)); \ + fputs (",.-", (FILE)); \ + rs6000_output_function_entry (FILE, FNAME); \ + putc ('\n', (FILE)); \ + } \ + } \ + while (0) + +#undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P +#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \ + (TARGET_TOC \ + && (GET_CODE (X) == SYMBOL_REF \ + || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ + && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \ + || GET_CODE (X) == LABEL_REF \ + || (GET_CODE (X) == CONST_INT \ + && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \ + || (GET_CODE (X) == CONST_DOUBLE \ + && ((TARGET_64BIT \ + && (TARGET_MINIMAL_TOC \ + || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \ + && ! TARGET_NO_FP_IN_TOC))) \ + || (!TARGET_64BIT \ + && !TARGET_NO_FP_IN_TOC \ + && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \ + && BITS_PER_WORD == HOST_BITS_PER_INT))))) + +/* Use --as-needed -lgcc_s for eh support. */ +#ifdef HAVE_LD_AS_NEEDED +#define USE_LD_AS_NEEDED 1 +#endif Index: gcc/config/rs6000/openbsd.h --- gcc/config/rs6000/openbsd.h.orig +++ gcc/config/rs6000/openbsd.h @@ -0,0 +1,132 @@ +/* Configuration file for an rs6000 OpenBSD target. + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* XXX need to check ASM_WEAKEN_LABEL/ASM_GLOBALIZE_LABEL. */ + +/* Run-time target specifications. */ +#undef TARGET_OS_CPP_BUILTINS /* FIXME: sysv4.h should not define this! */ +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + OPENBSD_OS_CPP_BUILTINS_ELF(); \ + builtin_define ("__PPC"); \ + builtin_define ("__PPC__"); \ + builtin_define ("__powerpc"); \ + builtin_define ("__powerpc__"); \ + builtin_assert ("cpu=powerpc"); \ + builtin_assert ("machine=powerpc"); \ + } \ + while (0) + +/* Override the default from rs6000.h to avoid conflicts with macros + defined in OpenBSD header files. */ + +#undef RS6000_CPU_CPP_ENDIAN_BUILTINS +#define RS6000_CPU_CPP_ENDIAN_BUILTINS() \ + do \ + { \ + if (BYTES_BIG_ENDIAN) \ + { \ + builtin_define ("__BIG_ENDIAN__"); \ + builtin_assert ("machine=bigendian"); \ + } \ + else \ + { \ + builtin_define ("__LITTLE_ENDIAN__"); \ + builtin_assert ("machine=littleendian"); \ + } \ + } \ + while (0) + +#undef CPP_OS_DEFAULT_SPEC +#define CPP_OS_DEFAULT_SPEC "%(cpp_os_openbsd)" + +#undef LINK_SPEC +#define LINK_SPEC \ + "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \ + %{shared:-shared} %{R*} \ + %{static:-Bstatic} \ + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ + %{!static:-dynamic-linker /usr/libexec/ld.so} \ + %{!nostdlib:-L/usr/lib}" + +#undef LIB_DEFAULT_SPEC +#define LIB_DEFAULT_SPEC "%(lib_openbsd)" + +#undef STARTFILE_DEFAULT_SPEC +#define STARTFILE_DEFAULT_SPEC "%(startfile_openbsd)" + +#undef CRTSAVRES_DEFAULT_SPEC +#define CRTSAVRES_DEFAULT_SPEC "" + +#undef ENDFILE_DEFAULT_SPEC +#define ENDFILE_DEFAULT_SPEC "%(endfile_openbsd)" + +#undef LINK_START_DEFAULT_SPEC +#define LINK_START_DEFAULT_SPEC "%(link_start_openbsd)" + +#undef LINK_OS_DEFAULT_SPEC +#define LINK_OS_DEFAULT_SPEC "%(link_os_openbsd)" + +/* Default ABI to use */ +#undef RS6000_ABI_NAME +#define RS6000_ABI_NAME "openbsd" + +/* Define this macro as a C expression for the initializer of an + array of string to tell the driver program which options are + defaults for this target and thus do not need to be handled + specially when using `MULTILIB_OPTIONS'. + + Do not define this macro if `MULTILIB_OPTIONS' is not defined in + the target makefile fragment or if none of the options listed in + `MULTILIB_OPTIONS' are set by default. *Note Target Fragment::. */ + +#undef MULTILIB_DEFAULTS +#define MULTILIB_DEFAULTS { "mbig", "mcall-openbsd" } + +/* collect2 support (Macros for initialization). */ + + +/* Don't tell collect2 we use COFF as we don't have (yet ?) a dynamic ld + library with the proper functions to handle this -> collect2 will + default to using nm. */ +#undef OBJECT_FORMAT_COFF + +/* Some code gets optimized incorrectly by move_movables() in loop.c */ +#define BROKEN_MOVE_MOVABLES_P + +/* This must agree with */ +#undef SIZE_TYPE +#define SIZE_TYPE "long unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "long int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 32 + +#undef TRAMPOLINE_SIZE +#define TRAMPOLINE_SIZE 40 + Index: gcc/config/rs6000/sysv4.h --- gcc/config/rs6000/sysv4.h.orig +++ gcc/config/rs6000/sysv4.h @@ -93,7 +93,8 @@ do { \ else if (!strcmp (rs6000_abi_name, "aixdesc")) \ rs6000_current_abi = ABI_AIX; \ else if (!strcmp (rs6000_abi_name, "freebsd") \ - || !strcmp (rs6000_abi_name, "linux")) \ + || !strcmp (rs6000_abi_name, "linux") \ + || !strcmp (rs6000_abi_name, "openbsd")) \ { \ if (TARGET_64BIT) \ rs6000_current_abi = ABI_AIX; \ @@ -102,8 +103,6 @@ do { \ } \ else if (!strcmp (rs6000_abi_name, "netbsd")) \ rs6000_current_abi = ABI_V4; \ - else if (!strcmp (rs6000_abi_name, "openbsd")) \ - rs6000_current_abi = ABI_V4; \ else if (!strcmp (rs6000_abi_name, "i960-old")) \ { \ rs6000_current_abi = ABI_V4; \ @@ -413,6 +412,7 @@ do { \ asm_fprintf (FILE, "%L%s", PREFIX) /* Globalizing directive for a label. */ +#undef GLOBAL_ASM_OP #define GLOBAL_ASM_OP "\t.globl " /* This says how to output assembler code to declare an @@ -821,13 +821,14 @@ ncrtn.o%s" /* OpenBSD support. */ #ifndef LIB_OPENBSD_SPEC -#define LIB_OPENBSD_SPEC "%{!shared:%{pthread:-lpthread%{p:_p}%{!p:%{pg:_p}}}} %{!shared:-lc%{p:_p}%{!p:%{pg:_p}}}" +#define LIB_OPENBSD_SPEC OBSD_LIB_SPEC #endif #ifndef STARTFILE_OPENBSD_SPEC #define STARTFILE_OPENBSD_SPEC "\ -%{!shared: %{pg:gcrt0.o%s} %{!pg:%{p:gcrt0.o%s} %{!p:crt0.o%s}}} \ -%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" +%{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} \ +%{!p:%{!static:crt0%O%s} %{static:%{nopie:crt0%O%s} %{!nopie:rcrt0%O%s}}}} \ +crtbegin%O%s} %{shared:crtbeginS%O%s}" #endif #ifndef ENDFILE_OPENBSD_SPEC @@ -844,7 +845,7 @@ ncrtn.o%s" #endif #ifndef CPP_OS_OPENBSD_SPEC -#define CPP_OS_OPENBSD_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}" +#define CPP_OS_OPENBSD_SPEC OBSD_CPP_SPEC #endif /* Define any extra SPECS that the compiler needs to generate. */ --- gcc/config/rs6000/t-openbsd.orig Mon Nov 14 12:16:44 2011 +++ gcc/config/rs6000/t-openbsd Mon Nov 14 13:23:24 2011 @@ -0,0 +1,48 @@ +# include t-rs6000 too +# this is taken from t-ppccomm +# but crt* removed. + + +LIB2FUNCS_EXTRA = tramp.S + +# This one can't end up in shared libgcc +LIB2FUNCS_STATIC_EXTRA = eabi.S + +# We want fine grained libraries, so use the new code to build the +# floating point emulation libraries. +FPBIT = fp-bit.c +DPBIT = dp-bit.c + + +dp-bit.c: $(srcdir)/config/fp-bit.c + cat $(srcdir)/config/fp-bit.c > dp-bit.c + +fp-bit.c: $(srcdir)/config/fp-bit.c + echo '#define FLOAT' > fp-bit.c + cat $(srcdir)/config/fp-bit.c >> fp-bit.c + +eabi.S: $(srcdir)/config/rs6000/eabi.asm + cat $(srcdir)/config/rs6000/eabi.asm > eabi.S + +tramp.S: $(srcdir)/config/rs6000/tramp.asm + cat $(srcdir)/config/rs6000/tramp.asm > tramp.S + +# Switch synonyms +MULTILIB_MATCHES_FLOAT = msoft-float=mcpu?401 \ + msoft-float=mcpu?403 \ + msoft-float=mcpu?ec603e \ + msoft-float=mcpu?801 \ + msoft-float=mcpu?821 \ + msoft-float=mcpu?823 \ + msoft-float=mcpu?860 +MULTILIB_MATCHES_ENDIAN = mlittle=mlittle-endian mbig=mbig-endian +MULTILIB_MATCHES_SYSV = mcall-sysv=mcall-sysv-eabi mcall-sysv=mcall-sysv-noeabi mcall-sysv=mcall-linux mcall-sysv=mcall-netbsd + +LIBGCC = stmp-multilib +INSTALL_LIBGCC = install-multilib + +# It is important that crtbegin.o, etc., aren't surprised by stuff in .sdata. +CRTSTUFF_T_CFLAGS = -msdata=none +# Make sure crt*.o are built with -fPIC even if configured with +# --enable-shared --disable-multilib +CRTSTUFF_T_CFLAGS_S = -fPIC -msdata=none Index: gcc/config/sparc/openbsd64.h --- gcc/config/sparc/openbsd64.h.orig +++ gcc/config/sparc/openbsd64.h @@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see /* XXX - do we really want HARD_QUAD? */ #undef TARGET_DEFAULT #define TARGET_DEFAULT \ -(MASK_V9 + MASK_PTR64 + MASK_64BIT + MASK_HARD_QUAD \ +(MASK_V9 + MASK_PTR64 + MASK_64BIT + /* MASK_HARD_QUAD */ \ + MASK_APP_REGS + MASK_FPU + MASK_STACK_BIAS + MASK_LONG_DOUBLE_128) #undef SPARC_DEFAULT_CMODEL @@ -30,10 +30,7 @@ along with GCC; see the file COPYING3. If not see #define TARGET_OS_CPP_BUILTINS() \ do \ { \ - builtin_define ("__unix__"); \ - builtin_define ("__OpenBSD__"); \ - builtin_assert ("system=unix"); \ - builtin_assert ("system=OpenBSD"); \ + OPENBSD_OS_CPP_BUILTINS(); \ builtin_define ("__sparc64__"); \ builtin_define ("__sparcv9__"); \ builtin_define ("__sparc_v9__"); \ @@ -42,10 +39,17 @@ along with GCC; see the file COPYING3. If not see while (0) #undef ASM_SPEC +#ifdef PIE_DEFAULT #define ASM_SPEC "\ +-s %{fpic|fPIC:-K PIC} %{!fno-pie: %{!p: %{!pg: -K PIC}}} \ +%(asm_cpu) %(asm_arch) \ +" +#else +#define ASM_SPEC "\ -s %{" FPIE_OR_FPIC_SPEC ":-K PIC} \ %(asm_cpu) %(asm_arch) \ " +#endif /* Layout of source language data types. */ #undef WCHAR_TYPE @@ -54,6 +58,15 @@ along with GCC; see the file COPYING3. If not see #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE 32 +#undef WINT_TYPE +#define WINT_TYPE "int" + +#undef INTMAX_TYPE +#define INTMAX_TYPE "long long int" + +#undef UINTMAX_TYPE +#define UINTMAX_TYPE "long long unsigned int" + #undef LONG_DOUBLE_TYPE_SIZE #define LONG_DOUBLE_TYPE_SIZE 128 @@ -63,13 +76,15 @@ along with GCC; see the file COPYING3. If not see %{shared:-shared} %{R*} \ %{static:-Bstatic} \ %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ %{assert*} \ - -dynamic-linker /usr/libexec/ld.so" + %{!static:-dynamic-linker /usr/libexec/ld.so}" /* As an elf system, we need crtbegin/crtend stuff. */ #undef STARTFILE_SPEC #define STARTFILE_SPEC "\ - %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} %{!p:crt0%O%s}} \ - crtbegin%O%s} %{shared:crtbeginS%O%s}" + %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} \ + %{!p:%{!static:crt0%O%s} %{static:%{nopie:crt0%O%s} \ + %{!nopie:rcrt0%O%s}}}} crtbegin%O%s} %{shared:crtbeginS%O%s}" #undef ENDFILE_SPEC #define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}" Index: gcc/config/sparc/sparc.c --- gcc/config/sparc/sparc.c.orig +++ gcc/config/sparc/sparc.c @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see #include "varasm.h" #include "output.h" #include "insn-attr.h" +#include "flags.h" #include "explow.h" #include "expr.h" #include "debug.h" @@ -6074,8 +6075,8 @@ sparc_expand_prologue (void) at the end of the function prologue, and moving instructions that access the stack via the frame pointer between the instructions that decrement the stack pointer could result in accessing the - register window save area, which is volatile. */ - emit_insn (gen_frame_blockage ()); + register window save area, which is volatile. */ + emit_insn (gen_frame_blockage ()); } else { @@ -6101,6 +6102,9 @@ sparc_expand_prologue (void) sparc_frame_base_offset - sparc_apparent_frame_size, SORR_SAVE); + + if (warn_stack_larger_than && size > stack_larger_than_size) + warning (OPT_Wstack_larger_than_, "stack usage is %lld bytes", size); /* Advertise that the data calculated just above are now valid. */ sparc_prologue_data_valid_p = true; Make sure to include standard headers that are tightly bound to the compiler, such as stdatomic.h Index: gcc/config/t-openbsd --- gcc/config/t-openbsd.orig +++ gcc/config/t-openbsd @@ -1,2 +1,6 @@ # We don't need GCC's own include files. -USER_H = $(EXTRA_HEADERS) +USER_H = $(srcdir)/ginclude/stdfix.h \ + $(srcdir)/ginclude/stdnoreturn.h \ + $(srcdir)/ginclude/stdalign.h \ + $(srcdir)/ginclude/stdatomic.h \ + $(EXTRA_HEADERS) Index: gcc/configure --- gcc/configure.orig +++ gcc/configure @@ -18077,7 +18077,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in @@ -21737,7 +21737,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in @@ -28908,7 +28908,7 @@ $as_echo "#define HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE 1" esac case "$target:$tm_file" in - powerpc64-*-freebsd* | powerpc64*-*-linux* | powerpc*-*-linux*rs6000/biarch64.h*) + powerpc64-*-freebsd* | powerpc64*-*-linux* | powerpc*-*-linux*rs6000/biarch64.h* | powerpc64*-openbsd*) case "$target" in *le-*-linux*) emul_name="-melf64lppc" @@ -28919,6 +28919,10 @@ case "$target:$tm_file" in *-*-freebsd*) emul_name="-melf64ppc_fbsd" ;; + *-*-openbsd*) + gcc_cv_ld_no_dot_syms=yes + gcc_cv_ld_large_toc=yes + ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker support for omitting dot symbols" >&5 $as_echo_n "checking linker support for omitting dot symbols... " >&6; } @@ -29286,6 +29290,7 @@ else fi ;; + *-*-openbsd*) gcc_cv_libc_provides_ssp=yes ;; *) gcc_cv_libc_provides_ssp=no ;; esac fi @@ -29306,6 +29311,7 @@ if test "${enable_default_ssp+set}" = set; then : if test x$gcc_cv_libc_provides_ssp = xyes; then case "$target" in ia64*-*-*) enable_default_ssp=no ;; + hppa*-*-*) enable_default_ssp=no ;; *) enable_default_ssp=$enableval ;; esac else Backport https://gcc.gnu.org/cgit/gcc/commit/?id=2801a49d1144bce5568b527d1972952ad3420f66 Index: gcc/cp/call.c --- gcc/cp/call.c.orig +++ gcc/cp/call.c @@ -11447,7 +11447,9 @@ set_up_extended_ref_temp (tree decl, tree expr, vecx_flag_pic = 0; if (opts->x_flag_pic && !opts->x_flag_pie) opts->x_flag_shlib = 1; + if (opts->x_profile_flag) + opts->x_flag_pie = 0; opts->x_flag_opts_finished = true; } @@ -2342,6 +2347,11 @@ common_handle_option (struct gcc_options *opts, case OPT_Wfatal_errors: dc->fatal_errors = value; break; + + case OPT_Wstack_larger_than_: + stack_larger_than_size = value; + warn_stack_larger_than = stack_larger_than_size != -1; + break; case OPT_Wstack_usage_: opts->x_flag_stack_usage_info = value != -1; Fix build with libc++19 https://gcc.gnu.org/cgit/gcc/patch/?id=a995fded34fe488153b06bb41e026277f01efded Index: gcc/system.h --- gcc/system.h.orig +++ gcc/system.h @@ -194,29 +194,10 @@ extern int fprintf_unlocked (FILE *, const char *, ... #undef fread_unlocked #undef fwrite_unlocked -/* Include before "safe-ctype.h" to avoid GCC poisoning - the ctype macros through safe-ctype.h */ +/* Include C++ standard headers before "safe-ctype.h" to avoid GCC + poisoning the ctype macros through safe-ctype.h */ #ifdef __cplusplus -#ifdef INCLUDE_STRING -# include -#endif -#endif - -/* There are an extraordinary number of issues with . - The last straw is that it varies with the locale. Use libiberty's - replacement instead. */ -#include "safe-ctype.h" - -#include - -#include - -#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO -extern int errno; -#endif - -#ifdef __cplusplus #if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY) # include #endif @@ -229,12 +210,28 @@ extern int errno; #ifdef INCLUDE_SET # include #endif +#ifdef INCLUDE_STRING +# include +#endif #ifdef INCLUDE_VECTOR # include #endif # include # include # include +#endif + +/* There are an extraordinary number of issues with . + The last straw is that it varies with the locale. Use libiberty's + replacement instead. */ +#include "safe-ctype.h" + +#include + +#include + +#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO +extern int errno; #endif /* Some of glibc's string inlines cause warnings. Plus we'd rather Index: gcc/targhooks.c --- gcc/targhooks.c.orig +++ gcc/targhooks.c @@ -64,6 +64,7 @@ along with GCC; see the file COPYING3. If not see #include "optabs.h" #include "regs.h" #include "recog.h" +#include "c-family/c-common.h" #include "diagnostic-core.h" #include "fold-const.h" #include "stor-layout.h" @@ -874,7 +875,7 @@ default_stack_protect_guard (void) rtx x; t = build_decl (UNKNOWN_LOCATION, - VAR_DECL, get_identifier ("__stack_chk_guard"), + VAR_DECL, get_identifier ("__guard_local"), ptr_type_node); TREE_STATIC (t) = 1; TREE_PUBLIC (t) = 1; @@ -883,6 +884,8 @@ default_stack_protect_guard (void) TREE_THIS_VOLATILE (t) = 1; DECL_ARTIFICIAL (t) = 1; DECL_IGNORED_P (t) = 1; + DECL_VISIBILITY (t) = VISIBILITY_HIDDEN; + DECL_VISIBILITY_SPECIFIED (t) = 1; /* Do not share RTL as the declaration is visible outside of current function. */ @@ -895,67 +898,72 @@ default_stack_protect_guard (void) return t; } -static GTY(()) tree stack_chk_fail_decl; +static GTY(()) int stack_protect_labelno; tree default_external_stack_protect_fail (void) { - tree t = stack_chk_fail_decl; + tree t, func, type, init, stack_smash_handler; + const char *tmp_name; + char *name; + size_t length; + char name_buf[32]; - if (t == NULL_TREE) - { - t = build_function_type_list (void_type_node, NULL_TREE); - t = build_decl (UNKNOWN_LOCATION, - FUNCTION_DECL, get_identifier ("__stack_chk_fail"), t); - TREE_STATIC (t) = 1; - TREE_PUBLIC (t) = 1; - DECL_EXTERNAL (t) = 1; - TREE_USED (t) = 1; - TREE_THIS_VOLATILE (t) = 1; - TREE_NOTHROW (t) = 1; - DECL_ARTIFICIAL (t) = 1; - DECL_IGNORED_P (t) = 1; - DECL_VISIBILITY (t) = VISIBILITY_DEFAULT; - DECL_VISIBILITY_SPECIFIED (t) = 1; + name = (char *)xmalloc(32); + if (NULL == (tmp_name = fname_as_string (0))) { + strlcpy (name, "*unknown*", 32); + } else { + strlcpy (name, tmp_name, 32); + } + + length = strlen (name); + /* Build a decl for __func__. */ + type = build_array_type (char_type_node, + build_index_type (size_int (length))); + type = build_qualified_type (type, TYPE_QUAL_CONST); - stack_chk_fail_decl = t; - } + init = build_string (length + 1, name); + free ((char *) name); + TREE_TYPE (init) = type; - return build_call_expr (t, 0); + func = build_decl (UNKNOWN_LOCATION, VAR_DECL, NULL_TREE, type); + TREE_STATIC (func) = 1; + TREE_READONLY (func) = 1; + DECL_ARTIFICIAL (func) = 1; + ASM_GENERATE_INTERNAL_LABEL (name_buf, "LSSH", stack_protect_labelno++); + DECL_NAME (func) = get_identifier (name_buf); + DECL_INITIAL (func) = init; + + assemble_variable (func, 0, 0, 0); + + /* Build a decl for __stack_smash_handler. */ + t = build_pointer_type (TREE_TYPE (func)); + t = build_function_type_list (void_type_node, t, NULL_TREE); + t = build_decl (UNKNOWN_LOCATION, + FUNCTION_DECL, get_identifier ("__stack_smash_handler"), t); + /* t = build_fn_decl ("__stack_smash_handler", t); */ + TREE_STATIC (t) = 1; + TREE_PUBLIC (t) = 1; + DECL_EXTERNAL (t) = 1; + TREE_USED (t) = 1; + TREE_THIS_VOLATILE (t) = 1; + TREE_NOTHROW (t) = 1; + DECL_ARTIFICIAL (t) = 1; + DECL_IGNORED_P (t) = 1; + DECL_VISIBILITY (t) = VISIBILITY_DEFAULT; + DECL_VISIBILITY_SPECIFIED (t) = 1; + + stack_smash_handler = t; + + /* Generate a call to __stack_smash_handler(__func__). */ + t = build_fold_addr_expr (func); + return build_call_expr (stack_smash_handler, 1, t); } tree default_hidden_stack_protect_fail (void) { -#ifndef HAVE_GAS_HIDDEN return default_external_stack_protect_fail (); -#else - tree t = stack_chk_fail_decl; - - if (!flag_pic) - return default_external_stack_protect_fail (); - - if (t == NULL_TREE) - { - t = build_function_type_list (void_type_node, NULL_TREE); - t = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, - get_identifier ("__stack_chk_fail_local"), t); - TREE_STATIC (t) = 1; - TREE_PUBLIC (t) = 1; - DECL_EXTERNAL (t) = 1; - TREE_USED (t) = 1; - TREE_THIS_VOLATILE (t) = 1; - TREE_NOTHROW (t) = 1; - DECL_ARTIFICIAL (t) = 1; - DECL_IGNORED_P (t) = 1; - DECL_VISIBILITY_SPECIFIED (t) = 1; - DECL_VISIBILITY (t) = VISIBILITY_HIDDEN; - - stack_chk_fail_decl = t; - } - - return build_call_expr (t, 0); -#endif } bool --- gcc/testsuite/gcc.dg/format/format.h.orig Sat Nov 12 13:49:12 2011 +++ gcc/testsuite/gcc.dg/format/format.h Sat Nov 12 13:49:42 2011 @@ -35,11 +35,13 @@ #include #include +#ifndef _WINT_T_DEFINED_ #ifndef _WINT_T #ifndef __WINT_TYPE__ #define __WINT_TYPE__ unsigned int #endif typedef __WINT_TYPE__ wint_t; +#endif #endif #ifdef _WIN64 Index: gnattools/configure --- gnattools/configure.orig +++ gnattools/configure @@ -2079,6 +2079,11 @@ case "${target}" in mlib-tgt-specific.adb /dev/null; then case $host_cpu in i*86 ) @@ -9735,7 +9735,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib: ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) + freebsd* | dragonfly* | openbsd*) archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes Index: libcc1/Makefile.in --- libcc1/Makefile.in.orig +++ libcc1/Makefile.in @@ -400,6 +400,8 @@ cc1libdir = $(libdir)/$(libsuffix) shared_source = callbacks.cc callbacks.hh connection.cc connection.hh \ marshall.cc marshall.hh rpc.hh status.hh +include $(top_srcdir)/../libversions + marshall_c_source = marshall-c.hh marshall_cxx_source = marshall-cp.hh libcc1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1plugin.sym @@ -409,6 +411,7 @@ libcc1plugin_la_LIBADD = $(libiberty) libcc1plugin_la_DEPENDENCIES = $(libiberty_dep) libcc1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(LIBcc1plugin_LTVERSION) \ $(CXXFLAGS) $(libcc1plugin_la_LDFLAGS) $(LTLDFLAGS) -o $@ libcp1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcp1plugin.sym @@ -418,6 +421,7 @@ libcp1plugin_la_LIBADD = $(libiberty) libcp1plugin_la_DEPENDENCIES = $(libiberty_dep) libcp1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(LIBcp1plugin_LTVERSION) \ $(CXXFLAGS) $(libcp1plugin_la_LDFLAGS) $(LTLDFLAGS) -o $@ LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) @@ -430,6 +434,7 @@ libcc1_la_LIBADD = $(libiberty) libcc1_la_DEPENDENCIES = $(libiberty_dep) libcc1_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(LIBcc1_LTVERSION) \ $(CXXFLAGS) $(libcc1_la_LDFLAGS) $(LTLDFLAGS) -o $@ all: cc1plugin-config.h Index: libffi/Makefile.in --- libffi/Makefile.in.orig +++ libffi/Makefile.in @@ -607,7 +607,8 @@ AM_CFLAGS = -Wall -g -fexceptions $(am__append_2) @LIBAT_BUILD_VERSIONED_SHLIB_FALSE@libffi_version_dep = @LIBAT_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map @LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map-sun -libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version` +include $(top_srcdir)/../libversions +libffi_version_info = $(LIBffi_LTVERSION) libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS) libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep) AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src @@ -1585,9 +1586,9 @@ installdirs-am: for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(pkgconfigdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive +install: +install-exec: +install-data: uninstall: uninstall-recursive install-am: all-am Index: libffi/include/Makefile.in --- libffi/include/Makefile.in.orig +++ libffi/include/Makefile.in @@ -494,7 +494,7 @@ info: info-am info-am: -install-data-am: install-toollibffiHEADERS +install-data-am: install-dvi: install-dvi-am --- libffi/src/closures.c.orig Mon Jan 12 17:19:59 2015 +++ libffi/src/closures.c Tue Aug 23 15:48:20 2016 @@ -525,6 +525,7 @@ dlmmap (void *start, size_t length, int prot, printf ("mapping in %zi\n", length); #endif +#if 0 if (execfd == -1 && is_emutramp_enabled ()) { ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset); @@ -543,6 +544,7 @@ dlmmap (void *start, size_t length, int prot, with ((prot & ~PROT_WRITE) | PROT_EXEC) and mremap with MREMAP_DUP and prot at this point. */ } +#endif if (execsize == 0 || execfd == -1) { Index: libgcc/Makefile.in --- libgcc/Makefile.in.orig +++ libgcc/Makefile.in @@ -412,7 +412,7 @@ ASM_HIDDEN_OP = @asm_hidden_op@ define gen-hide-list $(NM) -pg $< | \ - $(AWK) 'NF == 3 && $$2 !~ /^[UN]$$/ && $$3 !~ /.*_compat/ \ + $(AWK) 'NF == 3 && $$2 !~ /^[UNF]$$/ && $$3 !~ /.*_compat/ \ && $$3 !~ /.*@.*/ \ { print "\t$(ASM_HIDDEN_OP)", $$3 }' > $@T mv -f $@T $@ @@ -1167,11 +1167,11 @@ install-shared: install-leaf: $(install-shared) $(install-libunwind) $(mkinstalldirs) $(DESTDIR)$(inst_libdir) - $(INSTALL_DATA) libgcc.a $(DESTDIR)$(inst_libdir)/ + cp libgcc.a $(DESTDIR)$(inst_libdir)/ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc.a $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc.a ifeq ($(enable_gcov),yes) - $(INSTALL_DATA) libgcov.a $(DESTDIR)$(inst_libdir)/ + cp libgcov.a $(DESTDIR)$(inst_libdir)/ chmod 644 $(DESTDIR)$(inst_libdir)/libgcov.a $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a endif Index: libgcc/config.host --- libgcc/config.host.orig +++ libgcc/config.host @@ -359,6 +359,13 @@ aarch64*-*-freebsd*) tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" md_unwind_header=aarch64/freebsd-unwind.h ;; +aarch64-*-openbsd*) + extra_parts="$extra_parts crtfastmath.o" + tmake_file="${tmake_file} ${cpu_type}/t-aarch64" + tmake_file="${tmake_file} ${cpu_type}/t-lse" + tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" + md_unwind_header=aarch64/aarch64-unwind.h + ;; aarch64*-*-fuchsia*) tmake_file="${tmake_file} ${cpu_type}/t-aarch64" tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp" @@ -922,6 +929,12 @@ microblaze*-*-rtems*) ;; mips*-*-netbsd*) # NetBSD/mips, either endian. ;; +mips64-*-openbsd*) + set + ;; +mips64el-*-openbsd*) + set + ;; mips*-*-linux*) # Linux MIPS, either endian. extra_parts="$extra_parts crtfastmath.o" tmake_file="${tmake_file} t-crtfm" @@ -1104,6 +1117,9 @@ powerpc*-*-freebsd*) powerpc-*-netbsd*) tmake_file="$tmake_file rs6000/t-netbsd rs6000/t-crtstuff" ;; +powerpc*-*-openbsd*) + tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff rs6000/t-openbsd" + ;; powerpc-*-eabispe*) tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff t-crtstuff-pic t-fdpbit" extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o" @@ -1202,6 +1218,9 @@ riscv*-*-linux*) riscv*-*-freebsd*) tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address}" extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o" + ;; +riscv64-*-openbsd*) + tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address}" ;; riscv*-*-*) tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address}" Add crt* since some symbols are required by lang/php/7.3+ Index: libgcc/config/rs6000/t-openbsd --- libgcc/config/rs6000/t-openbsd.orig +++ libgcc/config/rs6000/t-openbsd @@ -0,0 +1,12 @@ +# already added in libgcc/config/rs6000/t-ppccomm +# LIB2ADD = $(srcdir)/config/rs6000/tramp.S + +LIB2ADD_ST += \ + $(srcdir)/config/rs6000/crtsavfpr.S \ + $(srcdir)/config/rs6000/crtresfpr.S \ + $(srcdir)/config/rs6000/crtsavgpr.S \ + $(srcdir)/config/rs6000/crtresgpr.S \ + $(srcdir)/config/rs6000/crtresxfpr.S \ + $(srcdir)/config/rs6000/crtresxgpr.S \ + $(srcdir)/config/rs6000/crtsavevr.S \ + $(srcdir)/config/rs6000/crtrestvr.S --- libgcc/config/t-hardfp.orig Mon Jan 4 15:30:50 2016 +++ libgcc/config/t-hardfp Tue Aug 23 15:48:20 2016 @@ -60,11 +60,11 @@ hardfp_func_list += $(foreach pair, $(hardfp_truncatio hardfp_func_list := $(filter-out $(hardfp_exclusions),$(hardfp_func_list)) # Regexp for matching a floating-point mode. -hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /\\|/g') +hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | gsed 's/ /\\|/g') # Regexp for matching the end of a function name, after the last # floating-point mode. -hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | sed 's/ /\\|/g') +hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | gsed 's/ /\\|/g') # Add -D options to define: # FUNC: the function name (e.g. __addsf3) @@ -73,7 +73,7 @@ hardfp_suffix_regexp := $(shell echo $(hardfp_int_mode # TYPE: the last floating-point mode (e.g. sf) hardfp_defines_for = \ $(shell echo $1 | \ - sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') + gsed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') hardfp-o = $(patsubst %,%$(objext),$(hardfp_func_list)) $(hardfp-o): %$(objext): $(srcdir)/config/hardfp.c Index: libgcc/libgcc2.c --- libgcc/libgcc2.c.orig +++ libgcc/libgcc2.c @@ -2223,6 +2223,7 @@ mprotect (char *addr, int len, int prot) #endif /* WINNT && ! __CYGWIN__ */ #ifdef TRANSFER_FROM_TRAMPOLINE +#include TRANSFER_FROM_TRAMPOLINE #endif #endif /* L_trampoline */ Index: libgcc/unwind-dw2.c --- libgcc/unwind-dw2.c.orig +++ libgcc/unwind-dw2.c @@ -216,6 +216,25 @@ _Unwind_IsExtendedContext (struct _Unwind_Context *con return (ASSUME_EXTENDED_UNWIND_CONTEXT || (context->flags & EXTENDED_CONTEXT_BIT)); } + +#ifdef __sparc64__ + +/* Figure out StackGhost cookie. */ +_Unwind_Word uw_get_wcookie(void); + +asm(".text\n" + "uw_get_wcookie:\n" + " add %o7, %g0, %g4\n" + " save %sp, -176, %sp\n" + " save %sp, -176, %sp\n" + " flushw\n" + " restore\n" + " ldx [%sp + 2047 + 120], %g5\n" + " xor %g4, %g5, %i0\n" + " ret\n" + " restore\n"); +#endif + /* Get the value of register REGNO as saved in CONTEXT. */ @@ -246,6 +265,13 @@ _Unwind_GetGR (struct _Unwind_Context *context, int re } #endif +#ifdef __sparc64__ + /* _Unwind_Word and _Unwind_Ptr are the same size on sparc64 */ + _Unwind_Word reg = * (_Unwind_Word *) val; + if (index == 15 || index == 31) + reg ^= uw_get_wcookie (); + return reg; +#else /* This will segfault if the register hasn't been saved. */ if (size == sizeof(_Unwind_Ptr)) return * (_Unwind_Ptr *) (_Unwind_Internal_Ptr) val; @@ -254,6 +280,7 @@ _Unwind_GetGR (struct _Unwind_Context *context, int re gcc_assert (size == sizeof(_Unwind_Word)); return * (_Unwind_Word *) (_Unwind_Internal_Ptr) val; } +#endif } static inline void * Index: libgfortran/Makefile.in --- libgfortran/Makefile.in.orig +++ libgfortran/Makefile.in @@ -727,7 +727,8 @@ LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool- toolexeclib_LTLIBRARIES = libgfortran.la toolexeclib_DATA = libgfortran.spec libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS) -libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ +include $(top_srcdir)/../libversions +libgfortran_la_LDFLAGS = $(LIBgfortran_LTVERSION) \ $(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \ $(HWCAP_LDFLAGS) \ -lm $(extra_ldflags_libgfortran) \ Index: libgo/Makefile.in --- libgo/Makefile.in.orig +++ libgo/Makefile.in @@ -983,7 +983,8 @@ GOCOMPILE = $(GOC) $(DEFAULT_INCLUDES) $(INCLUDES) $(A LTGOCOMPILE = $(LIBTOOL) --tag GO --mode=compile $(GOC) $(INCLUDES) \ $(AM_GOCFLAGS) $(GOCFLAGS) -GOLINK = $(LIBTOOL) --tag GO --mode-link $(GOC) \ +include $(top_srcdir)/../libversions +GOLINK = $(LIBTOOL) --tag GO --mode-link $(GOC) $(LIBgo_LTVERSION) \ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_GOCFLAGS) $(LTLDFLAGS) -o $@ Index: libgo/config/libtool.m4 --- libgo/config/libtool.m4.orig +++ libgo/config/libtool.m4 @@ -2546,7 +2546,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in Index: libgo/configure --- libgo/configure.orig +++ libgo/configure @@ -690,6 +690,8 @@ LIBGO_IS_IRIX_FALSE LIBGO_IS_IRIX_TRUE LIBGO_IS_FREEBSD_FALSE LIBGO_IS_FREEBSD_TRUE +LIBGO_IS_OPENBSD_FALSE +LIBGO_IS_OPENBSD_TRUE LIBGO_IS_DARWIN_FALSE LIBGO_IS_DARWIN_TRUE go_include @@ -10906,7 +10908,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in @@ -13833,6 +13835,10 @@ fi # architectures don't support it. FIXME: We should set a default # based on the host. +case ${host} in +powerpc*-*-*) with_libffi_default=no ;; +esac + # Check whether --with-libffi was given. if test "${with_libffi+set}" = set; then : withval=$with_libffi; : @@ -13891,6 +13897,7 @@ ALLGOOS="aix android darwin dragonfly freebsd hurd iri is_darwin=no is_freebsd=no +is_openbsd=no is_irix=no is_linux=no is_netbsd=no @@ -13904,6 +13911,7 @@ GOOS=unknown case ${host} in *-*-darwin*) is_darwin=yes; GOOS=darwin ;; *-*-freebsd*) is_freebsd=yes; GOOS=freebsd ;; + *-*-openbsd*) is_openbsd=yes; GOOS=openbsd ;; *-*-irix6*) is_irix=yes; GOOS=irix ;; *-*-linux*) is_linux=yes; GOOS=linux ;; *-*-netbsd*) is_netbsd=yes; GOOS=netbsd ;; @@ -13936,6 +13944,14 @@ fi else LIBGO_IS_IRIX_TRUE='#' LIBGO_IS_IRIX_FALSE= +fi + + if test $is_openbsd = yes; then + LIBGO_IS_OPENBSD_TRUE= + LIBGO_IS_OPENBSD_FALSE='#' +else + LIBGO_IS_OPENBSD_TRUE='#' + LIBGO_IS_OPENBSD_FALSE= fi if test $is_linux = yes; then Index: libgomp/configure --- libgomp/configure.orig +++ libgomp/configure @@ -10816,7 +10816,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in @@ -14455,7 +14455,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in Index: libiberty/cp-demangle.c --- libiberty/cp-demangle.c.orig +++ libiberty/cp-demangle.c @@ -4295,7 +4295,7 @@ static inline void d_append_num (struct d_print_info *dpi, int l) { char buf[25]; - sprintf (buf,"%d", l); + snprintf (buf, 25, "%d", l); d_append_string (dpi, buf); } @@ -6444,7 +6444,7 @@ __cxa_demangle (const char *mangled_name, char *output { if (strlen (demangled) < *length) { - strcpy (output_buffer, demangled); + strlcpy (output_buffer, demangled, *length); free (demangled); demangled = output_buffer; } Index: libitm/Makefile.in --- libitm/Makefile.in.orig +++ libitm/Makefile.in @@ -474,7 +474,8 @@ nodist_toolexeclib_HEADERS = libitm.spec @LIBITM_BUILD_VERSIONED_SHLIB_FALSE@libitm_version_dep = @LIBITM_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBITM_BUILD_VERSIONED_SHLIB_TRUE@libitm_version_dep = $(top_srcdir)/libitm.map @LIBITM_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBITM_BUILD_VERSIONED_SHLIB_TRUE@libitm_version_dep = libitm.map-sun -libitm_version_info = -version-info $(libtool_VERSION) +include $(top_srcdir)/../libversions +libitm_version_info = $(LIBitm_LTVERSION) # Force link with C, not C++. For now, while we're using C++ we don't # want or need libstdc++. --- libobjc/Makefile.in.orig Sun Feb 3 12:16:21 2013 +++ libobjc/Makefile.in Tue Mar 5 19:45:43 2013 @@ -259,18 +259,20 @@ install-html: install-pdf: install-info: +include $(top_srcdir)/../libversions + LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) libobjc$(libsuffix).la: $(OBJS) $(LIBTOOL_LINK) $(CC) -o $@ $(OBJS) \ -Wc,-shared-libgcc -rpath $(toolexeclibdir) \ - -version-info $(LIBOBJC_VERSION) $(extra_ldflags_libobjc) \ + $(LIBobjc_LTVERSION) $(extra_ldflags_libobjc) \ $(LTLDFLAGS) libobjc_gc$(libsuffix).la: $(OBJS_GC) $(LIBTOOL_LINK) $(CC) -o $@ $(OBJS_GC) $(OBJC_BOEHM_GC_LIBS) \ -Wc,-shared-libgcc -rpath $(toolexeclibdir) \ - -version-info $(LIBOBJC_GC_VERSION) $(extra_ldflags_libobjc) \ + $(LIBobjc_gc_LTVERSION) $(extra_ldflags_libobjc) \ $(LTLDFLAGS) info: Index: libobjc/configure --- libobjc/configure.orig +++ libobjc/configure @@ -10150,7 +10150,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in Index: libquadmath/Makefile.in --- libquadmath/Makefile.in.orig +++ libquadmath/Makefile.in @@ -449,6 +449,9 @@ toolexeclibdir = @toolexeclibdir@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ + +include $(top_srcdir)/../libversions + AUTOMAKE_OPTIONS = foreign info-in-builddir @BUILD_LIBQUADMATH_TRUE@ACLOCAL_AMFLAGS = -I .. -I ../config @BUILD_LIBQUADMATH_TRUE@AM_CPPFLAGS = -I $(top_srcdir)/../include @@ -462,7 +465,7 @@ AUTOMAKE_OPTIONS = foreign info-in-builddir @BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@version_dep = quadmath.map-sun @BUILD_LIBQUADMATH_TRUE@toolexeclib_LTLIBRARIES = libquadmath.la @BUILD_LIBQUADMATH_TRUE@libquadmath_la_LIBADD = -@BUILD_LIBQUADMATH_TRUE@libquadmath_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ +@BUILD_LIBQUADMATH_TRUE@libquadmath_la_LDFLAGS = $(LIBquadmath_LTVERSION) \ @BUILD_LIBQUADMATH_TRUE@ $(version_arg) $(lt_host_flags) -lm @BUILD_LIBQUADMATH_TRUE@libquadmath_la_DEPENDENCIES = $(version_dep) $(libquadmath_la_LIBADD) Index: libquadmath/configure --- libquadmath/configure.orig +++ libquadmath/configure @@ -10212,7 +10212,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in Index: libssp/Makefile.in --- libssp/Makefile.in.orig +++ libssp/Makefile.in @@ -373,9 +373,10 @@ libssp_la_SOURCES = \ strcat-chk.c strcpy-chk.c strncat-chk.c strncpy-chk.c \ vsnprintf-chk.c vsprintf-chk.c +include $(top_srcdir)/../libversions libssp_la_LIBADD = libssp_la_DEPENDENCIES = $(version_dep) $(libssp_la_LIBADD) -libssp_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ +libssp_la_LDFLAGS = $(LIBssp_LTVERSION) \ $(version_arg) $(lt_host_flags) libssp_nonshared_la_SOURCES = \ Index: libssp/configure --- libssp/configure.orig +++ libssp/configure @@ -10394,7 +10394,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in Index: libstdc++-v3/config/os/bsd/openbsd/ctype_base.h --- libstdc++-v3/config/os/bsd/openbsd/ctype_base.h.orig +++ libstdc++-v3/config/os/bsd/openbsd/ctype_base.h @@ -42,6 +42,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // on the mask type. Because of this, we don't use an enum. typedef char mask; +#ifdef _CTYPE_U + static const mask upper = _CTYPE_U; + static const mask lower = _CTYPE_L; + static const mask alpha = _CTYPE_U | _CTYPE_L; + static const mask digit = _CTYPE_N; + static const mask xdigit = _CTYPE_N | _CTYPE_X; + static const mask space = _CTYPE_S; + static const mask print = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N | _CTYPE_B; + static const mask graph = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N; + static const mask cntrl = _CTYPE_C; + static const mask punct = _CTYPE_P; + static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N; +# if __cplusplus >= 201103L + static const mask blank = space; +# endif +#else static const mask upper = _U; static const mask lower = _L; static const mask alpha = _U | _L; @@ -53,8 +69,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static const mask cntrl = _C; static const mask punct = _P; static const mask alnum = _U | _L | _N; -#if __cplusplus >= 201103L +# if __cplusplus >= 201103L static const mask blank = space; +# endif #endif }; *-openbsd* required for cross compiling libstdc++ Index: libstdc++-v3/configure --- libstdc++-v3/configure.orig +++ libstdc++-v3/configure @@ -11252,7 +11252,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in @@ -14936,7 +14936,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in Index: libstdc++-v3/libsupc++/Makefile.in --- libstdc++-v3/libsupc++/Makefile.in.orig +++ libstdc++-v3/libsupc++/Makefile.in @@ -478,7 +478,7 @@ AM_CPPFLAGS = $(GLIBCXX_INCLUDES) $(CPPFLAGS) # Need this library to both be part of libstdc++.a, and installed # separately too. # 1) separate libsupc++.la -toolexeclib_LTLIBRARIES = libsupc++.la +toolexeclib_LTLIBRARIES = libesupc++.la # 2) integrated libsupc++convenience.la that is to be a part of libstdc++.a noinst_LTLIBRARIES = libsupc++convenience.la @@ -730,7 +730,7 @@ clean-toolexeclibLTLIBRARIES: rm -f $${locs}; \ } -libsupc++.la: $(libsupc___la_OBJECTS) $(libsupc___la_DEPENDENCIES) $(EXTRA_libsupc___la_DEPENDENCIES) +libesupc++.la: $(libsupc___la_OBJECTS) $(libsupc___la_DEPENDENCIES) $(EXTRA_libsupc___la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(toolexeclibdir) $(libsupc___la_OBJECTS) $(libsupc___la_LIBADD) $(LIBS) libsupc++convenience.la: $(libsupc__convenience_la_OBJECTS) $(libsupc__convenience_la_DEPENDENCIES) $(EXTRA_libsupc__convenience_la_DEPENDENCIES) Index: libstdc++-v3/python/Makefile.in --- libstdc++-v3/python/Makefile.in.orig +++ libstdc++-v3/python/Makefile.in @@ -602,7 +602,7 @@ gdb.py: hook.in Makefile install-data-local: gdb.py @$(mkdir_p) $(DESTDIR)$(toolexeclibdir) @here=`pwd`; cd $(DESTDIR)$(toolexeclibdir); \ - for file in libstdc++.*; do \ + for file in libestdc++.*; do \ case $$file in \ *-gdb.py) ;; \ *.la) ;; \ Index: libstdc++-v3/src/Makefile.in --- libstdc++-v3/src/Makefile.in.orig +++ libstdc++-v3/src/Makefile.in @@ -457,13 +457,14 @@ CONFIG_CXXFLAGS = \ WARN_CXXFLAGS = \ $(WARN_FLAGS) $(WERROR_FLAG) -fdiagnostics-show-location=once +include $(top_srcdir)/../libversions # -I/-D flags to pass when compiling. AM_CPPFLAGS = $(GLIBCXX_INCLUDES) $(CPPFLAGS) @ENABLE_FILESYSTEM_TS_FALSE@filesystem_dir = @ENABLE_FILESYSTEM_TS_TRUE@filesystem_dir = filesystem SUBDIRS = c++98 c++11 c++17 $(filesystem_dir) -@VTV_CYGMIN_FALSE@toolexeclib_LTLIBRARIES = libstdc++.la +@VTV_CYGMIN_FALSE@toolexeclib_LTLIBRARIES = libestdc++.la # Cross compiler support. @VTV_CYGMIN_TRUE@toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la @@ -513,7 +514,7 @@ libstdc___la_DEPENDENCIES = \ $(top_builddir)/src/c++17/libc++17convenience.la libstdc___la_LDFLAGS = \ - -version-info $(libtool_VERSION) ${version_arg} -lm + $(LIBestdc++_LTVERSION) ${version_arg} -lm libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) @@ -693,7 +694,7 @@ clean-toolexeclibLTLIBRARIES: rm -f $${locs}; \ } -libstdc++.la: $(libstdc___la_OBJECTS) $(libstdc___la_DEPENDENCIES) $(EXTRA_libstdc___la_DEPENDENCIES) +libestdc++.la: $(libstdc___la_OBJECTS) $(libstdc___la_DEPENDENCIES) $(EXTRA_libstdc___la_DEPENDENCIES) $(AM_V_GEN)$(libstdc___la_LINK) $(am_libstdc___la_rpath) $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD) $(LIBS) libvtv.la: $(libvtv_la_OBJECTS) $(libvtv_la_DEPENDENCIES) $(EXTRA_libvtv_la_DEPENDENCIES) Silence this linker warning: /usr/local/lib/gcc/powerpc-unknown-openbsd6.4/6.4.0/../../../libestdc++.so.18.0: warning: sprintf() is often misused, please use snprintf() Index: libstdc++-v3/src/c++11/debug.cc --- libstdc++-v3/src/c++11/debug.cc.orig +++ libstdc++-v3/src/c++11/debug.cc @@ -685,7 +685,7 @@ namespace else if (__builtin_strcmp(name, "address") == 0) { char buf[64]; - int ret = __builtin_sprintf(buf, "%p", inst._M_address); + int ret = __builtin_snprintf(buf, sizeof buf, "%p", inst._M_address); print_word(ctx, buf, ret); } else @@ -740,7 +740,7 @@ namespace else if (__builtin_strcmp(name, "sequence") == 0) { assert(iterator._M_sequence); - int written = __builtin_sprintf(buf, "%p", iterator._M_sequence); + int written = __builtin_snprintf(buf, sizeof buf, "%p", iterator._M_sequence); print_word(ctx, buf, written); } else if (__builtin_strcmp(name, "seq_type") == 0) @@ -825,7 +825,7 @@ namespace } int written - = __builtin_sprintf(buf, "@ 0x%p {\n", inst._M_address); + = __builtin_snprintf(buf, sizeof buf, "@ 0x%p {\n", inst._M_address); print_word(ctx, buf, written); if (inst._M_type) @@ -881,7 +881,7 @@ namespace } int written - = __builtin_sprintf(buf, "@ 0x%p\n", ite._M_sequence); + = __builtin_snprintf(buf, sizeof buf, "@ 0x%p\n", ite._M_sequence); print_word(ctx, buf, written); } @@ -979,8 +979,8 @@ namespace if (param._M_kind == _Parameter::__integer) { int written - = __builtin_sprintf(buf, "%ld", - param._M_variant._M_integer._M_value); + = __builtin_snprintf(buf, sizeof buf, "%ld", + param._M_variant._M_integer._M_value); print_word(ctx, buf, written); } else if (param._M_kind == _Parameter::__string) @@ -1040,7 +1040,7 @@ namespace __gnu_debug if (_M_line > 0) { char buf[64]; - int written = __builtin_sprintf(buf, "%u:", _M_line); + int written = __builtin_snprintf(buf, sizeof buf, "%u:", _M_line); print_word(ctx, buf, written); go_to_next_line = true; } Index: libtool.m4 --- libtool.m4.orig +++ libtool.m4 @@ -2541,7 +2541,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in Index: ltmain.sh --- ltmain.sh.orig +++ ltmain.sh @@ -8268,7 +8268,7 @@ EOF *.la) func_basename "$deplib" name="$func_basename_result" - libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" newdependency_libs="$newdependency_libs $libdir/$name" Index: lto-plugin/Makefile.in --- lto-plugin/Makefile.in.orig +++ lto-plugin/Makefile.in @@ -346,11 +346,13 @@ AM_LIBTOOLFLAGS = --tag=disable-static libexecsub_LTLIBRARIES = liblto_plugin.la in_gcc_libs = $(foreach lib, $(libexecsub_LTLIBRARIES), $(gcc_build_dir)/$(lib)) liblto_plugin_la_SOURCES = lto-plugin.c +include $(top_srcdir)/../libversions # Note that we intentionally override the bindir supplied by ACX_LT_HOST_FLAGS. liblto_plugin_la_LDFLAGS = $(AM_LDFLAGS) $(lt_host_flags) -module \ -bindir $(libexecsubdir) $(if $(wildcard \ $(libiberty_noasan)),, $(if $(wildcard \ - $(libiberty_pic)),,-Wc,$(libiberty))) + $(libiberty_pic)),,-Wc,$(libiberty))) \ + $(LIBlto_plugin_LTVERSION) # Can be simplified when libiberty becomes a normal convenience library. libiberty = $(with_libiberty)/libiberty.a libiberty_noasan = $(with_libiberty)/noasan/libiberty.a @@ -682,7 +684,7 @@ $(in_gcc_libs) : $(gcc_build_dir)/%: % echo WARNING: $* is static, not copying to $@ >&2 ; \ else \ $(mkinstalldirs) $(gcc_build_dir) && \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $* `pwd`/$@ ; \ + cp $* `pwd`/$@ ; \ fi # Tell versions [3.59,3.63) of GNU make to not export all variables. Index: lto-plugin/configure --- lto-plugin/configure.orig +++ lto-plugin/configure @@ -11188,7 +11188,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in Index: zlib/configure --- zlib/configure.orig +++ zlib/configure @@ -10050,7 +10050,7 @@ openbsd*) *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in