mirror of
https://github.com/frida/tinycc
synced 2024-12-24 22:16:49 +03:00
Another attempt to "detect" multiarch
This commit is contained in:
parent
062efe6ab8
commit
b1a8233562
22
configure
vendored
22
configure
vendored
@ -296,7 +296,13 @@ if test -z "$cross_prefix" ; then
|
||||
gcc_major="$($CONFTEST version)"
|
||||
gcc_minor="$($CONFTEST minor)"
|
||||
if test "$mingw32" = "no" ; then
|
||||
libc_dir="$(ldd $CONFTEST | grep libc.so | sed 's|[^/]*/\(.*/\)[^/]*|\1|')"
|
||||
triplet="$($CONFTEST triplet)"
|
||||
if test -f "/usr/lib/$triplet/crti.o" ; then
|
||||
tcc_lddir="lib/$triplet"
|
||||
multiarch_triplet="$triplet"
|
||||
elif test -f "usr/lib64/crti.o" ; then
|
||||
tcc_lddir="lib64"
|
||||
fi
|
||||
|
||||
# gr: FIXME
|
||||
# ldd $CONFTEST gives (ubuntu 8)
|
||||
@ -306,13 +312,13 @@ if test -z "$cross_prefix" ; then
|
||||
# result is crap:
|
||||
# CONFIG_LDDIR="lib/tls/i686/cmov"
|
||||
# CONFIG_MUADIR="tls/i686/cmov"
|
||||
|
||||
multiarch_triplet=${libc_dir#*/}
|
||||
multiarch_triplet=${multiarch_triplet%/}
|
||||
tcc_lddir="${libc_dir%%/*}"
|
||||
if test -n "$multiarch_triplet" ; then
|
||||
tcc_lddir="$tcc_lddir/$multiarch_triplet"
|
||||
fi
|
||||
#
|
||||
# multiarch_triplet=${libc_dir#*/}
|
||||
# multiarch_triplet=${multiarch_triplet%/}
|
||||
# tcc_lddir="${libc_dir%%/*}"
|
||||
# if test -n "$multiarch_triplet" ; then
|
||||
# tcc_lddir="$tcc_lddir/$multiarch_triplet"
|
||||
# fi
|
||||
|
||||
# gr: maybe for after the release:
|
||||
# tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
|
||||
|
58
conftest.c
58
conftest.c
@ -1,27 +1,59 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* Define architecture */
|
||||
#if defined(__i386__)
|
||||
# define TRIPLET_ARCH "i386"
|
||||
#elif defined(__x86_64__)
|
||||
# define TRIPLET_ARCH "x86_64"
|
||||
#elif defined(__arm__)
|
||||
# define TRIPLET_ARCH "arm"
|
||||
#else
|
||||
# define TRIPLET_ARCH "unknown"
|
||||
#endif
|
||||
|
||||
/* Define OS */
|
||||
#if defined (__linux__)
|
||||
# define TRIPLET_OS "linux"
|
||||
#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
|
||||
# define TRIPLET_OS "kfreebsd"
|
||||
#elif !defined (__GNU__)
|
||||
# define TRIPLET_OS "unknown"
|
||||
#endif
|
||||
|
||||
/* Define calling convention and ABI */
|
||||
#define TRIPLET_ABI "gnu"
|
||||
|
||||
#ifdef __GNU__
|
||||
# define TRIPLET TRIPLET_ARCH "-" TRIPLET_ABI
|
||||
#else
|
||||
# define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
switch(argc == 2 ? argv[1][0] : 0) {
|
||||
#ifdef __GNUC__
|
||||
case 'v':
|
||||
printf("%d\n", __GNUC__);
|
||||
break;
|
||||
case 'm':
|
||||
printf("%d\n", __GNUC_MINOR__);
|
||||
break;
|
||||
#else
|
||||
case 'v':
|
||||
case 'm':
|
||||
puts("0");
|
||||
break;
|
||||
#endif
|
||||
case 'b':
|
||||
{
|
||||
volatile unsigned foo = 0x01234567;
|
||||
puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes");
|
||||
break;
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
case 'm':
|
||||
printf("%d\n", __GNUC_MINOR__);
|
||||
break;
|
||||
case 'v':
|
||||
printf("%d\n", __GNUC__);
|
||||
break;
|
||||
#else
|
||||
case 'm':
|
||||
case 'v':
|
||||
puts("0");
|
||||
break;
|
||||
#endif
|
||||
case 't':
|
||||
puts(TRIPLET);
|
||||
break;
|
||||
case -1:
|
||||
/* to test -Wno-unused-result */
|
||||
fread(NULL, 1, 1, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user