[lttng-dev] Problems cross compiling LTTNG

public at triplanets.com public at triplanets.com
Wed Jun 16 02:49:00 EDT 2021


Hi,

 

I am having problems cross compiling LTTNG for the ARM platform.  Everything
compiles fine, except the TOOLS.

 

The error I am getting is:

 

libtool: warning: library
'/home/USER/work/LTTNG/sysroot/usr/local/lib/liburcu.la' was moved.

/bin/grep: /usr/local/lib/liburcu-common.la: No such file or directory

/bin/sed: can't read /usr/local/lib/liburcu-common.la: No such file or
directory

libtool:   error: '/usr/local/lib/liburcu-common.la' is not a valid libtool
archive

Makefile:547: recipe for target 'libhashtable.la' failed

make[3]: *** [libhashtable.la] Error 1

make[3]: Leaving directory
'/home/USER/work/LTTNG/builds/lttng-tools/src/common/hashtable'

Makefile:955: recipe for target 'all-recursive' failed

make[2]: *** [all-recursive] Error 1

make[2]: Leaving directory
'/home/USER/work/LTTNG/builds/lttng-tools/src/common'

Makefile:551: recipe for target 'all-recursive' failed

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory '/home/USER/work/LTTNG/builds/lttng-tools/src'

Makefile:661: recipe for target 'all-recursive' failed

make: *** [all-recursive] Error 1

 

It is looking for "/usr/local/lib/libiconv.la" when it should be looking for
"/home/USER/work/LTTNG/sysroot /usr/local/lib/libiconv.la" which is where
the builds are being installed.

 

In desperation I tried setting -with-sysroot in the configuration step to
the appropriate directory but it made no difference.

 

My build scripts seem okay but maybe I am missing something obvious.  I also
tried a couple of other build scripts that were on the web as examples of
cross compiling LTTNG with similar results, so I wonder if the build
environment I am using is a little "different", but I have no control over
that.

 

This is the script that I am using.  It is based on one that was posted as a
successful example of cross compiling LTTNG, and I have made some changes
for my environment.  Works well for everything except the tools.

 

All suggestions on where the problem lies are welcome.

 

#!/bin/bash

 

# set your base directory

BASEDIR=/home/USER/work/LTTNG

 

# set your system root path

SYSROOT=$BASEDIR/sysroot

 

# export symlink to the real arm gcc

export HOST=arm-cortex_a8-linux

export CC="/home/USER/bin/${HOST}-gcc"

 

# set your kernel build path (you will need to symlink the includes into
this)

G_KERNELDIR=/home/USER/work/linux/build-2605246

 

# set the support library versions to build 

LIBICONV_VERSION=1.16                                               

LIBUUID_VERSION=1.0.3

LIBXML2_VERSION=2.9.9

POPT_VERSION=1.16

ZLIB_VERSION=1.2.11

 

#######################################################

#

# YOU SHOULD NOT NEED TO ALTER ANYTHING BELOW THIS LINE

#

#######################################################

 

# change your flags here

export ac_cv_func_malloc_0_nonnull=yes

export ac_cv_func_realloc_0_nonnull=yes

 

G_PREFIX=/usr/local

 

export PKG_CONFIG_PATH=${SYSROOT}${G_PREFIX}/lib/pkgconfig

export CPPFLAGS="-I${SYSROOT}${G_PREFIX}/include"

export LDFLAGS="-L${SYSROOT}${G_PREFIX}/lib
-Wl,-rpath-link=${SYSROOT}${G_PREFIX}/lib"

export LT_SYS_LIBRARY_PATH="${SYSROOT}${G_PREFIX}/lib"

 

G_ARCH=arm

G_CROSS_COMPILE=arm-

 

# tracking download/compile steps

G_CFG_FILE="$PWD/${0%\.*}.conf"

 

# other directories

G_TARBALL_DIR=$PWD/tarballs

G_SOURCES_DIR=$PWD/sources

G_BUILD_DIR=$PWD/builds

 

# steps for tracking progress in $G_CFG_FILE

step_start=0

step_download=1

step_compile=2

 

echo

echo "This script will compile and install lttng and some deps"

echo "Building for HOST=${HOST}"

echo

echo "Builds are located in $G_BUILD_DIR"

echo "Sources are located in $G_SOURCES_DIR"

echo "Tarballs are located in $G_TARBALL_DIR"

echo "sysroot is located at ${SYSROOT}"

echo "prefix is set to $G_PREFIX"

echo

echo "press Enter to continue or CRTL-C to abort"

read

 

