gcc/
        * config.gcc: fix target aarch64-linux-android, arm-linux-androideabi,
        i686-linux-android, x86_64-linux-android
        * config/linux-android.h: fix SPEC based on aarch64-linux-android-clang
        * config/aarch64/aarch64-elf.h: Add Macro DEFAULT_ASM_SPEC
        * config/aarch64/aarch64-linux.h: Add BIONIC_DYNAMIC_LINKER, fix SPEC 
for aarch64-android
        * config/aarch64/t-linux-android: New file for aarch64-android muiltarch
        * config/arm/elf.h: Add Macro DEFAULT_ASM_SPEC
        * config/arm/linux-eabi.h: Add Macro ASM_SPEC
        * config/arm/t-linux-androideabi: fix MULTILIB, MULTIARCH
        * config/gcc/i386/t-linux-android: New file for adding 
i686-linux-android MULTIARCH
        * config/gcc/i386/t-linux64-android: New file for adding 
x86_64-linux-android MULTILIB
libgcc/
        * config/i386/heap-trampoline.c: Allow x86-android platforms in heap 
trampolines.
libphobos/
        * libdruntime/core/stdc/stdio.d: fix stdin,stdout,stderr 
symbol conflict for android api-level>=23
        * libdruntime/gcc/sections/elf.d: for CRuntime_Bionic, SharedELF is true
        * libdruntime/gcc/sections/package.d: CRuntime_Bionic platform is 
SectionsElf platform
libstdc++-v3/
        * config/os/bionic: fix CTYPE undefine


---
 gcc/config.gcc                
               | 25 +++++++++++-
 gcc/config/aarch64/aarch64-elf.h            
 |  8 +++-
 gcc/config/aarch64/aarch64-linux.h          
 | 42 ++++++++++++++++++--
 gcc/config/aarch64/t-linux-android          
 |  4 ++
 gcc/config/arm/elf.h              
           |  8 +++-
 gcc/config/arm/linux-eabi.h            
      |  6 +++
 gcc/config/arm/t-linux-androideabi          
 |  6 ++-
 gcc/config/i386/t-linux-android            
  |  1 +
 gcc/config/i386/t-linux64-android          
  |  3 ++
 gcc/config/linux-android.h            
       | 14 +++++--
 libgcc/config/i386/heap-trampoline.c        
 |  2 +-
 libphobos/libdruntime/core/stdc/stdio.d      |  9 
+++--
 libphobos/libdruntime/gcc/sections/elf.d     |  1 +
 libphobos/libdruntime/gcc/sections/package.d |  1 +
 libstdc++-v3/config/os/bionic/ctype_base.h   | 22 +++++-----
 15 files changed, 124 insertions(+), 28 deletions(-)
 create mode 100644 gcc/config/aarch64/t-linux-android
 create mode 100644 gcc/config/i386/t-linux-android
 create mode 100644 gcc/config/i386/t-linux64-android


diff --git a/gcc/config.gcc b/gcc/config.gcc
index 71ac3badafd..8951567f788 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1241,14 +1241,18 @@ aarch64*-*-netbsd*)
   extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
   ;;
 aarch64*-*-linux*)
-       tm_file="${tm_file} elfos.h gnu-user.h linux.h glibc-stdint.h"
+       tm_file="${tm_file} 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"
+       extra_options="${extra_options} linux-android.opt"
   tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-linux"
   tm_defines="${tm_defines}  TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1"
   case $target in
   aarch64_be-*)
           tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
           ;;
+       *-android)
+        tmake_file="${tmake_file} aarch64/t-linux-android"
+        ;;
   esac
   aarch64_multilibs="${with_multilib_list}"
   if test "$aarch64_multilibs" = "default"; then
@@ -1476,6 +1480,7 @@ arm*-*-linux-* | arm*-*-uclinuxfdpiceabi)
   case ${target} in
   *-androideabi)
       tmake_file="$tmake_file arm/t-linux-androideabi"
+           target_cpu_cname="generic-armv7-a"
       ;;
   esac
   # The EABI requires the use of __cxa_atexit.
@@ -2022,6 +2027,12 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | 
i[34567]86-*-gnu* | i[34567]8
                   tm_file="${tm_file} i386/x86-64.h 
