Skip to content

Commit

Permalink
Add cross-compilation / Android support.
Browse files Browse the repository at this point in the history
1. New configure options for cross-compilation support:

    o -host=<host-type>
      The type of system on which TAU runs. This is used to
      designate the cross compiler prefix.
    o -hostutils
      Build TAU utils for <host-type>. Without this option, TAU
      utils (e.g. pprof) will be built to run on the arch / machine
      used to build TAU, i.e. don't cross compile TAU utils.

2. New valid value for `-arch': arm_android

3. And crossponding script/source code change.


Former-commit-id: b0f83f80ddae46f6bb15924132c8c3fc6fc82fc0
  • Loading branch information
Ender Dai committed Sep 20, 2013
1 parent 5a6f469 commit 6b8d167
Show file tree
Hide file tree
Showing 19 changed files with 169 additions and 80 deletions.
2 changes: 1 addition & 1 deletion Makefile.skel
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ PTHREAD_WRAPPER=src/wrappers/pthread #ENDIF##TAU_PTHREAD_WRAP#

# Subdirectories to make resursively
SUBDIR = $(TRACEINPUT) $(BASIC) $(PCXX) $(HPCXX) $(ANSIC) $(VTFCONVERTER) \
$(ELGCONVERTER) $(TRACE2PROFILE) $(IOWRAPPER) $(TAUPRELOAD) \
$(ELGCONVERTER) $(IOWRAPPER) $(TAUPRELOAD) \
$(MEMORYWRAPPER) $(TAUCUDA) $(TAU_CUPTI_AVAIL) $(TAUOPENCL) \
$(GPIWRAPPER) $(ARMCIWRAPPER) $(DMAPPWRAPPER) $(UPCWRAPPER) \
$(PTHREAD_WRAPPER) $(GOMP_WRAPPER)
Expand Down
34 changes: 34 additions & 0 deletions android.binutils-2.23.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff -u -r binutils-2.23.2/libiberty/getpagesize.c binutils-2.23.2-patched/libiberty/getpagesize.c
--- binutils-2.23.2/libiberty/getpagesize.c 2005-03-27 18:09:01.000000000 -0800
+++ binutils-2.23.2-patched/libiberty/getpagesize.c 2013-07-08 11:39:27.314956014 -0700
@@ -60,11 +60,14 @@
# endif /* PAGESIZE */
#endif /* GNU_OUR_PAGESIZE */

+/* BIONIC has getpagesize() defined in <unistd.h> */
+#ifndef __BIONIC__
int
getpagesize (void)
{
return (GNU_OUR_PAGESIZE);
}
+#endif /* __BIONIC__ */

#else /* VMS */

@@ -76,6 +79,8 @@
#endif
extern unsigned long lib$getsyi(const unsigned short *,...);

+/* BIONIC has getpagesize() defined in <unistd.h> */
+#ifndef __BIONIC__
int getpagesize (void)
{
long pagsiz = 0L;
@@ -86,5 +91,6 @@
pagsiz = 512L; /* VAX default */
return (int) pagsiz;
}
+#endif /* __BIONIC__ */

#endif /* VMS */
67 changes: 49 additions & 18 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ for arg in "$@"; do
echo " gfortran|gfortran4]"
echo "-upc=<compiler> ............................. specify the UPC compiler."
echo " options [upc|gcc(GNU UPC) |upcc (Berkeley UPC) | cc (Cray CCE UPC)"
echo "-host=<host-type>..................the type of system on which TAU runs"
echo "-hostutils..............................build TAU utils for <host-type>"
echo "-pdt=<dir> ........ Specify location of PDT (Program Database Toolkit)."
echo "-pdt_c++=<compiler> ............ specify a different PDT C++ compiler."
echo " options [CC|KCC|g++|*xlC*|cxx|pgCC|pgcpp|FCC|guidec++|aCC|c++|ecpc|"
Expand All @@ -304,7 +306,8 @@ for arg in "$@"; do
echo "-exec-prefix=<arch> .......... Specify a target architecture directory."
echo "-arch=<architecture> ................... Specify a target architecture."
echo " options [xt3|craycnl|bgp|bgq|bgl|ibm64|ibm64linux|sunx86_64"
echo " crayxmt|solaris2-64|mips32|sgin32|sgi64|sgio32]"
echo " crayxmt|solaris2-64|mips32|sgin32|sgi64|sgio32"
echo " arm_linux|arm_android]"
echo "-bfd=<dir | download> ............ Specify a BFD directory or download."
echo ""
echo "MPI Options:"
Expand Down Expand Up @@ -421,6 +424,10 @@ for arg in "$@"; do
echo " gfortran|gfortran4]"
echo "-upc=<compiler> ............................. specify the UPC compiler."
echo " options [upc|gcc(GNU UPC) |upcc (Berkeley UPC) | cc (Cray CCE UPC)"
echo "-host=<host-type>..................the type of system on which TAU runs"
echo " this is used for cross-compilation"
echo "-hostutils..............................build TAU utils for <host-type>"
echo " this is used for cross-compilation"
echo "-pdt=<dir> ........ Specify location of PDT (Program Database Toolkit)."
echo "-pdt_c++=<compiler> ............ specify a different PDT C++ compiler."
echo " options [CC|KCC|g++|*xlC*|cxx|pgCC|pgcpp|FCC|guidec++|aCC|c++|ecpc|"
Expand All @@ -433,7 +440,8 @@ for arg in "$@"; do
echo "-exec-prefix=<arch> .......... Specify a target architecture directory."
echo "-arch=<architecture> ................... Specify a target architecture."
echo " options [xt3|craycnl|bgp|bgq|bgl|ibm64|ibm64linux|sunx86_64"
echo " crayxmt|solaris2-64|mips32|sgin32|sgi64|sgio32]"
echo " crayxmt|solaris2-64|mips32|sgin32|sgi64|sgio32"
echo " arm_linux|arm_android]"
echo "-iowrapper .................................... Build POSIX IO Wrapper."
echo "-pthread .................................. Use pthread thread package."
echo "-papithread .................................. Use PAPI thread package."
Expand Down Expand Up @@ -610,7 +618,7 @@ if [ "$usingbash" = "yes" ] ; then
else
modmodargs=`echo "x$modargs" | sed -e 's/^x//' -e 's#\\\#\\\\\\\\\\\#g'`
fi
cp include/tau_config.h.default include/tau_config.h

echo "#define TAU_CONFIG \"$modmodargs\"" > include/tau_config.h

START_DIR=`pwd`
Expand Down Expand Up @@ -722,6 +730,8 @@ papiwallclock=no
papivirtual=no
use_ansic=no
tauarch=unknown
host=
host_prefix=
pdtcompdir=
pdtarchdir=unknown
tauprefix=unknown
Expand Down Expand Up @@ -809,9 +819,6 @@ cuda=no
cupti=no
strsignal_ok=no

# Reset include/Makefile before starting anything else
sed -f utils/FixMakefile.sed.default < include/Makefile.skel > include/Makefile

restore_perfdmf_and_paraprof


Expand Down Expand Up @@ -1878,6 +1885,18 @@ for arg in "$@"; do
fi
;;

-host=*)
host=`echo $arg | sed -e 's/-host=//' -e 's/ /_/g'`
host_prefix=${host}-
fixmakeargs="$fixmakeargs host=$host"
shift
;;

-hostutils)
fixmakeargs="$fixmakeargs HOSTUTILS"
shift
;;

-pdtcompdir=*)
pdtcompdir=`echo $arg | sed -e 's/-pdtcompdir=//' -e 's/ /_/g'`
shift
Expand Down Expand Up @@ -2391,16 +2410,13 @@ if [ "x$detectarch" = "x" ] ; then
fi


if [ "$tauarch" = "i386_linux" -o "$tauarch" = "i386_solaris" -o "$tauarch" = "mpis32" -o "$tauarch" = "ppc64" ]; then
if [ "$tauarch" = "i386_linux" -o "$tauarch" = "i386_solaris" -o "$tauarch" = "arm_android" -o "$tauarch" = "arm_linux" -o "$tauarch" = "mpis32" -o "$tauarch" = "ppc64" ]; then
fixmakeargs="$fixmakeargs arch_width=32bit"
else
fixmakeargs="$fixmakeargs arch_width=64bit"
fi





###############################################################
# if there are no arguments, GUESS at system configuration
if [ $tauarch = unknown -o $tauarch = none ]
Expand Down Expand Up @@ -3309,7 +3325,7 @@ case $cxx_compiler in

*g++)
echo "Default C++ compiler will be " \
`gcc -v 2>&1 | tail -1 | sed 's/gcc/g++/g'`
`$cxx_compiler -v 2>&1 | tail -1`
gnu=yes
# No fixmakeargs needed because it is the default
;;
Expand Down Expand Up @@ -3890,8 +3906,8 @@ esac
# Encode the full path of the C++/C compiler in the stub Makefile
if [ "x$full_cxx_compiler" = "x" ]
then
full_cxx_compiler=`which $cxx_compiler`
full_cc_compiler=`which $c_compiler`
full_cxx_compiler=`which $host_prefix$cxx_compiler`
full_cc_compiler=`which $host_prefix$c_compiler`
if [ $fujitsu = yes ]
then
# Fujitsu does not want full path to point to the absolute paths due to
Expand Down Expand Up @@ -4860,9 +4876,9 @@ then
then
tauoptions="${tauoptions}-gnu"
fi
taugcclibdir=`$c_compiler -print-libgcc-file-name | sed -e 's,[^/]*$,,'`
taugcclibdir=`$host_prefix$c_compiler -print-libgcc-file-name | sed -e 's,[^/]*$,,'`
echo "Using GNU lib dir as $taugcclibdir"
taugccstdcxxlibdir=`$c_compiler -print-file-name=libstdc++.a | sed -e 's,[^/]*$,,'`
taugccstdcxxlibdir=`$host_prefix$c_compiler -print-file-name=libstdc++.a | sed -e 's,[^/]*$,,'`
echo "Using GNU stdc++ lib dir as $taugccstdcxxlibdir"
fixmakeargs="$fixmakeargs taugcclibdir=$taugcclibdir taugccstdcxxlibdir=$taugccstdcxxlibdir"
fi
Expand All @@ -4879,7 +4895,7 @@ cat << EOF > gccAuditorTest.c
#endif
EOF

$c_compiler $orig_useropt -c gccAuditorTest.c 1> /dev/null 2>&1
$host_prefix$c_compiler $orig_useropt -c gccAuditorTest.c 1> /dev/null 2>&1
if [ "$?" = "1" ]
then
echo "LD AUDITOR unavailable, disabling"
Expand Down Expand Up @@ -5255,7 +5271,18 @@ case $machine in

arm_linux)
echo Found a \"$machine\" configuration definition
fixmakeargs="arch=$machine ARMLINUXPAPI $fixmakeargs"
fixmakeargs="arch=$machine $fixmakeargs"
if [ $papi = yes ] ; then
fixmakeargs="ARMLINUXPAPI $fixmakeargs"
fi
;;

arm_android)
echo Found a \"$machine\" configuration definition
fixmakeargs="arch=$machine ANDROID $fixmakeargs"
if [ $papi = yes ] ; then
fixmakeargs="ARMLINUXPAPI $fixmakeargs"
fi
;;

unknown)
Expand Down Expand Up @@ -6328,6 +6355,10 @@ if [ "x$bfd" = "xyes" -a ! "$turnbfdoff" = yes ] ; then
elif [ $machine = "rs6000" -o $machine = "ibm64" ]; then
./configure CFLAGS=-fPIC CXXFLAGS=-fPIC --prefix=$bfddir --disable-nls --disable-werror --disable-largefile
make && make install
elif [ $machine = "arm_android" ]; then
patch -p1 <$START_DIR/android.binutils-2.23.2.patch
./configure CFLAGS=-fPIC CXXFLAGS=-fPIC --prefix=$bfddir --disable-nls --disable-werror --disable-largefile --host=$host
make && make install
else
./configure CFLAGS=-fPIC CXXFLAGS=-fPIC --prefix=$bfddir --disable-nls --disable-werror
make && make install
Expand Down Expand Up @@ -6585,7 +6616,7 @@ int main() {
}
EOF
$echo "Checking for librt linkage support ... ${nnl}"
if $cxx_compiler $orig_useropt -o conftest_rt_link_test conftest_rt_link_test.cpp -lrt 1> /dev/null 2>&1 ; then
if $host_prefix$cxx_compiler $orig_useropt -o conftest_rt_link_test conftest_rt_link_test.cpp -lrt 1> /dev/null 2>&1 ; then
tau_links_rt=yes
fixmakeargs="$fixmakeargs TAU_LINKS_RT"
echo "yes"
Expand Down
24 changes: 19 additions & 5 deletions include/Makefile.skel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ TAU_CXX_FE=$(CONFIG_CXX)

TAU_CUDA_CXX=g++

# Name prefix for cross compiler. E.g. `arm-linux-gnueabi-'.
CROSS_PREFIX=#FixMakefile#