[ -e "$G_CFG_FILE" ] && . "$G_CFG_FILE" &> /dev/null

 

function get_src_dir()

{

    local filename="$1"

    tar -tf "$G_TARBALL_DIR/$filename"| sed -e 's@/.*@@' | uniq

}

 

function build()

{

    local filename="$1"

    local what="$2"

    local dir_name="$3"

    local state="$4"

    local do_bootstrap=$5

 

    if [ $state -eq $step_download ] ; then

 

        if $do_bootstrap ; then

            pushd $G_SOURCES_DIR/$dir_name

            ./bootstrap

            popd

        fi

 

        mkdir -p "$G_BUILD_DIR/$dir_name"       

        pushd "$G_BUILD_DIR/$dir_name"      

        if [ -n "$patch" ] ; then

            pushd "$G_SOURCES_DIR/$dir_name"        

            wget $patch -O- | patch -p1

            popd

        fi

        "$G_SOURCES_DIR/$dir_name"/configure --host=${HOST}
--prefix=${G_PREFIX} ${EXTRA_CONF} --enable-shared

        if [ -n ${COPY_MAKEFILE} ] ; then

               # this hack in necessary because the tests do not compile in
our build environment

               cp -f $BASEDIR/mtmake ${COPY_MAKEFILE}

        fi

        make -j3 \

          && make install DESTDIR=${SYSROOT} \

            && echo "$what=$step_compile" >> $G_CFG_FILE

        popd

   fi

    if [ $state -eq $step_compile ] ; then

        echo ">> $what is already compiled"

    fi

}

 

function download()

{

    local url="$1"

    local what="$2"

    local filename="$3"

    local state="$4"

 

    if [ $state -lt $step_download ] ; then

        wget "$url" -O "$G_TARBALL_DIR/$filename"

        echo "$what=$step_download" >> $G_CFG_FILE

        tar -C $G_SOURCES_DIR -xf "$G_TARBALL_DIR/$filename"

        . "$G_CFG_FILE" &> /dev/null

    fi

}

 

function download_git()

{

    local url="$1"

    local what="$2"

    local filename="$3"

    local state="$4"

 

    if [ $state -lt $step_download ] ; then

 

        pushd $G_SOURCES_DIR

        git clone $url

        popd

        echo "$what=$step_download" >> $G_CFG_FILE

        . "$G_CFG_FILE" &> /dev/null

    fi

}

 

function init()

{

    local what="$1"

    eval state=\$$what

 

    if [ ! -n "$state" ] ; then

        echo "$what=$step_start" >> $G_CFG_FILE

        . "$G_CFG_FILE" &> /dev/null

    fi

 

    eval state=\$$what

}

 

function get_em()

{

    local url="$1"

    local what="$2"

    local filename=$(basename $url) 

 

    init "$what"

    download "$url" "$what" $filename $state

    eval state=\$$what

    local dir_name=$(get_src_dir $filename)

    build $filename "$what" $dir_name $state false

}

 

function get_em_git()

{

    local url="$1"

    local what="$2"

    local do_bootstrap="$3"

    local filename=$(basename $url) 

    filename=${filename/.git}

 

    init "$what"

    download_git "$url" "$what" $filename $state

    eval state=\$$what

 

    build $filename "$what" $filename $state $do_bootstrap

}

 

echo "create directories"

mkdir -p "$G_TARBALL_DIR" "$G_SOURCES_DIR" "$G_BUILD_DIR" &>/dev/null

 

 

########################

# define the packages we want to compile

########################

 

# this are the dependencies that are missing for our sysroot

# we will compile them and install the to the ${SYSROOT}

#

# --- BEGIN --- dependencies

what=libuuid

url=http://downloads.sourceforge.net/project/libuuid/libuuid-$LIBUUID_VERSIO
N.tar.gz

get_em $url "$what"

 

what=libiconv

url=https://ftp.gnu.org/gnu/libiconv/libiconv-$LIBICONV_VERSION.tar.gz

get_em $url "$what"

unset patch

 

what=zlib

url=https://zlib.net/zlib-$ZLIB_VERSION.tar.gz

init "$what"

filename=$(basename $url)   

download "$url" "$what" $filename $state

if [ $state -eq $step_compile ] ; then

    echo ">> $what is already compiled"

else

    dir_name=$(get_src_dir $filename)

    pushd $G_SOURCES_DIR/$dir_name

    LDSHARED="$CC -shared -Wl,-soname,libz.so.1" \

    ./configure --shared --prefix="${G_PREFIX}"

    make \

      && make install prefix="${G_PREFIX}" DESTDIR=${SYSROOT} \

        && echo "$what=$step_compile" >> $G_CFG_FILE

    popd