i386/gnu-user-common.h i386/gnu-user64.h i386/linux-common.h i386/linux64.h"
                   tm_defines="${tm_defines} TARGET_BI_ARCH=1"
                   tmake_file="${tmake_file} i386/t-linux64"
+                       # Define multilib configuration for i686-linux-android.
+            case ${target} in
+            *-android)
+                
tmake_file="$tmake_file i386/t-linux64-android"
+                ;;
+            esac
                   x86_multilibs="${with_multilib_list}"
                   if test "$x86_multilibs" = "default"; then
                           x86_multilibs="m64,m32"
@@ -2085,6 +2096,12 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-gnu*)
           ;;
   esac
   tmake_file="${tmake_file} i386/t-linux64"
+       # Define multilib configuration for x86_64-linux-android.
+    case ${target} in
+    *-android)
+        tmake_file="$tmake_file i386/t-linux64-android"
+        ;;
+    esac
   x86_multilibs="${with_multilib_list}"
   if test "$x86_multilibs" = "default"; then
           case ${with_abi} in
@@ -5892,6 +5909,12 @@ case ${target} in
   i[34567]86-*-linux* | x86_64-*-linux*)
           extra_objs="${extra_objs} gnu-property.o"
           tmake_file="$tmake_file i386/t-linux i386/t-gnu-property"
+               # Define multilib configuration for i686-linux-android.
+        case ${target} in
+        *-android)
+            tmake_file="$tmake_file 
i386/t-linux-android"
+            ;;
+        esac
           ;;
   i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu)
           tmake_file="$tmake_file i386/t-kfreebsd"
diff --git a/gcc/config/aarch64/aarch64-elf.h b/gcc/config/aarch64/aarch64-elf.h
index b6fb7936789..a1ace46ebb2 100644
--- a/gcc/config/aarch64/aarch64-elf.h
+++ b/gcc/config/aarch64/aarch64-elf.h
@@ -132,8 +132,8 @@
 #define ASM_MABI_SPEC     "%{mabi=lp64:}"
 #endif


-#ifndef ASM_SPEC
-#define ASM_SPEC "\
+#ifndef DEFAULT_ASM_SPEC
+#define DEFAULT_ASM_SPEC "\
 %{mbig-endian:-EB} \
 %{mlittle-endian:-EL} \
 %{march=*:-march=%*} \
@@ -141,6 +141,10 @@
 ASM_MABI_SPEC
 #endif


+#ifndef ASM_SPEC
+# define ASM_SPEC DEFAULT_ASM_SPEC
+#endif
+
 #undef TYPE_OPERAND_FMT
 #define TYPE_OPERAND_FMT  "%%%s"


diff --git a/gcc/config/aarch64/aarch64-linux.h 
b/gcc/config/aarch64/aarch64-linux.h
index 8e51c8202cc..a6b20ac4992 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -23,6 +23,11 @@


 #define GLIBC_DYNAMIC_LINKER 
"/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"


+#ifdef BIONIC_DYNAMIC_LINKER
+#undef BIONIC_DYNAMIC_LINKER
+#endif
+#define BIONIC_DYNAMIC_LINKER "/system/bin/linker64"
+
 #undef MUSL_DYNAMIC_LINKER
 #define MUSL_DYNAMIC_LINKER 
"/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"


@@ -30,7 +35,18 @@
 #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"


 #undef  CC1_SPEC
-#define CC1_SPEC GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC
+#define CC1_SPEC LINUX_OR_ANDROID_CC(GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC, \
+GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC " " ANDROID_CC1_SPEC)
+
+#define CC1PLUS_SPEC \
+  LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC)
+
+#undef ASM_SPEC
+#define ASM_SPEC \
+  LINUX_OR_ANDROID_CC (DEFAULT_ASM_SPEC, \
+  DEFAULT_ASM_SPEC  " " \
+  ANDROID_ASM_SPEC)
+


 #define CPP_SPEC "%{pthread:-D_REENTRANT}"


@@ -46,21 +62,41 @@
    %{mbig-endian:-EB} %{mlittle-endian:-EL}     \
    -maarch64linux%{mabi=ilp32:32}%{mbig-endian:b}"


+#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)


