diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 3d044e8..82523e1 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -40269,10 +40269,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, { case IX86_BUILTIN_CPU_INIT: { - /* Make it call __cpu_indicator_init in libgcc. */ + /* Make it call __cpu_indicator_init_local in libgcc.a. */ tree call_expr, fndecl, type; type = build_function_type_list (integer_type_node, NULL_TREE); - fndecl = build_fn_decl ("__cpu_indicator_init", type); + fndecl = build_fn_decl ("__cpu_indicator_init_local", type); call_expr = build_call_expr (fndecl, 0); return expand_expr (call_expr, target, mode, EXPAND_NORMAL); } diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h index a1f98d3..4f6b2dc 100644 --- a/gcc/config/i386/pmm_malloc.h +++ b/gcc/config/i386/pmm_malloc.h @@ -27,12 +27,13 @@ #include /* We can't depend on since the prototype of posix_memalign - may not be visible. */ + may not be visible and we can't pollute the namespace either. */ #ifndef __cplusplus -extern int posix_memalign (void **, size_t, size_t); +extern int _mm_posix_memalign (void **, size_t, size_t) #else -extern "C" int posix_memalign (void **, size_t, size_t) throw (); +extern "C" int _mm_posix_memalign (void **, size_t, size_t) throw () #endif +__asm__("posix_memalign"); static __inline void * _mm_malloc (size_t size, size_t alignment) @@ -42,7 +43,7 @@ _mm_malloc (size_t size, size_t alignment) return malloc (size); if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4)) alignment = sizeof (void *); - if (posix_memalign (&ptr, alignment, size) == 0) + if (_mm_posix_memalign (&ptr, alignment, size) == 0) return ptr; else return NULL; diff --git a/gcc/config/linux.c b/gcc/config/linux.c index 250296b..16c3768 100644 --- a/gcc/config/linux.c +++ b/gcc/config/linux.c @@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see bool linux_libc_has_function (enum function_class fn_class) { - if (OPTION_GLIBC) + if (OPTION_GLIBC || OPTION_MUSL) return true; if (OPTION_BIONIC) if (fn_class == function_c94 diff --git a/gcc/configure b/gcc/configure index 1c6e340..7e8b5d6 100755 --- a/gcc/configure +++ b/gcc/configure @@ -29390,6 +29390,33 @@ fi $as_echo "$gcc_cv_no_pie" >&6; } if test "$gcc_cv_no_pie" = "yes"; then NO_PIE_FLAG="-no-pie" +else + # Check if -nopie works. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -nopie option" >&5 +$as_echo_n "checking for -nopie option... " >&6; } +if test "${gcc_cv_nopie+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + saved_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -nopie" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int main(void) {return 0;} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + gcc_cv_nopie=yes +else + gcc_cv_nopie=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$saved_LDFLAGS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_nopie" >&5 +$as_echo "$gcc_cv_nopie" >&6; } + if test "$gcc_cv_nopie" = "yes"; then + NO_PIE_FLAG="-nopie" + fi fi diff --git a/gcc/configure.ac b/gcc/configure.ac index 6c1dcd9..0ca7647 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -6098,6 +6098,19 @@ AC_CACHE_CHECK([for -no-pie option], LDFLAGS="$saved_LDFLAGS"]) if test "$gcc_cv_no_pie" = "yes"; then NO_PIE_FLAG="-no-pie" +else + # Check if -nopie works. + AC_CACHE_CHECK([for -nopie option], + [gcc_cv_nopie], + [saved_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -nopie" + AC_LINK_IFELSE([int main(void) {return 0;}], + [gcc_cv_nopie=yes], + [gcc_cv_nopie=no]) + LDFLAGS="$saved_LDFLAGS"]) + if test "$gcc_cv_nopie" = "yes"; then + NO_PIE_FLAG="-nopie" + fi fi AC_SUBST([NO_PIE_FLAG]) diff --git a/gcc/gcc.c b/gcc/gcc.c index 1af5920..0208d61 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -860,7 +860,8 @@ proper position among the other output files. */ #ifndef LINK_SSP_SPEC #ifdef TARGET_LIBC_PROVIDES_SSP #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ - "|fstack-protector-strong|fstack-protector-explicit:}" + "|fstack-protector-strong|fstack-protector-explicit" \ + ":-lssp_nonshared}" #else #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ "|fstack-protector-strong|fstack-protector-explicit" \ diff --git a/libcilkrts/runtime/os-unix.c b/libcilkrts/runtime/os-unix.c index cb582dd..e43d7d5 100644 --- a/libcilkrts/runtime/os-unix.c +++ b/libcilkrts/runtime/os-unix.c @@ -51,6 +51,7 @@ #if defined __linux__ # include # include +# include #elif defined __APPLE__ # include // Uses sysconf(_SC_NPROCESSORS_ONLN) in verbose output @@ -400,28 +401,19 @@ COMMON_SYSDEP void __cilkrts_sleep(void) COMMON_SYSDEP void __cilkrts_yield(void) { -#if __APPLE__ || __FreeBSD__ || __VXWORKS__ - // On MacOS, call sched_yield to yield quantum. I'm not sure why we - // don't do this on Linux also. - sched_yield(); -#elif defined(__DragonFly__) - // On DragonFly BSD, call sched_yield to yield quantum. - sched_yield(); -#elif defined(__MIC__) +#if defined(__MIC__) // On MIC, pthread_yield() really trashes things. Arch's measurements // showed that calling _mm_delay_32() (or doing nothing) was a better // option. Delaying 1024 clock cycles is a reasonable compromise between // giving up the processor and latency starting up when work becomes // available _mm_delay_32(1024); -#elif defined(__ANDROID__) || (defined(__sun__) && defined(__svr4__)) - // On Android and Solaris, call sched_yield to yield quantum. I'm not - // sure why we don't do this on Linux also. - sched_yield(); -#else - // On Linux, call pthread_yield (which in turn will call sched_yield) - // to yield quantum. +#elif defined(__sun__) && !defined(__svr4__) + // On old SunOS call pthread_yield to yield a quantum. pthread_yield(); +#else + // On other platforms call sched_yield to yield a quantum. + sched_yield(); #endif } diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c index 8c2248d..6c82f15 100644 --- a/libgcc/config/i386/cpuinfo.c +++ b/libgcc/config/i386/cpuinfo.c @@ -485,7 +485,7 @@ __cpu_indicator_init (void) return 0; } -#if defined SHARED && defined USE_ELF_SYMVER -__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0"); -__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0"); +#ifndef SHARED +int __cpu_indicator_init_local (void) + __attribute__ ((weak, alias ("__cpu_indicator_init"))); #endif diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux index 11bb46e..4f47f7b 100644 --- a/libgcc/config/i386/t-linux +++ b/libgcc/config/i386/t-linux @@ -3,4 +3,4 @@ # t-slibgcc-elf-ver and t-linux SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver -HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER +HOST_LIBGCC2_CFLAGS += -mlong-double-80