[PATCH] Search target sysroot gcc version specific dirs with multilib.
From: Khem Raj We install the gcc libraries (such as crtbegin.p) into //5.2.0/ which is a default search path for GCC (aka multi_suffix in the code below). is 'machine' in gcc's terminology. We use these directories so that multiple gcc versions could in theory co-exist on target. We only want to build one gcc-cross-canadian per arch and have this work for all multilibs. can be handled by mapping the multilib to the one used by gcc-cross-canadian, e.g. mips64-polkmllib32-linux is symlinked to by mips64-poky-linux. The default gcc search path in the target sysroot for a "lib64" mutlilib is: /lib32/mips64-poky-linux/5.2.0/ /lib32/../lib64/ /usr/lib32/mips64-poky-linux/5.2.0/ /usr/lib32/../lib64/ /lib32/ /usr/lib32/ which means that the lib32 crtbegin.o will be found and the lib64 ones will not which leads to compiler failures. This patch injects a multilib version of that path first so the lib64 binaries can be found first. With this change the search path becomes: /lib32/../lib64/mips64-poky-linux/5.2.0/ /lib32/mips64-poky-linux/5.2.0/ /lib32/../lib64/ /usr/lib32/../lib64/mips64-poky-linux/5.2.0/ /usr/lib32/mips64-poky-linux/5.2.0/ /usr/lib32/../lib64/ /lib32/ /usr/lib32/ Signed-off-by: Khem Raj Signed-off-by: Yash Shinde --- gcc/gcc.cc | 29 - 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc/gcc.cc b/gcc/gcc.cc index 16bb07f2cdc..4e5e3079804 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -2801,7 +2801,7 @@ for_each_path (const struct path_prefix *paths, if (path == NULL) { len = paths->max_len + extra_space + 1; - len += MAX (MAX (suffix_len, multi_os_dir_len), multiarch_len); + len += MAX ((suffix_len + multi_os_dir_len), multiarch_len); path = XNEWVEC (char, len); } @@ -2813,6 +2813,33 @@ for_each_path (const struct path_prefix *paths, /* Look first in MACHINE/VERSION subdirectory. */ if (!skip_multi_dir) { + if (!(pl->os_multilib ? skip_multi_os_dir : skip_multi_dir)) + { +const char *this_multi; +size_t this_multi_len; + +if (pl->os_multilib) + { +this_multi = multi_os_dir; +this_multi_len = multi_os_dir_len; + } +else + { +this_multi = multi_dir; +this_multi_len = multi_dir_len; + } + +/* Look in multilib MACHINE/VERSION subdirectory first */ +if (this_multi_len) + { +memcpy (path + len, this_multi, this_multi_len + 1); +memcpy (path + len + this_multi_len, multi_suffix, suffix_len + 1); +ret = callback (path, callback_info); + if (ret) +break; + } + } + memcpy (path + len, multi_suffix, suffix_len + 1); ret = callback (path, callback_info); if (ret) -- 2.34.1
[PATCH] Add ssp_nonshared to link commandline for musl targets
From: Khem Raj When -fstack-protector options are enabled we need to link with ssp_shared on musl since it does not provide the __stack_chk_fail_local() so essentially it provides libssp but not libssp_nonshared something like TARGET_LIBC_PROVIDES_SSP_BUT_NOT_SSP_NONSHARED where-as for glibc the needed symbols are already present in libc_nonshared library therefore we do not need any library helper on glibc based systems but musl needs the libssp_noshared from gcc Signed-off-by: Khem Raj Signed-off-by: Yash Shinde --- gcc/config/linux.h | 7 +++ gcc/config/rs6000/linux.h | 10 ++ gcc/config/rs6000/linux64.h | 10 ++ 3 files changed, 27 insertions(+) --- gcc/config/linux.h | 7 +++ gcc/config/rs6000/linux.h | 10 ++ gcc/config/rs6000/linux64.h | 10 ++ 3 files changed, 27 insertions(+) diff --git a/gcc/config/linux.h b/gcc/config/linux.h index e3aca79..33f9265bb93 100644 --- a/gcc/config/linux.h +++ b/gcc/config/linux.h @@ -189,6 +189,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see } #endif +#ifdef TARGET_LIBC_PROVIDES_SSP +#undef LINK_SSP_SPEC +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit" \ + ":-lssp_nonshared}" +#endif + #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */ /* This is a *uclinux* target. We don't define below macros to normal linux versions, because doing so would require *uclinux* targets to include diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h index 5d21befe8e4..4fc17e781ba 100644 --- a/gcc/config/rs6000/linux.h +++ b/gcc/config/rs6000/linux.h @@ -99,6 +99,16 @@ " -m elf32ppclinux") #endif +/* link libssp_nonshared.a with musl */ +#if DEFAULT_LIBC == LIBC_MUSL +#ifdef TARGET_LIBC_PROVIDES_SSP +#undef LINK_SSP_SPEC +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit" \ + ":-lssp_nonshared}" +#endif +#endif + #undef LINK_OS_LINUX_SPEC #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \ %{!static-pie: \ diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 9e457033d11..49c9f6e2105 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -377,6 +377,16 @@ extern int dot_symbols; " -m elf64ppc") #endif +/* link libssp_nonshared.a with musl */ +#if DEFAULT_LIBC == LIBC_MUSL +#ifdef TARGET_LIBC_PROVIDES_SSP +#undef LINK_SSP_SPEC +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit" \ + ":-lssp_nonshared}" +#endif +#endif + #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \ %{!static-pie: \ %{rdynamic:-export-dynamic} \ -- 2.34.1
[PATCH] Pass CXXFLAGS_FOR_BUILD to avoid build failure errors.
From: Richard Purdie If CXXFLAGS contains something unsupported by the build CXX, we see build failures (e.g. using -fmacro-prefix-map for the target). ChangeLog: * Makefile.in: Regenerate. * Makefile.tpl: Add missing CXXFLAGS_FOR_BUILD overrides. Signed-off-by: Richard Purdie Signed-off-by: Yash Shinde --- Makefile.in | 2 ++ Makefile.tpl | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Makefile.in b/Makefile.in index 06a9398e172..4b0069b257c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -178,6 +178,7 @@ BUILD_EXPORTS = \ # built for the build system to override those in BASE_FLAGS_TO_PASS. EXTRA_BUILD_FLAGS = \ CFLAGS="$(CFLAGS_FOR_BUILD)" \ + CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ LDFLAGS="$(LDFLAGS_FOR_BUILD)" # This is the list of directories to built for the host system. @@ -210,6 +211,7 @@ HOST_EXPORTS = \ CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \ CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \ CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \ + CXXFLAGS_FOR_BUILD="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS_FOR_BUILD; \ DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \ DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \ LD="$(LD)"; export LD; \ diff --git a/Makefile.tpl b/Makefile.tpl index dfbd74b68f8..419b332953b 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -181,6 +181,7 @@ BUILD_EXPORTS = \ # built for the build system to override those in BASE_FLAGS_TO_PASS. EXTRA_BUILD_FLAGS = \ CFLAGS="$(CFLAGS_FOR_BUILD)" \ + CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ LDFLAGS="$(LDFLAGS_FOR_BUILD)" # This is the list of directories to built for the host system. @@ -213,6 +214,7 @@ HOST_EXPORTS = \ CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \ CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \ CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \ + CXXFLAGS_FOR_BUILD="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS_FOR_BUILD; \ DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \ DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \ LD="$(LD)"; export LD; \ -- 2.39.0
[PATCH] libgcc_s: Use alias for __cpu_indicator_init instead of symver
From: Khem Raj Adapter from https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00899.html This fix was debated but hasnt been applied gcc upstream since they expect musl to support '@' in symbol versioning which is a sun/gnu versioning extention. This patch however avoids the need for the '@' symbols at all libgcc/Changelog: 2015-05-11 Szabolcs Nagy * config/i386/cpuinfo.c (__cpu_indicator_init_local): Add. (__cpu_indicator_init@GCC_4.8.0, __cpu_model@GCC_4.8.0): Remove. * config/i386/t-linux (HOST_LIBGCC2_CFLAGS): Remove -DUSE_ELF_SYMVER. gcc/Changelog: 2015-05-11 Szabolcs Nagy * config/i386/i386-expand.c (ix86_expand_builtin): Make __builtin_cpu_init call __cpu_indicator_init_local instead of __cpu_indicator_init. Signed-off-by: Khem Raj Signed-off-by: Yash Shinde --- gcc/config/i386/i386-expand.cc | 4 ++-- libgcc/config/i386/cpuinfo.c | 6 +++--- libgcc/config/i386/t-linux | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 3eddbc94360..aee05e813cc 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -12647,10 +12647,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/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c index dab1d98060f..cf824b4114a 100644 --- a/libgcc/config/i386/cpuinfo.c +++ b/libgcc/config/i386/cpuinfo.c @@ -63,7 +63,7 @@ __cpu_indicator_init (void) __cpu_features2); } -#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 8506a635790..564296f788e 100644 --- a/libgcc/config/i386/t-linux +++ b/libgcc/config/i386/t-linux @@ -3,5 +3,5 @@ # 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 $(CET_FLAGS) +HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS) CRTSTUFF_T_CFLAGS += $(CET_FLAGS) -- 2.39.0
[PATCH] Share work directories
From: Khem Raj Fix configure and Makefile files to read the defaults.hand t-oe from build directory, so that the source can be shared between gcc-cross-initial, gcc-cross-intermediate, gcc-cross, gcc-runtime, and also the sdk build which use a separate build directory compared to source directory. While compiling gcc-crosssdk-initial-x86_64 on some host, there is occasionally failure that test the existance of default.h doesn't work, the reason is tm_include_list='** defaults.h' rather than tm_include_list='** ./defaults.h'. So we add the test condition for this situation. gcc/ChangeLog: * configure * configure.ac * mkconfig.sh Signed-off-by: Khem Raj Signed-off-by: Hongxu Jia --- gcc/configure| 4 ++-- gcc/configure.ac | 4 ++-- gcc/mkconfig.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/configure b/gcc/configure index 254f9b6c943..ff2a3e26049 100755 --- a/gcc/configure +++ b/gcc/configure @@ -13471,8 +13471,8 @@ for f in $tm_file; do tm_include_list="${tm_include_list} $f" ;; defaults.h ) - tm_file_list="${tm_file_list} \$(srcdir)/$f" - tm_include_list="${tm_include_list} $f" + tm_file_list="${tm_file_list} ./$f" + tm_include_list="${tm_include_list} ./$f" ;; * ) tm_file_list="${tm_file_list} \$(srcdir)/config/$f" diff --git a/gcc/configure.ac b/gcc/configure.ac index 62bc908b991..d36830cf2fb 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2336,8 +2336,8 @@ for f in $tm_file; do tm_include_list="${tm_include_list} $f" ;; defaults.h ) - tm_file_list="${tm_file_list} \$(srcdir)/$f" - tm_include_list="${tm_include_list} $f" + tm_file_list="${tm_file_list} ./$f" + tm_include_list="${tm_include_list} ./$f" ;; * ) tm_file_list="${tm_file_list} \$(srcdir)/config/$f" diff --git a/gcc/mkconfig.sh b/gcc/mkconfig.sh index 054ede89647..3b2c2b9df37 100644 --- a/gcc/mkconfig.sh +++ b/gcc/mkconfig.sh @@ -77,7 +77,7 @@ if [ -n "$HEADERS" ]; then if [ $# -ge 1 ]; then echo '#ifdef IN_GCC' >> ${output}T for file in "$@"; do - if test x"$file" = x"defaults.h"; then + if test x"$file" = x"./defaults.h" -o x"$file" = x"defaults.h"; then postpone_defaults_h="yes" else echo "# include \"$file\"" >> ${output}T @@ -106,7 +106,7 @@ esac # If we postponed including defaults.h, add the #include now. if test x"$postpone_defaults_h" = x"yes"; then -echo "# include \"defaults.h\"" >> ${output}T +echo "# include \"./defaults.h\"" >> ${output}T fi # Add multiple inclusion protection guard, part two. -- 2.39.0