TAU_BUILD_CC=
TAU_BUILD_CXX=
# Front end C/C++ Compilers
Expand Down Expand Up @@ -64,11 +67,10 @@ TAU_BUILD_CXX=
TAU_LIBEX=lib64 #ENDIF##ARCH_WIDTH_64#



USER_OPT=-O2
EXTRADIR=
EXTRADIRCXX=
TAUROOT=/home/users/scottb/tau2
TAUROOT=#FixMakefile#
TULIPDIR=
TAUEXTRASHLIBOPTS=
TAUGCCLIBOPTS=
Expand Down Expand Up @@ -214,6 +216,16 @@ F90_ABI = $(ABI)
TAU_CC = $(CONFIG_CC) $(ABI) $(ISA)
TAU_CXX = $(CONFIG_CXX) $(ABI) $(ISA)
TAU_RUN_CC = $(FULL_CC) $(ABI) $(ISA)
BUILD_CC = $(CONFIG_CC) $(ABI) $(ISA)
HOST_CC = $(CROSS_PREFIX)$(BUILD_CC) $(ABI) $(ISA)
CC = $(HOST_CC)
BUILD_CXX = $(CONFIG_CXX) $(ABI) $(ISA)
HOST_CXX = $(CROSS_PREFIX)$(BUILD_CXX) $(ABI) $(ISA)
CXX = $(HOST_CXX)

