On an armeabi-v7a device (phone) in the termux app with clang & make installed this passes all the tests. Can be used as a cross compiler to create "native apps" as well. Example 'config-extra.mak' for the cross arm-eabi-tcc: SYSROOT = <path_to_android_ndk...>/sysroot/usr TRIPLET = arm-linux-androideabi ANDRVER = 32 ROOT-arm-eabi = $(SYSROOT) CRT-arm-eabi = {R}/lib/$(TRIPLET)/$(ANDRVER) LIB-arm-eabi = {B};{R}/lib/$(TRIPLET)/$(ANDRVER);{R}/lib/$(TRIPLET) INC-arm-eabi = {B}/lib/include;{R}/include/$(TRIPLET);{R}/include DEF-arm-eabi = -DTCC_TARGET_ARM -DTCC_ARM_VFP -DTCC_ARM_EABI DEF-arm-eabi += -DTARGETOS_ANDROID -DCONFIG_TCC_PIE -DCONFIG_NEW_DTAGS DEF-arm-eabi += -DCONFIG_TCC_ELFINTERP=\"/system/bin/linker\" # on unix replace ';' by ':'. $ ./configure && make cross-arm-eabi && make install
Unified · Split
| @@ -90,8 +90,10 @@ NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP · 89 unmodified lines | |||
| 90 | NATIVE_DEFINES_$(CONFIG_arm64) += -DTCC_TARGET_ARM64 | 90 | NATIVE_DEFINES_$(CONFIG_arm64) += -DTCC_TARGET_ARM64 |
| 91 | NATIVE_DEFINES_$(CONFIG_riscv64) += -DTCC_TARGET_RISCV64 | 91 | NATIVE_DEFINES_$(CONFIG_riscv64) += -DTCC_TARGET_RISCV64 |
| 92 | NATIVE_DEFINES_$(CONFIG_BSD) += -DTARGETOS_$(TARGETOS) | 92 | NATIVE_DEFINES_$(CONFIG_BSD) += -DTARGETOS_$(TARGETOS) |
| 93 | NATIVE_DEFINES_$(CONFIG_Android) += -DTARGETOS_ANDROID | ||
| 93 | NATIVE_DEFINES_$(CONFIG_pie) += -DCONFIG_TCC_PIE | 94 | NATIVE_DEFINES_$(CONFIG_pie) += -DCONFIG_TCC_PIE |
| 94 | NATIVE_DEFINES_$(CONFIG_pic) += -DCONFIG_TCC_PIC | 95 | NATIVE_DEFINES_$(CONFIG_pic) += -DCONFIG_TCC_PIC |
| 96 | NATIVE_DEFINES_$(CONFIG_new-dtags) += -DCONFIG_NEW_DTAGS | ||
| 95 | NATIVE_DEFINES_no_$(CONFIG_bcheck) += -DCONFIG_TCC_BCHECK=0 | 97 | NATIVE_DEFINES_no_$(CONFIG_bcheck) += -DCONFIG_TCC_BCHECK=0 |
| 96 | NATIVE_DEFINES_no_$(CONFIG_backtrace) += -DCONFIG_TCC_BACKTRACE=0 | 98 | NATIVE_DEFINES_no_$(CONFIG_backtrace) += -DCONFIG_TCC_BACKTRACE=0 |
| 97 | NATIVE_DEFINES += $(NATIVE_DEFINES_yes) $(NATIVE_DEFINES_no_no) | 99 | NATIVE_DEFINES += $(NATIVE_DEFINES_yes) $(NATIVE_DEFINES_no_no) |
| @@ -27,8 +27,7 @@ mandir="" · 26 unmodified lines | |||
| 27 | infodir="" | 27 | infodir="" |
| 28 | sysroot="" | 28 | sysroot="" |
| 29 | cross_prefix="" | 29 | cross_prefix="" |
| 30 | test -z "$CC" && CC="gcc" | 30 | cc="gcc" |
| 31 | test -z "$cc" && cc="$CC" | ||
| 32 | ar="ar" | 31 | ar="ar" |
| 33 | bigendian="no" | 32 | bigendian="no" |
| 34 | mingw32="no" | 33 | mingw32="no" |
| @@ -46,16 +45,20 @@ confvars= · 11 unmodified lines | |||
| 46 | suggest="yes" | 45 | suggest="yes" |
| 47 | gcc_major=0 | 46 | gcc_major=0 |
| 48 | gcc_minor=0 | 47 | gcc_minor=0 |
| 49 | cc_name="$cc" | 48 | cc_name="gcc" |
| 50 | ar_set= | 49 | ar_set= |
| 51 | darwin= | 50 | darwin= |
| 52 | cpu= | ||
| 53 | cpuver= | 51 | cpuver= |
| 54 | dwarf= | 52 | dwarf= |
| 55 | 53 | ||
| 54 | # use CC from environment when set | ||
| 55 | test -n "$CC" && cc="$CC" | ||
| 56 | |||
| 56 | # OS specific | 57 | # OS specific |
| 57 | cpu_sys=`uname -m` | 58 | cpu=`uname -m` |
| 59 | cpu_sys="$cpu" | ||
| 58 | targetos=`uname` | 60 | targetos=`uname` |
| 61 | test "$(uname -o)" = "Android" && targetos=Android | ||
| 59 | 62 | ||
| 60 | case $targetos in | 63 | case $targetos in |
| 61 | Darwin) | 64 | Darwin) |
| @@ -73,6 +76,20 @@ case $targetos in · 11 unmodified lines | |||
| 73 | DragonFly|OpenBSD|FreeBSD|NetBSD) | 76 | DragonFly|OpenBSD|FreeBSD|NetBSD) |
| 74 | confvars="$confvars BSD ldl=no" | 77 | confvars="$confvars BSD ldl=no" |
| 75 | ;; | 78 | ;; |
| 79 | Android) | ||
| 80 | confvars="$confvars Android pie new-dtags" | ||
| 81 | if test -n "$TERMUX_VERSION"; then | ||
| 82 | prefix="$PREFIX" # "/data/data/com.termux/files/usr" | ||
| 83 | sysroot="$PREFIX" | ||
| 84 | test "$cpu" = "aarch64" -o "$cpu" = "x86_64" && S="64" || S="" | ||
| 85 | tcc_sysincludepaths="{B}/include:{R}/include/\\\"CONFIG_TRIPLET\\\":{R}/include" | ||
| 86 | tcc_libpaths="{B}:{R}/lib:/system/lib${S}" | ||
| 87 | tcc_crtprefix="{R}/lib" | ||
| 88 | tcc_elfinterp="/system/bin/linker${S}" | ||
| 89 | use_triplet="yes" | ||
| 90 | tcc_switches="-Wl,-rpath=$sysroot/lib,-section-alignment=0x1000" | ||
| 91 | fi | ||
| 92 | ;; | ||
| 76 | *) | 93 | *) |
| 77 | ;; | 94 | ;; |
| 78 | esac | 95 | esac |
| @@ -153,6 +170,8 @@ for opt do · 74 unmodified lines | |||
| 153 | ;; | 170 | ;; |
| 154 | --with-selinux) confvars="$confvars selinux" | 171 | --with-selinux) confvars="$confvars selinux" |
| 155 | ;; | 172 | ;; |
| 173 | --tcc-switches=*) tcc_switches=`echo $opt | cut -d '=' -f 2-` | ||
| 174 | ;; | ||
| 156 | --config-mingw32*) mingw32=$(echo "$opt=yes" | cut -d '=' -f 2) | 175 | --config-mingw32*) mingw32=$(echo "$opt=yes" | cut -d '=' -f 2) |
| 157 | ;; | 176 | ;; |
| 158 | --config-*) confvars="$confvars ${opt#--config-}"; suggest="no" | 177 | --config-*) confvars="$confvars ${opt#--config-}"; suggest="no" |
| @@ -176,9 +195,6 @@ if test "$darwin" = "yes" -a "$cpu" = "x86_64" -a "$cpu_sys" = "arm64"; then · 17 unmodified lines | |||
| 176 | LDFLAGS="$LDFLAGS -arch $cpu" | 195 | LDFLAGS="$LDFLAGS -arch $cpu" |
| 177 | fi | 196 | fi |
| 178 | 197 | ||
| 179 | # checking for cpu | ||
| 180 | test -z "$cpu" && cpu="$cpu_sys" | ||
| 181 | |||
| 182 | case "$cpu" in | 198 | case "$cpu" in |
| 183 | x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386) | 199 | x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386) |
| 184 | cpu="i386" | 200 | cpu="i386" |
| @@ -325,6 +341,7 @@ Advanced options (experts only): · 140 unmodified lines | |||
| 325 | --crtprefix=... specify locations of crt?.o, colon separated | 341 | --crtprefix=... specify locations of crt?.o, colon separated |
| 326 | --elfinterp=... specify elf interpreter | 342 | --elfinterp=... specify elf interpreter |
| 327 | --triplet=... specify system library/include directory triplet | 343 | --triplet=... specify system library/include directory triplet |
| 344 | --tcc-switches=... specify implicit switches passed to tcc | ||
| 328 | 345 | ||
| 329 | --config-uClibc,-musl enable system specific configurations | 346 | --config-uClibc,-musl enable system specific configurations |
| 330 | --config-mingw32 build on windows using msys, busybox, etc. | 347 | --config-mingw32 build on windows using msys, busybox, etc. |
| @@ -349,8 +366,8 @@ if test -z "$cross_prefix" ; then · 18 unmodified lines | |||
| 349 | fi | 366 | fi |
| 350 | if test "$mingw32" = "no" ; then | 367 | if test "$mingw32" = "no" ; then |
| 351 | 368 | ||
| 352 | if test -z "$triplet"; then | 369 | if test -z "$triplet" -a -n "$_triplet"; then |
| 353 | if test -n "$_triplet" -a -f "/usr/lib/$_triplet/crti.o" ; then | 370 | if test -f "/usr/lib/$_triplet/crti.o" -o -n "$use_triplet" ; then |
| 354 | triplet="$_triplet" | 371 | triplet="$_triplet" |
| 355 | fi | 372 | fi |
| 356 | fi | 373 | fi |
| @@ -372,8 +389,7 @@ if test -z "$cross_prefix" ; then · 15 unmodified lines | |||
| 372 | confvars="$confvars arm_eabihf arm_vfp" | 389 | confvars="$confvars arm_eabihf arm_vfp" |
| 373 | elif test "${_triplet%eabi}" != "$_triplet" ; then | 390 | elif test "${_triplet%eabi}" != "$_triplet" ; then |
| 374 | confvars="$confvars arm_eabi arm_vfp" | 391 | confvars="$confvars arm_eabi arm_vfp" |
| 375 | fi | 392 | elif grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then |
| 376 | if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then | ||
| 377 | confvars="$confvars arm_vfp" | 393 | confvars="$confvars arm_vfp" |
| 378 | fi | 394 | fi |
| 379 | fi | 395 | fi |
| @@ -496,6 +512,7 @@ print_mak CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths" · 116 unmodified lines | |||
| 496 | print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths" | 512 | print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths" |
| 497 | print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix" | 513 | print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix" |
| 498 | print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp" | 514 | print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp" |
| 515 | print_mak CONFIG_TCC_SWITCHES "$tcc_switches" | ||
| 499 | print_mak CONFIG_LDDIR "$tcc_lddir" | 516 | print_mak CONFIG_LDDIR "$tcc_lddir" |
| 500 | print_mak CONFIG_TRIPLET "$triplet" | 517 | print_mak CONFIG_TRIPLET "$triplet" |
| 501 | print_mak TCC_CPU_VERSION "$cpuver" num | 518 | print_mak TCC_CPU_VERSION "$cpuver" num |
| @@ -21,6 +21,8 @@ const char *platform_macros[] = { · 20 unmodified lines | |||
| 21 | "__OpenBSD__", "TARGETOS_OpenBSD", | 21 | "__OpenBSD__", "TARGETOS_OpenBSD", |
| 22 | "__NetBSD__", "TARGETOS_NetBSD", | 22 | "__NetBSD__", "TARGETOS_NetBSD", |
| 23 | "__linux__", "TARGETOS_Linux", | 23 | "__linux__", "TARGETOS_Linux", |
| 24 | "__ANDROID__", "TARGETOS_ANDROID", | ||
| 25 | |||
| 24 | "__SIZEOF_POINTER__", "PTR_SIZE", | 26 | "__SIZEOF_POINTER__", "PTR_SIZE", |
| 25 | "__SIZEOF_LONG__", "LONG_SIZE", | 27 | "__SIZEOF_LONG__", "LONG_SIZE", |
| 26 | 0 | 28 | 0 |
| @@ -206,15 +208,21 @@ int main(int argc, char **argv) · 179 unmodified lines | |||
| 206 | # define TRIPLET_OS "unknown" | 208 | # define TRIPLET_OS "unknown" |
| 207 | #endif | 209 | #endif |
| 208 | 210 | ||
| 211 | #if defined __ANDROID__ | ||
| 212 | # define ABI_PREFIX "android" | ||
| 213 | #else | ||
| 214 | # define ABI_PREFIX "gnu" | ||
| 215 | #endif | ||
| 216 | |||
| 209 | /* Define calling convention and ABI */ | 217 | /* Define calling convention and ABI */ |
| 210 | #if defined (__ARM_EABI__) | 218 | #if defined (__ARM_EABI__) |
| 211 | # if defined (__ARM_PCS_VFP) | 219 | # if defined (__ARM_PCS_VFP) |
| 212 | # define TRIPLET_ABI "gnueabihf" | 220 | # define TRIPLET_ABI ABI_PREFIX"eabihf" |
| 213 | # else | 221 | # else |
| 214 | # define TRIPLET_ABI "gnueabi" | 222 | # define TRIPLET_ABI ABI_PREFIX"eabi" |
| 215 | # endif | 223 | # endif |
| 216 | #else | 224 | #else |
| 217 | # define TRIPLET_ABI "gnu" | 225 | # define TRIPLET_ABI ABI_PREFIX |
| 218 | #endif | 226 | #endif |
| 219 | 227 | ||
| 220 | #if defined _WIN32 | 228 | #if defined _WIN32 |
| @@ -125,6 +125,13 @@ · 124 unmodified lines | |||
| 125 | #define __FINITE_MATH_ONLY__ 1 | 125 | #define __FINITE_MATH_ONLY__ 1 |
| 126 | #define _FORTIFY_SOURCE 0 | 126 | #define _FORTIFY_SOURCE 0 |
| 127 | 127 | ||
| 128 | #elif defined __ANDROID__ | ||
| 129 | #define BIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD | ||
| 130 | #define __PRETTY_FUNCTION__ __FUNCTION__ | ||
| 131 | #define __has_builtin(x) 0 | ||
| 132 | #define _Nonnull | ||
| 133 | #define _Nullable | ||
| 134 | |||
| 128 | #else | 135 | #else |
| 129 | /* Linux */ | 136 | /* Linux */ |
| 130 | 137 | ||
| @@ -161,7 +161,7 @@ static pthread_spinlock_t bounds_spin; · 160 unmodified lines | |||
| 161 | #define HAVE_TLS_FUNC (1) | 161 | #define HAVE_TLS_FUNC (1) |
| 162 | #define HAVE_TLS_VAR (0) | 162 | #define HAVE_TLS_VAR (0) |
| 163 | #endif | 163 | #endif |
| 164 | #ifdef TCC_MUSL | 164 | #if defined TCC_MUSL || defined __ANDROID__ |
| 165 | # undef HAVE_CTYPE | 165 | # undef HAVE_CTYPE |
| 166 | #endif | 166 | #endif |
| 167 | #endif | 167 | #endif |
| @@ -1174,7 +1174,8 @@ void __attribute__((destructor)) __bound_exit(void) · 1006 unmodified lines | |||
| 1174 | 1174 | ||
| 1175 | if (inited) { | 1175 | if (inited) { |
| 1176 | #if !defined(_WIN32) && !defined(__APPLE__) && !defined TCC_MUSL && \ | 1176 | #if !defined(_WIN32) && !defined(__APPLE__) && !defined TCC_MUSL && \ |
| 1177 | !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__) | 1177 | !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \ |
| 1178 | !defined(__ANDROID__) | ||
| 1178 | if (print_heap) { | 1179 | if (print_heap) { |
| 1179 | extern void __libc_freeres (void); | 1180 | extern void __libc_freeres (void); |
| 1180 | __libc_freeres (); | 1181 | __libc_freeres (); |
| @@ -496,6 +496,8 @@ static void tcc_split_path(TCCState *s, void *p_ary, int *p_nb_ary, const char * · 495 unmodified lines | |||
| 496 | c = p[1], p += 2; | 496 | c = p[1], p += 2; |
| 497 | if (c == 'B') | 497 | if (c == 'B') |
| 498 | cstr_cat(&str, s->tcc_lib_path, -1); | 498 | cstr_cat(&str, s->tcc_lib_path, -1); |
| 499 | if (c == 'R') | ||
| 500 | cstr_cat(&str, CONFIG_SYSROOT, -1); | ||
| 499 | if (c == 'f' && file) { | 501 | if (c == 'f' && file) { |
| 500 | /* substitute current file's dir */ | 502 | /* substitute current file's dir */ |
| 501 | const char *f = file->true_filename; | 503 | const char *f = file->true_filename; |
| @@ -810,7 +812,9 @@ LIBTCCAPI TCCState *tcc_new(void) · 308 unmodified lines | |||
| 810 | #ifdef TCC_TARGET_ARM | 812 | #ifdef TCC_TARGET_ARM |
| 811 | s->float_abi = ARM_FLOAT_ABI; | 813 | s->float_abi = ARM_FLOAT_ABI; |
| 812 | #endif | 814 | #endif |
| 813 | 815 | #ifdef CONFIG_NEW_DTAGS | |
| 816 | s->enable_new_dtags = 1; | ||
| 817 | #endif | ||
| 814 | s->ppfp = stdout; | 818 | s->ppfp = stdout; |
| 815 | /* might be used in error() before preprocess_start() */ | 819 | /* might be used in error() before preprocess_start() */ |
| 816 | s->include_stack_ptr = s->include_stack; | 820 | s->include_stack_ptr = s->include_stack; |
| @@ -943,6 +947,11 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 126 unmodified lines | |||
| 943 | tcc_add_crt(s, "crtbeginS.o"); | 947 | tcc_add_crt(s, "crtbeginS.o"); |
| 944 | else | 948 | else |
| 945 | tcc_add_crt(s, "crtbegin.o"); | 949 | tcc_add_crt(s, "crtbegin.o"); |
| 950 | #elif defined TARGETOS_ANDROID | ||
| 951 | if (output_type != TCC_OUTPUT_DLL) | ||
| 952 | tcc_add_crt(s, "crtbegin_dynamic.o"); | ||
| 953 | else | ||
| 954 | tcc_add_crt(s, "crtbegin_so.o"); | ||
| 946 | #else | 955 | #else |
| 947 | if (output_type != TCC_OUTPUT_DLL) | 956 | if (output_type != TCC_OUTPUT_DLL) |
| 948 | tcc_add_crt(s, "crt1.o"); | 957 | tcc_add_crt(s, "crt1.o"); |
| @@ -281,6 +281,9 @@ int main(int argc0, char **argv0) · 280 unmodified lines | |||
| 281 | redo: | 281 | redo: |
| 282 | argc = argc0, argv = argv0; | 282 | argc = argc0, argv = argv0; |
| 283 | s = s1 = tcc_new(); | 283 | s = s1 = tcc_new(); |
| 284 | #ifdef CONFIG_TCC_SWITCHES | ||
| 285 | tcc_set_options(s, CONFIG_TCC_SWITCHES); | ||
| 286 | #endif | ||
| 284 | opt = tcc_parse_args(s, &argc, &argv, 1); | 287 | opt = tcc_parse_args(s, &argc, &argv, 1); |
| 285 | 288 | ||
| 286 | if (n == 0) { | 289 | if (n == 0) { |
| @@ -857,7 +857,7 @@ ST_FUNC void relocate_syms(TCCState *s1, Section *symtab, int do_resolve) · 856 unmodified lines | |||
| 857 | #if defined TCC_IS_NATIVE && !defined TCC_TARGET_PE | 857 | #if defined TCC_IS_NATIVE && !defined TCC_TARGET_PE |
| 858 | /* dlsym() needs the undecorated name. */ | 858 | /* dlsym() needs the undecorated name. */ |
| 859 | void *addr = dlsym(RTLD_DEFAULT, &name[s1->leading_underscore]); | 859 | void *addr = dlsym(RTLD_DEFAULT, &name[s1->leading_underscore]); |
| 860 | #if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD | 860 | #if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD || TARGETOS_ANDROID |
| 861 | if (addr == NULL) { | 861 | if (addr == NULL) { |
| 862 | int i; | 862 | int i; |
| 863 | for (i = 0; i < s1->nb_loaded_dlls; i++) | 863 | for (i = 0; i < s1->nb_loaded_dlls; i++) |
| @@ -1526,6 +1526,11 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 662 unmodified lines | |||
| 1526 | # if !TARGETOS_OpenBSD | 1526 | # if !TARGETOS_OpenBSD |
| 1527 | tcc_add_crt(s1, "crtn.o"); | 1527 | tcc_add_crt(s1, "crtn.o"); |
| 1528 | # endif | 1528 | # endif |
| 1529 | #elif TARGETOS_ANDROID | ||
| 1530 | if (s1->output_type == TCC_OUTPUT_DLL) | ||
| 1531 | tcc_add_crt(s1, "crtend_so.o"); | ||
| 1532 | else | ||
| 1533 | tcc_add_crt(s1, "crtend_android.o"); | ||
| 1529 | #else | 1534 | #else |
| 1530 | tcc_add_crt(s1, "crtn.o"); | 1535 | tcc_add_crt(s1, "crtn.o"); |
| 1531 | #endif | 1536 | #endif |
| @@ -2272,22 +2277,15 @@ static void tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr, · 740 unmodified lines | |||
| 2272 | ehdr.e_ident[4] = ELFCLASSW; | 2277 | ehdr.e_ident[4] = ELFCLASSW; |
| 2273 | ehdr.e_ident[5] = ELFDATA2LSB; | 2278 | ehdr.e_ident[5] = ELFDATA2LSB; |
| 2274 | ehdr.e_ident[6] = EV_CURRENT; | 2279 | ehdr.e_ident[6] = EV_CURRENT; |
| 2280 | |||
| 2275 | #if TARGETOS_FreeBSD || TARGETOS_FreeBSD_kernel | 2281 | #if TARGETOS_FreeBSD || TARGETOS_FreeBSD_kernel |
| 2276 | ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD; | 2282 | ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD; |
| 2277 | #endif | 2283 | #elif defined TCC_TARGET_ARM && defined TCC_ARM_EABI |
| 2278 | #ifdef TCC_TARGET_ARM | 2284 | ehdr.e_flags = EF_ARM_EABI_VER5; |
| 2279 | #ifdef TCC_ARM_EABI | 2285 | ehdr.e_flags |= s1->float_abi == ARM_HARD_FLOAT |
| 2280 | ehdr.e_ident[EI_OSABI] = 0; | 2286 | ? EF_ARM_VFP_FLOAT : EF_ARM_SOFT_FLOAT; |
| 2281 | ehdr.e_flags = EF_ARM_EABI_VER4; | 2287 | #elif defined TCC_TARGET_ARM |
| 2282 | if (file_type & (TCC_OUTPUT_EXE | TCC_OUTPUT_DLL)) | ||
| 2283 | ehdr.e_flags |= EF_ARM_HASENTRY; | ||
| 2284 | if (s1->float_abi == ARM_HARD_FLOAT) | ||
| 2285 | ehdr.e_flags |= EF_ARM_VFP_FLOAT; | ||
| 2286 | else | ||
| 2287 | ehdr.e_flags |= EF_ARM_SOFT_FLOAT; | ||
| 2288 | #else | ||
| 2289 | ehdr.e_ident[EI_OSABI] = ELFOSABI_ARM; | 2288 | ehdr.e_ident[EI_OSABI] = ELFOSABI_ARM; |
| 2290 | #endif | ||
| 2291 | #elif defined TCC_TARGET_RISCV64 | 2289 | #elif defined TCC_TARGET_RISCV64 |
| 2292 | ehdr.e_flags = EF_RISCV_FLOAT_ABI_DOUBLE; | 2290 | ehdr.e_flags = EF_RISCV_FLOAT_ABI_DOUBLE; |
| 2293 | #endif | 2291 | #endif |
| @@ -8266,7 +8266,7 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym) · 8265 unmodified lines | |||
| 8266 | sym = type.ref; | 8266 | sym = type.ref; |
| 8267 | if (sym->f.func_type == FUNC_OLD && l == VT_CONST) | 8267 | if (sym->f.func_type == FUNC_OLD && l == VT_CONST) |
| 8268 | decl0(VT_CMP, 0, sym); | 8268 | decl0(VT_CMP, 0, sym); |
| 8269 | #ifdef TCC_TARGET_MACHO | 8269 | #if defined TCC_TARGET_MACHO || defined TARGETOS_ANDROID |
| 8270 | if (sym->f.func_alwinl | 8270 | if (sym->f.func_alwinl |
| 8271 | && ((type.t & (VT_EXTERN | VT_INLINE)) | 8271 | && ((type.t & (VT_EXTERN | VT_INLINE)) |
| 8272 | == (VT_EXTERN | VT_INLINE))) { | 8272 | == (VT_EXTERN | VT_INLINE))) { |
| @@ -3713,6 +3713,9 @@ static const char * const target_os_defs = · 3712 unmodified lines | |||
| 3713 | # else | 3713 | # else |
| 3714 | "__linux__\0" | 3714 | "__linux__\0" |
| 3715 | "__linux\0" | 3715 | "__linux\0" |
| 3716 | # if TARGETOS_ANDROID | ||
| 3717 | "__ANDROID__\0" | ||
| 3718 | # endif | ||
| 3716 | # endif | 3719 | # endif |
| 3717 | "__unix__\0" | 3720 | "__unix__\0" |
| 3718 | "__unix\0" | 3721 | "__unix\0" |
| @@ -3724,17 +3727,22 @@ static void putdef(CString *cs, const char *p) · 5 unmodified lines | |||
| 3724 | cstr_printf(cs, "#define %s%s\n", p, &" 1"[!!strchr(p, ' ')*2]); | 3727 | cstr_printf(cs, "#define %s%s\n", p, &" 1"[!!strchr(p, ' ')*2]); |
| 3725 | } | 3728 | } |
| 3726 | 3729 | ||
| 3730 | static void putdefs(CString *cs, const char *p) | ||
| 3731 | { | ||
| 3732 | while (*p) | ||
| 3733 | putdef(cs, p), p = strchr(p, 0) + 1; | ||
| 3734 | } | ||
| 3735 | |||
| 3727 | static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) | 3736 | static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) |
| 3728 | { | 3737 | { |
| 3729 | int a, b, c; | 3738 | int a, b, c; |
| 3730 | const char *defs[] = { target_machine_defs, target_os_defs, NULL }; | ||
| 3731 | const char *p; | ||
| 3732 | 3739 | ||
| 3733 | sscanf(TCC_VERSION, "%d.%d.%d", &a, &b, &c); | 3740 | sscanf(TCC_VERSION, "%d.%d.%d", &a, &b, &c); |
| 3734 | cstr_printf(cs, "#define __TINYC__ %d\n", a*10000 + b*100 + c); | 3741 | cstr_printf(cs, "#define __TINYC__ %d\n", a*10000 + b*100 + c); |
| 3735 | for (a = 0; defs[a]; ++a) | 3742 | |
| 3736 | for (p = defs[a]; *p; p = strchr(p, 0) + 1) | 3743 | putdefs(cs, target_machine_defs); |
| 3737 | putdef(cs, p); | 3744 | putdefs(cs, target_os_defs); |
| 3745 | |||
| 3738 | #ifdef TCC_TARGET_ARM | 3746 | #ifdef TCC_TARGET_ARM |
| 3739 | if (s1->float_abi == ARM_HARD_FLOAT) | 3747 | if (s1->float_abi == ARM_HARD_FLOAT) |
| 3740 | putdef(cs, "__ARM_PCS_VFP"); | 3748 | putdef(cs, "__ARM_PCS_VFP"); |
| @@ -390,7 +390,7 @@ static void set_pages_executable(TCCState *s1, int mode, void *ptr, unsigned lon · 389 unmodified lines | |||
| 390 | tcc_error("mprotect failed: did you mean to configure --with-selinux?"); | 390 | tcc_error("mprotect failed: did you mean to configure --with-selinux?"); |
| 391 | 391 | ||
| 392 | /* XXX: BSD sometimes dump core with bad system call */ | 392 | /* XXX: BSD sometimes dump core with bad system call */ |
| 393 | # if (TCC_TARGET_ARM && !TARGETOS_BSD) || TCC_TARGET_ARM64 | 393 | # if (defined TCC_TARGET_ARM && !TARGETOS_BSD) || defined TCC_TARGET_ARM64 |
| 394 | if (mode == 0 || mode == 3) { | 394 | if (mode == 0 || mode == 3) { |
| 395 | void __clear_cache(void *beginning, void *end); | 395 | void __clear_cache(void *beginning, void *end); |
| 396 | __clear_cache(ptr, (char *)ptr + length); | 396 | __clear_cache(ptr, (char *)ptr + length); |
| @@ -35,8 +35,8 @@ endif · 34 unmodified lines | |||
| 35 | ifeq (,$(filter arm64 i386 x86_64,$(ARCH))) | 35 | ifeq (,$(filter arm64 i386 x86_64,$(ARCH))) |
| 36 | TESTS := $(filter-out vla_test-run,$(TESTS)) | 36 | TESTS := $(filter-out vla_test-run,$(TESTS)) |
| 37 | endif | 37 | endif |
| 38 | ifeq ($(CONFIG_arm_eabi),yes) | 38 | ifeq (-$(CONFIG_arm_eabi)-$(CONFIG_arm_vfp)-,-yes--) |
| 39 | TESTS := $(filter-out test3,$(TESTS)) | 39 | TESTS := $(filter-out test3 test1b,$(TESTS)) |
| 40 | endif | 40 | endif |
| 41 | ifeq (,$(filter i386 x86_64,$(ARCH))) | 41 | ifeq (,$(filter i386 x86_64,$(ARCH))) |
| 42 | TESTS := $(filter-out asm-c-connect-test,$(TESTS)) | 42 | TESTS := $(filter-out asm-c-connect-test,$(TESTS)) |
| @@ -250,7 +250,7 @@ abitest-% : abitest-%.exe · 207 unmodified lines | |||
| 250 | ./$< $(TCCFLAGS) | 250 | ./$< $(TCCFLAGS) |
| 251 | 251 | ||
| 252 | abitest: abitest-cc | 252 | abitest: abitest-cc |
| 253 | ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float | 253 | ifneq (-$(CONFIG_arm_eabi)-$(CONFIG_arm_vfp)-,-yes--) |
| 254 | abitest: abitest-tcc | 254 | abitest: abitest-tcc |
| 255 | endif | 255 | endif |
| 256 | 256 | ||
| @@ -261,6 +261,8 @@ vla_test-run: vla_test$(EXESUF) · 4 unmodified lines | |||
| 261 | @echo ------------ $@ ------------ | 261 | @echo ------------ $@ ------------ |
| 262 | ./vla_test$(EXESUF) | 262 | ./vla_test$(EXESUF) |
| 263 | 263 | ||
| 264 | .PHONY: abitest vla_test | ||
| 265 | |||
| 264 | asm-c-connect$(EXESUF): asm-c-connect-1.c asm-c-connect-2.c | 266 | asm-c-connect$(EXESUF): asm-c-connect-1.c asm-c-connect-2.c |
| 265 | $(TCC) -o $@ $^ | 267 | $(TCC) -o $@ $^ |
| 266 | 268 | ||
| @@ -21,14 +21,19 @@ · 20 unmodified lines | |||
| 21 | typedef __SIZE_TYPE__ uintptr_t; | 21 | typedef __SIZE_TYPE__ uintptr_t; |
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | #if defined(_WIN32) || \ | 24 | #if defined(_WIN32) \ |
| 25 | (defined(__arm__) && \ | 25 | || (defined(__arm__) \ |
| 26 | (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__))) | 26 | && (defined(__FreeBSD__) \ |
| 27 | || defined(__OpenBSD__) \ | ||
| 28 | || defined(__NetBSD__) \ | ||
| 29 | || defined __ANDROID__)) | ||
| 27 | #define LONG_LONG_FORMAT "%lld" | 30 | #define LONG_LONG_FORMAT "%lld" |
| 28 | #define ULONG_LONG_FORMAT "%llu" | 31 | #define ULONG_LONG_FORMAT "%llu" |
| 32 | #define XLONG_LONG_FORMAT "%llx" | ||
| 29 | #else | 33 | #else |
| 30 | #define LONG_LONG_FORMAT "%Ld" | 34 | #define LONG_LONG_FORMAT "%Ld" |
| 31 | #define ULONG_LONG_FORMAT "%Lu" | 35 | #define ULONG_LONG_FORMAT "%Lu" |
| 36 | #define XLONG_LONG_FORMAT "%Lx" | ||
| 32 | #endif | 37 | #endif |
| 33 | 38 | ||
| 34 | // MinGW has 80-bit rather than 64-bit long double which isn't compatible with TCC or MSVC | 39 | // MinGW has 80-bit rather than 64-bit long double which isn't compatible with TCC or MSVC |
| @@ -2265,7 +2270,7 @@ double ftab1[3] = { 1.2, 3.4, -5.6 }; · 2230 unmodified lines | |||
| 2265 | 2270 | ||
| 2266 | void float_test(void) | 2271 | void float_test(void) |
| 2267 | { | 2272 | { |
| 2268 | #if !defined(__arm__) || defined(__ARM_PCS_VFP) | 2273 | #if !defined(__arm__) || defined(__ARM_PCS_VFP) || defined __ANDROID__ |
| 2269 | volatile float fa, fb; | 2274 | volatile float fa, fb; |
| 2270 | volatile double da, db; | 2275 | volatile double da, db; |
| 2271 | int a; | 2276 | int a; |
| @@ -2531,7 +2536,7 @@ void longlong_test(void) · 259 unmodified lines | |||
| 2531 | b = 0x12345678; | 2536 | b = 0x12345678; |
| 2532 | a = -1; | 2537 | a = -1; |
| 2533 | c = a + b; | 2538 | c = a + b; |
| 2534 | printf("%Lx\n", c); | 2539 | printf(XLONG_LONG_FORMAT"\n", c); |
| 2535 | #endif | 2540 | #endif |
| 2536 | 2541 | ||
| 2537 | /* long long reg spill test */ | 2542 | /* long long reg spill test */ |
| @@ -9,7 +9,7 @@ TESTS = $(patsubst %.c,%.test,\ · 8 unmodified lines | |||
| 9 | 9 | ||
| 10 | # some tests do not pass on all platforms, remove them for now | 10 | # some tests do not pass on all platforms, remove them for now |
| 11 | SKIP = 34_array_assignment.test # array assignment is not in C standard | 11 | SKIP = 34_array_assignment.test # array assignment is not in C standard |
| 12 | ifeq ($(CONFIG_arm_eabi),yes) # not ARM soft-float | 12 | ifeq (-$(CONFIG_arm_eabi)-$(CONFIG_arm_vfp)-,-yes--) |
| 13 | SKIP += 22_floating_point.test | 13 | SKIP += 22_floating_point.test |
| 14 | endif | 14 | endif |
| 15 | ifdef CONFIG_OSX | 15 | ifdef CONFIG_OSX |
| @@ -27,12 +27,12 @@ ifeq (,$(filter i386 x86_64,$(ARCH))) · 11 unmodified lines | |||
| 27 | SKIP += 125_atomic_misc.test # currently only x86 supported | 27 | SKIP += 125_atomic_misc.test # currently only x86 supported |
| 28 | endif | 28 | endif |
| 29 | ifeq ($(CONFIG_backtrace),no) | 29 | ifeq ($(CONFIG_backtrace),no) |
| 30 | SKIP += 112_backtrace.test | ||
| 31 | SKIP += 113_btdll.test | 30 | SKIP += 113_btdll.test |
| 32 | CONFIG_bcheck = no | 31 | CONFIG_bcheck = no |
| 33 | # no bcheck without backtrace | 32 | # no bcheck without backtrace |
| 34 | endif | 33 | endif |
| 35 | ifeq ($(CONFIG_bcheck),no) | 34 | ifeq ($(CONFIG_bcheck),no) |
| 35 | SKIP += 112_backtrace.test | ||
| 36 | SKIP += 114_bound_signal.test | 36 | SKIP += 114_bound_signal.test |
| 37 | SKIP += 115_bound_setjmp.test | 37 | SKIP += 115_bound_setjmp.test |
| 38 | SKIP += 116_bound_setjmp2.test | 38 | SKIP += 116_bound_setjmp2.test |