-#define LINK_SPEC LINUX_TARGET_LINK_SPEC AARCH64_ERRATA_LINK_SPEC
+#define LINK_SPEC \
+LINUX_OR_ANDROID_LD(LINUX_TARGET_LINK_SPEC AARCH64_ERRATA_LINK_SPEC, \
+LINUX_TARGET_LINK_SPEC AARCH64_ERRATA_LINK_SPEC " " \
+ANDROID_LINK_SPEC)


 #define GNU_USER_TARGET_MATHFILE_SPEC \
  
 "%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}}"


+#ifdef TARGET_ANDROID
+#undef LIBGCC2_UNWIND_ATTRIBUTE
+#define LIBGCC2_UNWIND_ATTRIBUTE \
+   __attribute__((visibility("default")))
+#endif
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, 
ANDROID_STARTFILE_SPEC)
+
 #undef ENDFILE_SPEC
 #define ENDFILE_SPEC   \
   GNU_USER_TARGET_MATHFILE_SPEC " " \
-  GNU_USER_TARGET_ENDFILE_SPEC
+  LINUX_OR_ANDROID_LD( \
+  GNU_USER_TARGET_ENDFILE_SPEC, \
+  ANDROID_ENDFILE_SPEC)


 #define TARGET_OS_CPP_BUILTINS()          \
   do                                         \
     {                                           \
   GNU_USER_TARGET_OS_CPP_BUILTINS();      \
+       ANDROID_TARGET_OS_CPP_BUILTINS();  \
     }                                           \
   while (0)


diff --git a/gcc/config/aarch64/t-linux-android 
b/gcc/config/aarch64/t-linux-android
new file mode 100644
index 00000000000..e326d055d96
--- /dev/null
+++ b/gcc/config/aarch64/t-linux-android
@@ -0,0 +1,4 @@
+MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call 
if_multiarch,:aarch64$(AARCH_BE)-linux-android)
+MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-android)
+
+MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call 
if_multiarch,:aarch64$(AARCH_BE)-linux-android_ilp32)
diff --git a/gcc/config/arm/elf.h b/gcc/config/arm/elf.h
index 97230d19a36..5342dc898c0 100644
--- a/gcc/config/arm/elf.h
+++ b/gcc/config/arm/elf.h
@@ -56,8 +56,8 @@
 #undef SUBSUBTARGET_EXTRA_SPECS
 #define SUBSUBTARGET_EXTRA_SPECS


-#ifndef ASM_SPEC
-#define ASM_SPEC "\
+#ifndef DEFAULT_ASM_SPEC
+#define DEFAULT_ASM_SPEC "\
 %{mbig-endian:-EB} \
 %{mlittle-endian:-EL} \
 %(asm_cpu_spec) \
@@ -68,6 +68,10 @@
 %(subtarget_extra_asm_spec)"
 #endif


+#ifndef ASM_SPEC
+# define ASM_SPEC DEFAULT_ASM_SPEC
+#endif
+
 /* The ARM uses @ are a comment character so we need to redefine
    TYPE_OPERAND_FMT.  */
 #undef  TYPE_OPERAND_FMT
diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
index eef791f6a02..93442bd87e7 100644
--- a/gcc/config/arm/linux-eabi.h
+++ b/gcc/config/arm/linux-eabi.h
@@ -110,6 +110,12 @@
 #define CC1PLUS_SPEC \
   LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC)


+#undef ASM_SPEC
+#define ASM_SPEC \
+  LINUX_OR_ANDROID_CC (DEFAULT_ASM_SPEC, \
+  DEFAULT_ASM_SPEC  " " \
+  ANDROID_ASM_SPEC)
+
 #undef  LIB_SPEC
 #define LIB_SPEC                                                  \
   LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LIB_SPEC,                     
\
diff --git a/gcc/config/arm/t-linux-androideabi 
b/gcc/config/arm/t-linux-androideabi
index 8f1307c557f..9ffab1e1e9e 100644
--- a/gcc/config/arm/t-linux-androideabi
+++ b/gcc/config/arm/t-linux-androideabi
@@ -1,9 +1,11 @@
-MULTILIB_OPTIONS     = march=armv7-a mthumb
-MULTILIB_DIRNAMES    = armv7-a thumb
+MULTILIB_OPTIONS     =
+MULTILIB_DIRNAMES    =
 MULTILIB_EXCEPTIONS  =
 MULTILIB_MATCHES     =
 MULTILIB_OSDIRNAMES  =