#HOSTUTILS#TAU_CC_FE = $(CROSS_PREFIX)$(BUILD_CC) #ENDIF
#HOSTUTILS#TAU_CXX_FE = $(CROSS_PREFIX)$(BUILD_CXX) #ENDIF

#MPC#TAU_RUN_CC = mpc_cc #ENDIF#
#XLUPC#TAU_RUN_CC = xlupc $(ABI) $(ISA) #ENDIF#
#BUPC#TAU_RUN_CC = $(TAU_UPCC) #ENDIF#
Expand Down Expand Up @@ -632,6 +644,7 @@ TAU_GCCLIB = -lgcc_s
#FREEBSD#TAU_GCCLIB = -lgcc #ENDIF#
#BGL#TAU_GCCLIB = -lgcc #ENDIF#
#BGQ#TAU_GCCLIB = -lgcc #ENDIF#
#ANDROID#TAU_GCCLIB = #ENDIF#
TAU_FORTRANLIBS = -L$(TAUGCCLIBDIR) $(TAUGCCLIBOPTS) -lstdc++ $(TAU_GCCLIB) #ENDIF##GNU#
#OPEN64ORC_FORTRAN#TAU_FORTRANLIBS = -lfortran -lffio #ENDIF#
#PATHSCALE_FORTRAN#TAU_FORTRANLIBS = -lpathfstart -lpathfortran #ENDIF#
Expand Down Expand Up @@ -958,8 +971,9 @@ TAU_LINKER_OPT14=$(EXTRA_LINKER_ARGS)
# Compiler Instrumentation
##############################################

