--- gcc/genmatch.cc.orig +++ gcc/genmatch.cc @@ -39,6 +39,14 @@ { return NULL; } + +void * +ggc_internal_cleared_alloc_no_dtor (size_t, void (*)(void *), + size_t, size_t MEM_STAT_DECL) +{ + return NULL; +} + void ggc_free (void *) { } --- gcc/ggc-common.cc.orig +++ gcc/ggc-common.cc @@ -119,14 +119,24 @@ } /* Allocate a block of memory, then clear it. */ -void * -ggc_internal_cleared_alloc (size_t size, void (*f)(void *), size_t s, size_t n - MEM_STAT_DECL) +extern "C" void * +ggc_internal_cleared_alloc_ (size_t size, void (*f)(void *), size_t s, size_t n + MEM_STAT_DECL) { void *buf = ggc_internal_alloc (size, f, s, n PASS_MEM_STAT); memset (buf, 0, size); return buf; } + +extern void * +ggc_internal_cleared_alloc (size_t size, void (*f)(void *), size_t s, + size_t n MEM_STAT_DECL) + __attribute__((__alias__ ("ggc_internal_cleared_alloc_"))); + +extern void * +ggc_internal_cleared_alloc_no_dtor (size_t size, void (*f)(void *), + size_t s, size_t n MEM_STAT_DECL) + __attribute__((__alias__ ("ggc_internal_cleared_alloc_"))); /* Resize a block of memory, possibly re-allocating it. */ void * --- gcc/ggc-none.cc.orig +++ gcc/ggc-none.cc @@ -40,21 +40,38 @@ return requested_size; } -void * -ggc_internal_alloc (size_t size, void (*f)(void *), size_t, size_t - MEM_STAT_DECL) +extern "C" void * +ggc_internal_alloc__ (size_t size, void (*f)(void *), size_t, size_t + MEM_STAT_DECL) { gcc_assert (!f); // ggc-none doesn't support finalizers return xmalloc (size); } -void * -ggc_internal_cleared_alloc (size_t size, void (*f)(void *), size_t, size_t - MEM_STAT_DECL) +extern "C" void * +ggc_internal_cleared_alloc__ (size_t size, void (*f)(void *), size_t, size_t + MEM_STAT_DECL) { gcc_assert (!f); // ggc-none doesn't support finalizers return xcalloc (size, 1); } + +extern void * +ggc_internal_alloc (size_t size, void (*f)(void *), size_t s, + size_t n MEM_STAT_DECL) + __attribute__((__alias__ ("ggc_internal_alloc__"))); +extern void * +ggc_internal_alloc_no_dtor (size_t size, void (*f)(void *), size_t s, + size_t n MEM_STAT_DECL) + __attribute__((__alias__ ("ggc_internal_alloc__"))); +extern void * +ggc_internal_cleared_alloc (size_t size, void (*f)(void *), + size_t s, size_t n MEM_STAT_DECL) + __attribute__((__alias__ ("ggc_internal_cleared_alloc__"))); +extern void * +ggc_internal_cleared_alloc_no_dtor (size_t size, void (*f)(void *), + size_t s, size_t n MEM_STAT_DECL) + __attribute__((__alias__ ("ggc_internal_cleared_alloc__"))); void * ggc_realloc_stat (void *x, size_t size MEM_STAT_DECL) --- gcc/ggc-page.cc.orig +++ gcc/ggc-page.cc @@ -1273,9 +1273,9 @@ /* Allocate a chunk of memory of SIZE bytes. Its contents are undefined. */ -void * -ggc_internal_alloc (size_t size, void (*f)(void *), size_t s, size_t n - MEM_STAT_DECL) +extern "C" void * +ggc_internal_alloc___ (size_t size, void (*f)(void *), size_t s, size_t n + MEM_STAT_DECL) { size_t order, word, bit, object_offset, object_size; struct page_entry *entry; @@ -1457,6 +1457,15 @@ return result; } + +extern void * +ggc_internal_alloc (size_t size, void (*f)(void *), size_t s, + size_t n MEM_STAT_DECL) + __attribute__((__alias__ ("ggc_internal_alloc___"))); +extern void * +ggc_internal_alloc_no_dtor (size_t size, void (*f)(void *), size_t s, + size_t n MEM_STAT_DECL) + __attribute__((__alias__ ("ggc_internal_alloc___"))); /* Mark function for strings. */ --- gcc/ggc.h.orig +++ gcc/ggc.h @@ -127,13 +127,18 @@ /* The internal primitive. */ extern void *ggc_internal_alloc (size_t, void (*)(void *), size_t, - size_t CXX_MEM_STAT_INFO) + size_t CXX_MEM_STAT_INFO); +/* If the second argument is non-NULL, it can't be marked ATTRIBUTE_MALLOC, + because ggc_free performs finalization. Add an alias or wrapper used just + for the NULL finalizer which can be marked with ATTRIBUTE_MALLOC. */ +extern void *ggc_internal_alloc_no_dtor (size_t, void (*)(void *), size_t, + size_t CXX_MEM_STAT_INFO) ATTRIBUTE_MALLOC; inline void * ggc_internal_alloc (size_t s CXX_MEM_STAT_INFO) { - return ggc_internal_alloc (s, NULL, 0, 1 PASS_MEM_STAT); + return ggc_internal_alloc_no_dtor (s, NULL, 0, 1 PASS_MEM_STAT); } extern size_t ggc_round_alloc_size (size_t requested_size); @@ -141,12 +146,16 @@ /* Allocates cleared memory. */ extern void *ggc_internal_cleared_alloc (size_t, void (*)(void *), size_t, size_t - CXX_MEM_STAT_INFO) ATTRIBUTE_MALLOC; + CXX_MEM_STAT_INFO); +extern void *ggc_internal_cleared_alloc_no_dtor (size_t, void (*)(void *), + size_t, size_t + CXX_MEM_STAT_INFO) + ATTRIBUTE_MALLOC; inline void * ggc_internal_cleared_alloc (size_t s CXX_MEM_STAT_INFO) { - return ggc_internal_cleared_alloc (s, NULL, 0, 1 PASS_MEM_STAT); + return ggc_internal_cleared_alloc_no_dtor (s, NULL, 0, 1 PASS_MEM_STAT); } /* Resize a block. */ @@ -187,8 +196,8 @@ return static_cast (ggc_internal_alloc (sizeof (T), finalize, 0, 1 PASS_MEM_STAT)); else - return static_cast (ggc_internal_alloc (sizeof (T), NULL, 0, 1 - PASS_MEM_STAT)); + return static_cast (ggc_internal_alloc_no_dtor (sizeof (T), NULL, + 0, 1 PASS_MEM_STAT)); } /* GGC allocation function that does not call finalizer for type @@ -199,8 +208,8 @@ inline T * ggc_alloc_no_dtor (ALONE_CXX_MEM_STAT_INFO) { - return static_cast (ggc_internal_alloc (sizeof (T), NULL, 0, 1 - PASS_MEM_STAT)); + return static_cast (ggc_internal_alloc_no_dtor (sizeof (T), NULL, 0, 1 + PASS_MEM_STAT)); } template @@ -212,8 +221,9 @@ finalize, 0, 1 PASS_MEM_STAT)); else - return static_cast (ggc_internal_cleared_alloc (sizeof (T), NULL, 0, 1 - PASS_MEM_STAT)); + return static_cast (ggc_internal_cleared_alloc_no_dtor (sizeof (T), + NULL, 0, 1 + PASS_MEM_STAT)); } template @@ -224,8 +234,9 @@ return static_cast (ggc_internal_alloc (c * sizeof (T), finalize, sizeof (T), c PASS_MEM_STAT)); else - return static_cast (ggc_internal_alloc (c * sizeof (T), NULL, 0, 0 - PASS_MEM_STAT)); + return static_cast (ggc_internal_alloc_no_dtor (c * sizeof (T), + NULL, 0, 0 + PASS_MEM_STAT)); } template @@ -238,8 +249,10 @@ sizeof (T), c PASS_MEM_STAT)); else - return static_cast (ggc_internal_cleared_alloc (c * sizeof (T), NULL, - 0, 0 PASS_MEM_STAT)); + return static_cast (ggc_internal_cleared_alloc_no_dtor (c + * sizeof (T), + NULL, 0, 0 + PASS_MEM_STAT)); } inline void * --- gcc/config/darwin.h.orig +++ gcc/config/darwin.h @@ -264,8 +264,6 @@ "%{weak_reference_mismatches*:\ -Xlinker -weak_reference_mismatches -Xlinker %*} \ % /dev/null 2>&1; then + gcc_cv_target_dl_iterate_phdr=yes + else + gcc_cv_target_dl_iterate_phdr=no + fi + ;; *-linux-musl*) gcc_cv_target_dl_iterate_phdr=yes ;; --- gcc/gcc.cc.orig +++ gcc/gcc.cc @@ -1653,6 +1653,9 @@ static const char *const standard_startfile_prefix_2 = STANDARD_STARTFILE_PREFIX_2; +/* Since we hardset rpath to LOCALBASE, follow with library search path */ +static const char *const standard_raven_prefix = "@LOCALBASE@/lib/"; + /* A relative path to be used in finding the location of tools relative to the driver. */ static const char *const tooldir_base_prefix = TOOLDIR_BASE_PREFIX; @@ -5490,6 +5493,8 @@ #endif add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS", PREFIX_PRIORITY_LAST, 1, 0); + add_prefix (&startfile_prefixes, standard_raven_prefix, "BINUTILS", + PREFIX_PRIORITY_LAST, 0, 0); } gcc_assert (!IS_ABSOLUTE_PATH (tooldir_base_prefix)); @@ -8066,16 +8071,6 @@ *cp++ = '.'; *cp = '\0'; - /* Exclude directories that the linker is known to search. */ - if (linker - && IS_DIR_SEPARATOR (path[0]) - && ((cp - path == 6 - && filename_ncmp (path + 1, "lib", 3) == 0) - || (cp - path == 10 - && filename_ncmp (path + 1, "usr", 3) == 0 - && IS_DIR_SEPARATOR (path[4]) - && filename_ncmp (path + 5, "lib", 3) == 0))) - return 0; return (stat (path, &st) >= 0 && S_ISDIR (st.st_mode)); } --- libcc1/configure.orig +++ libcc1/configure @@ -9282,7 +9282,7 @@ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else - archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes --- libssp/ssp.c.orig +++ libssp/ssp.c @@ -131,7 +131,7 @@ progname_len = strlen (__progname); len = msg1len + progname_len + sizeof(msg2)-1 + 1; - p = buf = alloca (len); + p = buf = __builtin_alloca (len); memcpy (p, msg1, msg1len); p += msg1len;