+MULTIARCH_DIRNAME = $(call if_multiarch,arm$(ARM_EB)-linux-androideabi$(if 
$(filter hard,$(with_float)),hf))
+
 # The "special" multilib can be used to build native applications for 
Android,
 # as opposed to native shared libraries that are then called via JNI.
 #MULTILIB_OPTIONS    += tno-android-cc
diff --git a/gcc/config/i386/t-linux-android b/gcc/config/i386/t-linux-android
new file mode 100644
index 00000000000..d17d060ea96
--- /dev/null
+++ b/gcc/config/i386/t-linux-android
@@ -0,0 +1 @@
+MULTIARCH_DIRNAME = $(call if_multiarch,i686-linux-android)
diff --git a/gcc/config/i386/t-linux64-android 
b/gcc/config/i386/t-linux64-android
new file mode 100644
index 00000000000..c2e3c8ecb92
--- /dev/null
+++ b/gcc/config/i386/t-linux64-android
@@ -0,0 +1,3 @@
+MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-android)
+MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i686-linux-android)
+MULTILIB_OSDIRNAMES+= mx32=../libx32$(call 
if_multiarch,:x86_64-linux-androidx32)
diff --git a/gcc/config/linux-android.h b/gcc/config/linux-android.h
index 5f5ccd4e0f4..b23f098d312 100644
--- a/gcc/config/linux-android.h
+++ b/gcc/config/linux-android.h
@@ -38,15 +38,23 @@
   "%{" NOANDROID "|tno-android-ld:" LINUX_SPEC ";:" ANDROID_SPEC "}"


 #define ANDROID_LINK_SPEC \
-  "%{shared: -Bsymbolic}"
+  "%{shared: -Bsymbolic}  -z noexecstack -z relro -z now"


 #define ANDROID_CC1_SPEC                                          \
   "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} "                    
\
   "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}"


 #define ANDROID_CC1PLUS_SPEC                                              
\
-  "%{!fexceptions:%{!fno-exceptions: -fno-exceptions}} "          \
-  "%{!frtti:%{!fno-rtti: -fno-rtti}}"
+  "%{!fexceptions:%{!fno-exceptions: -fexceptions}} "             \
+  "%{!frtti:%{!fno-rtti: -frtti}}"
+
+#ifdef HAVE_LD_EH_FRAME_HDR
+#undef LINK_EH_SPEC
+#define LINK_EH_SPEC "--eh-frame-hdr  "
+#endif
+
+#define ANDROID_ASM_SPEC \
+  "--noexecstack"


 #define ANDROID_LIB_SPEC \
   "%{!static: -ldl}"