BFDLINK=-L/home/users/scottb/tau2/x86_64/binutils-2.23.2//lib -L/home/users/scottb/tau2/x86_64/binutils-2.23.2//lib64
BFDLINK=#FixMakefile#
BFDLIBS=-lbfd -liberty -lz
BFDINCLUDE=#FixMakefile#

TAU_BFDLIB=$(BFDLINK) $(BFDLIBS) #ENDIF##TAU_BFD#
TAU_COMPINST_PTHREAD_OPTIONS= -Dpthread_create=tau_pthread_create -Dpthread_exit=tau_pthread_exit#ENDIF##PTHREAD_AVAILABLE#
Expand All @@ -984,7 +998,7 @@ TAU_LINKER_OPT13=$(TAU_BFDLIB) #ENDIF##TAU_BFD#
TAU_FORTRAN_COMPINST_OPTION=$(TAU_COMPINST_OPTION)
#NAGWARE_FORTRAN#TAU_FORTRAN_COMPINST_OPTION=-Wc,-finstrument-functions#ENDIF#

TAU_LINKER_OPT16= -lrt#ENDIF##TAU_LINKS_RT#
#TAU_LINKS_RT#TAU_LINKER_OPT16= -lrt#ENDIF#

##############################################
# Various Sampling Support Options
Expand Down Expand Up @@ -1015,7 +1029,7 @@ PROFILEOPT84 = -DTAU_STRSIGNAL_OK#ENDIF##TAU_STRSIGNAL_OK#
##############################################
# DL_AUDITOR
##############################################
PROFILEOPT88 = -DTAU_TRACK_LD_LOADER #ENDIF##LD_AUDITOR_AVAILABLE#
#LD_AUDITOR_AVAILABLE#PROFILEOPT88 = -DTAU_TRACK_LD_LOADER #ENDIF#


##############################################
Expand Down
2 changes: 1 addition & 1 deletion include/Profile/TauMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

// Which platforms have pvalloc?
#ifndef HAVE_PVALLOC
#if defined(__APPLE__) || defined(TAU_XLC) || defined(TAU_WINDOWS)
#if defined(__APPLE__) || defined(TAU_XLC) || defined(TAU_WINDOWS) || defined(TAU_ANDROID)
#undef HAVE_PVALLOC
#else
#define HAVE_PVALLOC 1
Expand Down
Loading

0 comments on commit 6b8d167

Please sign in to comment.