fi

 

what=libxml2

url=ftp://xmlsoft.org/libxml2/libxml2-sources-$LIBXML2_VERSION.tar.gz

EXTRA_CONF="--without-python"

get_em $url "$what"

unset EXTRA_CONF

export libxml2_CFLAGS="-I${SYSROOT}${G_PREFIX}/include/libxml2"

export libxml2_LIBS="L${SYSROOT}${G_PREFIX}/lib -lxml2 -lpthread -lm -lz"

 

what=popt

url=ftp://anduin.linuxfromscratch.org/BLFS/svn/p/popt-$POPT_VERSION.tar.gz

get_em $url "$what"

export POPT_LIBS="-L${SYSROOT}${G_PREFIX}/lib -lpopt"

 

# --- END --- dependencies

 

 

#######################

# compile lttng related packages and install into ${SYSROOT}

what=userspace_rcu

url=git://git.lttng.org/userspace-rcu.git

get_em_git $url "$what" true

export URCU_BP_CFLAGS="-I${SYSROOT}${G_PREFIX}/include"

export URCU_BP_LIBS="-L${SYSROOT}${G_PREFIX}/lib -lurcu-common -lurcu-bp"

export URCU_CDS_CFLAGS="-I${SYSROOT}${G_PREFIX}/include"

export URCU_CDS_LIBS="-L${SYSROOT}${G_PREFIX}/lib -lurcu-common -lurcu-cds"

export URCU_CFLAGS="-I${SYSROOT}${G_PREFIX}/include/urcu"

export URCU_LIBS="-L${SYSROOT}${G_PREFIX}/lib -lurcu-common -lurcu
-lurcu-cds"

export CPPFLAGS="-I${SYSROOT}${G_PREFIX}/include
-I${SYSROOT}${G_PREFIX}/include/urcu"

 

 

 

what=lttng_ust

url=git://git.lttng.org/lttng-ust.git

EXTRA_CONF="--disable-maintainer-mode --disable-examples
--disable-man-pages"

COPY_MAKEFILE="$BASEDIR/builds/lttng-ust/tests/Makefile"

get_em_git $url "$what" true

unset COPY_MAKEFILE

unset EXTRA_CONF

export UST_LIBS="-L${SYSROOT}${G_PREFIX}/lib -llttng-ust -llttng-ust-common
-ldl"

 


# fix the paths in the la files

#for FILE in $(find ${SYSROOT}${G_PREFIX}/lib -type f -name "*.la") ; do

#             sed -i "s^-L/home/USER/work/LTTNG/sysroot/usr/local/lib
/usr/local/lib^-L/home/USER/work/LTTNG/sysroot/usr/local/lib
/home/USER/work/LTTNG/sysroot/usr/local/lib^" ${FILE}

#done

 

 

 

what=lttng_tools

url=git://git.lttng.org/lttng-tools.git

EXTRA_CONF="--disable-maintainer-mode --disable-man-pages --disable-static
--with-sessiond-bin=/mnt/sd1/modulesLTTNG/lttng/usr/local/bin/lttng-sessiond
"

COPY_MAKEFILE="${BASEDIR}/builds/lttng-tools/tests/Makefile"

get_em_git $url "$what" true              

unset COPY_MAKEFILE

unset EXTRA_CONF

 

 

 

what=lttng_modules

url=git://git.lttng.org/lttng-modules.git

init "$what"

filename=$(basename $url)   

filename=${filename/.git}

download_git "$url" "$what" $filename $state

if [ $state -eq $step_compile ] ; then

    echo ">> $what is already compiled"

else

    #dir_name=$(get_src_dir $filename)

    pushd $G_SOURCES_DIR/$filename

    make ARCH=$G_ARCH CROSS_COMPILE=$G_CROSS_COMPILE KERNELDIR=$G_KERNELDIR
-j4 \

    && make ARCH=$G_ARCH CROSS_COMPILE=$G_CROSS_COMPILE
KERNELDIR=$G_KERNELDIR INSTALL_MOD_PATH=${SYSROOT} modules_install \

        && echo "$what=$step_compile" >> $G_CFG_FILE

    popd

fi

 

echo

echo "INFO: the build progress for all packages is tracked in $G_CFG_FILE"

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.lttng.org/pipermail/lttng-dev/attachments/20210616/0a8223da/attachment-0001.htm>


More information about the lttng-dev mailing list