[PATCH] Fix build issues for *-linux-android and add aarch64-linux-android support. [PR101785, PR99499]
I have add aarch64-linux-android target support and fix build issues with libstdc++ for android. Several small issues like no libpthread.a (since android does not need libpthread.a) + 'ifunc' is not supported on this target, i will leave other people to fix. --- gcc/config.gcc | 3 +- gcc/config/aarch64/aarch64-linux.h | 48 -- libstdc++-v3/config/os/bionic/ctype_base.h | 38 +++-- 3 files changed, 72 insertions(+), 17 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index 2c4266ce7b0..8d25868e1cd 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1129,10 +1129,11 @@ aarch64*-*-netbsd*) extra_options="${extra_options} netbsd.opt netbsd-elf.opt" ;; aarch64*-*-linux*) - tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h" + tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h" tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-linux.h" tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-linux" tm_defines="${tm_defines} TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1" + extra_options="${extra_options} linux-android.opt" case $target in aarch64_be-*) tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1" diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h index 5e4553d79f5..3e6b112ae95 100644 --- a/gcc/config/aarch64/aarch64-linux.h +++ b/gcc/config/aarch64/aarch64-linux.h @@ -26,6 +26,9 @@ #undef MUSL_DYNAMIC_LINKER #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" +#undef BIONIC_DYNAMIC_LINKER +#define BIONIC_DYNAMIC_LINKER "/system/bin/linker64" + #undef ASAN_CC1_SPEC #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}" @@ -46,11 +49,48 @@ %{mbig-endian:-EB} %{mlittle-endian:-EL} \ -maarch64linux%{mabi=ilp32:32}%{mbig-endian:b}" - -#define LINK_SPEC LINUX_TARGET_LINK_SPEC AARCH64_ERRATA_LINK_SPEC - #define GNU_USER_TARGET_MATHFILE_SPEC \ "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" + +#if defined(TARGET_ANDROID) + +#define EXTRA_TARGET_D_OS_VERSIONS() \ + ANDROID_TARGET_D_OS_VERSIONS(); + +#define LINK_SPEC LINUX_TARGET_LINK_SPEC AARCH64_ERRATA_LINK_SPEC ANDROID_LINK_SPEC + +#undef SUBTARGET_CC1_SPEC +#define SUBTARGET_CC1_SPEC \ + LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \ + GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) + +#undef LIB_SPEC +#define LIB_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LIB_SPEC, \ + GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC " " ANDROID_LIB_SPEC) + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC) + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \ + GNU_USER_TARGET_ENDFILE_SPEC,\ + GNU_USER_TARGET_MATHFILE_SPEC " "\ + ANDROID_ENDFILE_SPEC) + +#define TARGET_OS_CPP_BUILTINS() \ + do \ +{ \ + GNU_USER_TARGET_OS_CPP_BUILTINS(); \ + ANDROID_TARGET_OS_CPP_BUILTINS();\ +} \ + while (0) + +#else + +#define LINK_SPEC LINUX_TARGET_LINK_SPEC AARCH64_ERRATA_LINK_SPEC #undef ENDFILE_SPEC #define ENDFILE_SPEC \ @@ -64,6 +104,8 @@ } \ while (0) +#endif + #define TARGET_ASM_FILE_END aarch64_file_end_indicate_exec_stack /* Uninitialized common symbols in non-PIE executables, even with diff --git a/libstdc++-v3/config/os/bionic/ctype_base.h b/libstdc++-v3/config/os/bionic/ctype_base.h index bbb499ce749..8c5a505ee8d 100644 --- a/libstdc++-v3/config/os/bionic/ctype_base.h +++ b/libstdc++-v3/config/os/bionic/ctype_base.h @@ -27,6 +27,19 @@ // // Information as gleaned from /usr/include/ctype.h +// Define macros by ourselves so we do not get into more troubles. +#define _GLIBCXX_U 0x01 +#define _GLIBCXX_L 0x02 +#define _GLIBCXX_D 0x04 +#define _GLIBCXX_S 0x08 +#define _GLIBCXX_P 0x10 +#define _GLIBCXX_C 0x20 +#define _GLIBCXX_X 0x40 +#define _GLIBCXX_B 0x80 +#define _GLIBCXX_R (_GLIBCXX_P|_GLIBCXX_U|\ +_GLIBCXX_L|_GLIBCXX_D|_GLIBCXX_B) +#define _GLIBCXX_A (_GLIBCXX_L|_GLIBCXX_U) +#define _GLIBCXX_N _GLIBCXX_D namespace std _GLIBCXX_VISIBILITY(default) { @@ -41,20 +54,19 @@
[PATCH 1/1] [PATCH] Fix canadian compile for mingw-w64 copies the wrong dlls for mingw-w64 multilibs [PR100427]
When building GCC hosted on windows with Canadian/native compilation (host==target), the build scripts in GCC would override DLLs with each other. For example, for MinGW-w64, 32-bit DLLs would override 64 bits because build scripts copy them both to /bin. This patch fixes the issue by avoiding copying DLLs with multilibs. However, it would still copy when we do not build multilibs, usually the native build for GCC on windows. --- gcc/configure | 26 ++ libatomic/configure| 13 + libbacktrace/configure | 13 + libcc1/configure | 26 ++ libffi/configure | 26 ++ libgfortran/configure | 26 ++ libgo/config/libtool.m4| 13 + libgo/configure| 13 + libgomp/configure | 26 ++ libitm/configure | 26 ++ libobjc/configure | 13 + liboffloadmic/configure| 26 ++ liboffloadmic/plugin/configure | 26 ++ libphobos/configure| 13 + libquadmath/configure | 13 + libsanitizer/configure | 26 ++ libssp/configure | 13 + libstdc++-v3/configure | 26 ++ libtool.m4 | 13 + libvtv/configure | 26 ++ lto-plugin/configure | 13 + zlib/configure | 13 + 22 files changed, 429 insertions(+) diff --git a/gcc/configure b/gcc/configure index 992a9d70092..d66ccc2a7f4 100755 --- a/gcc/configure +++ b/gcc/configure @@ -18642,6 +18642,18 @@ cygwin* | mingw* | pw32* | cegcc*) yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds +# If user builds GCC with mulitlibs enabled, it should just install on $(libdir) +# not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones. +if test ${multilib} = yes; then +postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + $install_prog $dir/$dlname $destdir/$dlname~ + chmod a+x $destdir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then +eval '\''$striplib $destdir/$dlname'\'' || exit \$?; + fi' +else postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ @@ -18651,6 +18663,7 @@ cygwin* | mingw* | pw32* | cegcc*) if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' +fi postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' @@ -22299,6 +22312,18 @@ cygwin* | mingw* | pw32* | cegcc*) yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds +# If user builds GCC with mulitlibs enabled, it should just install on $(libdir) +# not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones. +if test ${multilib} = yes; then +postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + $install_prog $dir/$dlname $destdir/$dlname~ + chmod a+x $destdir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then +eval '\''$striplib $destdir/$dlname'\'' || exit \$?; + fi' +else postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ @@ -22308,6 +22333,7 @@ cygwin* | mingw* | pw32* | cegcc*) if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' +fi postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' diff --git a/libatomic/configure b/libatomic/configure index 5867e69ac14..4fd8cb34cd4 100755 --- a/libatomic/configure +++ b/libatomic/configure @@ -10461,6 +10461,18 @@ cygwin* | mingw* | pw32* | cegcc*) yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds +# If user builds GCC with mulitlibs
[PATCH] Fix [11/12 regression] error: 'fenv_t' has not been declared in '::' -- canadian compilation fails [PR100017]
libstdc++ cannot find fenv_t for fenv.h when doing canadian compilation. Fix it by adding -nostdinc++ toggle to configure and configure.ac. new patch after today's change to configure --- configure| 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 9c2d7df1bb2..103a59627b0 100755 --- a/configure +++ b/configure @@ -17304,7 +17304,7 @@ else fi -RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET" +RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET -nostdinc++" { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target ar" >&5 $as_echo_n "checking where to find the target ar... " >&6; } diff --git a/configure.ac b/configure.ac index 68cc5cc31fe..baab3b02e2e 100644 --- a/configure.ac +++ b/configure.ac @@ -3636,7 +3636,7 @@ ACX_CHECK_INSTALLED_TARGET_TOOL(STRIP_FOR_TARGET, strip) ACX_CHECK_INSTALLED_TARGET_TOOL(WINDRES_FOR_TARGET, windres) ACX_CHECK_INSTALLED_TARGET_TOOL(WINDMC_FOR_TARGET, windmc) -RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET" +RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET -nostdinc++" GCC_TARGET_TOOL(ar, AR_FOR_TARGET, AR, [binutils/ar]) GCC_TARGET_TOOL(as, AS_FOR_TARGET, AS, [gas/as-new]) -- 2.25.1
[PATCH] [PATCH] Fix [11/12 regression] error: 'fenv_t' has not been declared in '::' -- canadian compilation fails [PR100017]
libstdc++ cannot find fenv_t for fenv.h when doing canadian compilation. Fix it by adding -nostdinc++ toggle to configure and configure.ac. Backported from master --- configure| 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 504f6410274..0c53c986c11 100755 --- a/configure +++ b/configure @@ -16478,7 +16478,7 @@ else fi -RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET" +RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET -nostdinc++" { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target ar" >&5 $as_echo_n "checking where to find the target ar... " >&6; } diff --git a/configure.ac b/configure.ac index 088e735c5db..ee0953d53ae 100644 --- a/configure.ac +++ b/configure.ac @@ -3520,7 +3520,7 @@ ACX_CHECK_INSTALLED_TARGET_TOOL(STRIP_FOR_TARGET, strip) ACX_CHECK_INSTALLED_TARGET_TOOL(WINDRES_FOR_TARGET, windres) ACX_CHECK_INSTALLED_TARGET_TOOL(WINDMC_FOR_TARGET, windmc) -RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET" +RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET -nostdinc++" GCC_TARGET_TOOL(ar, AR_FOR_TARGET, AR, [binutils/ar]) GCC_TARGET_TOOL(as, AS_FOR_TARGET, AS, [gas/as-new]) -- 2.25.1
[PATCH] Fix [11/12 regression] error: 'fenv_t' has not been declared in '::' -- canadian compilation fails [PR100017]
From: expnkx libstdc++ cannot find fenv_t for fenv.h when doing canadian compilation. Fix it by adding -nostdinc++ toggle to configure and configure.ac. --- configure| 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 2e2dcd0ab30..f4c746e7733 100755 --- a/configure +++ b/configure @@ -17285,7 +17285,7 @@ else fi -RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET" +RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET -nostdinc++" { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target ar" >&5 $as_echo_n "checking where to find the target ar... " >&6; } diff --git a/configure.ac b/configure.ac index 68cc5cc31fe..baab3b02e2e 100644 --- a/configure.ac +++ b/configure.ac @@ -3636,7 +3636,7 @@ ACX_CHECK_INSTALLED_TARGET_TOOL(STRIP_FOR_TARGET, strip) ACX_CHECK_INSTALLED_TARGET_TOOL(WINDRES_FOR_TARGET, windres) ACX_CHECK_INSTALLED_TARGET_TOOL(WINDMC_FOR_TARGET, windmc) -RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET" +RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET -nostdinc++" GCC_TARGET_TOOL(ar, AR_FOR_TARGET, AR, [binutils/ar]) GCC_TARGET_TOOL(as, AS_FOR_TARGET, AS, [gas/as-new]) -- 2.25.1