diff --git a/libgcc/config/i386/heap-trampoline.c 
b/libgcc/config/i386/heap-trampoline.c
index a8637dc92d3..1b94b3ca9a7 100644
--- a/libgcc/config/i386/heap-trampoline.c
+++ b/libgcc/config/i386/heap-trampoline.c
@@ -141,7 +141,7 @@ allocate_trampoline_page (void)
 {
   void *page;


-#if defined(__gnu_linux__)
+#if defined(__linux__) || defined(__gnu_hurd__)
   page = mmap (0, getpagesize (), PROT_WRITE | PROT_EXEC,
          MAP_ANON | MAP_PRIVATE, 0, 0);
 #elif __APPLE__
diff --git a/libphobos/libdruntime/core/stdc/stdio.d 
b/libphobos/libdruntime/core/stdc/stdio.d
index 1fc046163ee..ca2b5b4b441 100644
--- a/libphobos/libdruntime/core/stdc/stdio.d
+++ b/libphobos/libdruntime/core/stdc/stdio.d
@@ -1187,12 +1187,15 @@ else version (CRuntime_Bionic)


     private extern shared FILE[3] __sF;


+    @property auto __stdin()() { return &__sF[0]; }
+    @property auto __stdout()() { return &__sF[1]; }
+    @property auto __stderr()() { return &__sF[2]; }
     ///
-    @property auto stdin()() { return &__sF[0]; }
+    alias __stdin stdin;
     ///
-    @property auto stdout()() { return &__sF[1]; }
+    alias __stdout stdout;
     ///
-    @property auto stderr()() { return &__sF[2]; }
+    alias __stderr stderr;
 }
 else version (CRuntime_Musl)
 {
diff --git a/libphobos/libdruntime/gcc/sections/elf.d 
b/libphobos/libdruntime/gcc/sections/elf.d
index a67dd4a42b6..12bc9fb7b30 100644
--- a/libphobos/libdruntime/gcc/sections/elf.d
+++ b/libphobos/libdruntime/gcc/sections/elf.d
@@ -30,6 +30,7 @@ version (S390)    version = IBMZ_Any;
 version (SystemZ) version = IBMZ_Any;


 version (CRuntime_Glibc) enum SharedELF = true;
+else version (CRuntime_Bionic) enum SharedELF = true;
 else version (CRuntime_Musl) enum SharedELF = true;
 else version (FreeBSD) enum SharedELF = true;
 else version (NetBSD) enum SharedELF = true;
diff --git a/libphobos/libdruntime/gcc/sections/package.d 
b/libphobos/libdruntime/gcc/sections/package.d
index 6a245944387..f05b8ea7f61 100644
--- a/libphobos/libdruntime/gcc/sections/package.d
+++ b/libphobos/libdruntime/gcc/sections/package.d
@@ -23,6 +23,7 @@
 module gcc.sections;


 version (CRuntime_Glibc)  version = SectionsElf;
+version (CRuntime_Bionic) version = SectionsElf;
 version (CRuntime_Musl)   version = SectionsElf;
 version (CRuntime_UClibc) version = SectionsElf;
 version (FreeBSD)         version = SectionsElf;
diff --git a/libstdc++-v3/config/os/bionic/ctype_base.h 
b/libstdc++-v3/config/os/bionic/ctype_base.h
index e93f90a62be..0134ddb3f5b 100644
--- a/libstdc++-v3/config/os/bionic/ctype_base.h
+++ b/libstdc++-v3/config/os/bionic/ctype_base.h
@@ -41,17 +41,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
&nbsp; &nbsp; &nbsp;// NB: Offsets into ctype<char&gt;::_M_table force a 
particular size
&nbsp; &nbsp; &nbsp;// on the mask type. Because of this, we don't use an enum.
&nbsp; &nbsp; &nbsp;typedef char                mask;
-&nbsp; &nbsp; static const mask upper&nbsp; &nbsp;     = _U;
-&nbsp; &nbsp; static const mask lower  = _L;
-&nbsp; &nbsp; static const mask alpha  = _U | _L;
-&nbsp; &nbsp; static const mask digit  = _N;
-&nbsp; &nbsp; static const mask xdigit         = _X | _N;
-&nbsp; &nbsp; static const mask space  = _S;
-&nbsp; &nbsp; static const mask print  = _P | _U | _L | _N | _B;
-&nbsp; &nbsp; static const mask graph  = _P | _U | _L | _N;
-&nbsp; &nbsp; static const mask cntrl  = _C;
-&nbsp; &nbsp; static const mask punct  = _P;
-&nbsp; &nbsp; static const mask alnum  = _U | _L | _N;
+&nbsp; &nbsp; static const mask upper  = _CTYPE_U;
+&nbsp; &nbsp; static const mask lower  = _CTYPE_L;
+&nbsp; &nbsp; static const mask alpha  = _CTYPE_U | _CTYPE_L;
+&nbsp; &nbsp; static const mask digit  = _CTYPE_N;
+&nbsp; &nbsp; static const mask xdigit         = _CTYPE_X | _CTYPE_N;
+&nbsp; &nbsp; static const mask space  = _CTYPE_S;
+&nbsp; &nbsp; static const mask print  = _CTYPE_P | _CTYPE_U | _CTYPE_L | 
_CTYPE_N | _CTYPE_B;
+&nbsp; &nbsp; static const mask graph  = _CTYPE_P | _CTYPE_U | _CTYPE_L | 
_CTYPE_N;
+&nbsp; &nbsp; static const mask cntrl  = _CTYPE_C;
+&nbsp; &nbsp; static const mask punct  = _CTYPE_P;
+&nbsp; &nbsp; static const mask alnum  = _CTYPE_U | _CTYPE_L | _CTYPE_N;
&nbsp;#if __cplusplus &gt;= 201103L
&nbsp; &nbsp; &nbsp;static const mask blank     = space;
&nbsp;#endif
--
2.34.1

Reply via email to