This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simple question about cross-compilation

Hi, I'm trying to cross-compile a program to run on arm versatile juno r2 development platform. 

The system where I'm compilling is:
Linux lfpm1993-virtual-machine 4.13.0-43-generic #48~16.04.1-Ubuntu SMP Thu May 17 12:56:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

The host where the application will be run is:
Linux localhost 4.9.51 #1 SMP PREEMPT Tue Feb 13 06:21:18 UTC 2018 aarch64

To compile I executed this command:
./configure --host=aarch64-linux-gnu --prefix=/data/data/papi --with-ffsll --with-walltimer=cycle --with-tls=__thread --with-virtualtimer=perfctr --with-perf-events --with-arch=aarch64 --with-CPU=arm

Followed up, by running:
sudo make
sudo make install

After the instalattion, the binary files were place here, /data/data/papi, as expected.

Typing ls shows:
bin include lib share

I then executed:
adb connect 146.193.56.204
adb push /data/data/papi /data/data/papi
adb shell
cd data/data/papi/bin/

Typing ls shows:
1|juno:/data/data/papi/bin # ls
papi_avail papi_decode papi_native_avail
papi_clockres papi_error_codes papi_version
papi_command_line papi_event_chooser papi_xml_event_info
papi_component_avail papi_mem_info
papi_cost papi_multiplex_cost

And this part is where I can't make it work, if I try to execute for example, papi_avail:
./papi_avail

This is the output message:
/system/bin/sh: ./papi_avail: No such file or directory

Trying with sh:
1|juno:/data/data/papi/bin # sh ./papi_avail
./papi_avail[2]: syntax error: '�1' unexpected
./papi_avail[1]: ELF��2@@H�@8: not found

So, my question is what i did wrong and how can I solve it?

Thanks, for your help:
Luís Martins






  • Hi Luís,

    This cross-compile issue looks like library compatible problem, the papi linked libc version is not compatible with the libc version run on arm versatile juno r2 development platform. 

    It seems you are running android on arm versatile juno r2, and the aarch64-linux-gnu is linaro toolchian?

    Android system use bionic c as its standard c library which is not compatible with gnu libc.

    Quick solution is to compile a static version of papi. Most of tests and benchmark tools will use this solution to run on android system.

    • Thanks Steven Miao for your reply it helped me more than you could've imagined, it made me found the anwer and get it working!

      It seems you are running android on arm versatile juno r2, and the aarch64-linux-gnu is linaro toolchian?

      Yes, it is! This are the toolchains I have currently installed:

      Quick solution is to compile a static version of papi. Most of tests and benchmark tools will use this solution to run on android system.

      The configure options I had avaiable were:



      This is the configuration commands I executed and the resulting logs:

      Fullscreen
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      lfpm1993@lfpm1993-virtual-machine:~/Desktop/papi/src$·./configure --host=aarch64-linux-gnu --prefix=/data/data/papi --with-static-lib=yes --with-shared-lib=no --with-static-tools --with-arch=aarch64 --with-CPU=arm --with-ffsll --with-walltimer=cycle --with-tls=__thread --with-virtualtimer=perfctr --with-perf-events
      checking for architecture... aarch64
      checking for OS... linux
      checking for OS version... 4.13.0-43-generic
      checking for perf_event workaround level... autodetect
      checking for if MIC should be used... no
      checking for aarch64-linux-gnu-xlc... no
      checking for aarch64-linux-gnu-icc... no
      checking for aarch64-linux-gnu-gcc... aarch64-linux-gnu-gcc
      checking whether the C compiler works... yes
      checking for C compiler default output file name... a.out
      checking for suffix of executables...·
      checking whether we are cross compiling... yes
      checking for suffix of object files... o
      checking whether we are using the GNU C compiler... yes
      checking whether aarch64-linux-gnu-gcc accepts -g... yes
      checking for aarch64-linux-gnu-gcc option to accept ISO C89... none needed
      checking for aarch64-linux-gnu-xlf... no
      checking for aarch64-linux-gnu-ifort... no
      checking for aarch64-linux-gnu-gfortran... no
      checking for aarch64-linux-gnu-f95... no
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


      Searching online I found that the solution for those errors could be the order of the flags:
      (https://stackoverflow.com/questions/35716010/no-reference-to-pthread-mutex-lock-with-lpthread-compiled)

      Messing around the Makefiles and adding -lpthreads, solved my problem.

      Thanks for all the help!
      Luís Martins





      • I will expand a little bit further the anwer.
        I asked PAPI support and Vince was kind enough to give me his input on this, I will copy/paste his reply:

        Fullscreen
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        > It mostly just looks like "-lpthread" should be in the LFLAGS for the
        > utils and it's not there for some reason.
        >
        > I will see if I can figure out what's going on.
        It looks like it's not related to cross-compile, but rather you can make
        this happen natively if you build statically and also have
        --with-pthread-mutexes set (which is the default for ARM).
        Adding -lpthread to the end of (or after) $(PAPILIB) fixes this but have
        no idea the proper way to get configure to do this for us.
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


        • Hi Luís,

          I guess if you chose to build static PAPI lib and tools, it will use pthread_lock and link to pthread lib, if you use default dynamic lib, it will use PAPI_lock() and will not link to pthread lib.

          0