PINE64
How to compile on other systems for Pine - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PINE A64(+) (https://forum.pine64.org/forumdisplay.php?fid=4)
+--- Forum: Linux on Pine A64(+) (https://forum.pine64.org/forumdisplay.php?fid=6)
+--- Thread: How to compile on other systems for Pine (/showthread.php?tid=4198)



How to compile on other systems for Pine - utdrmac - 03-07-2017

I'm somewhat familiar with the basic cmake/make/make install recipe for compiling code. The issue is that this usually results in code compiled for the architecture of the host machine (which for me is an Intel Core i7 / x86_64). Compiling code on this machine is lightspeed faster than compiling directly on the Pine.

Are there (I'm sure there are) flags/switches/make-file changes I can make/use when compiling on my desktop so that the resulting binaries will work on the Pine?

I tried this just now "cmake . -DCFLAGS='-maarch64' -DCXXFLAGS='maarch64'" but I didn't see any messages about the architecture changing. I'm waiting for the compile to finish.

Thanks!


RE: How to compile on other systems for Pine - xalius - 03-07-2017

Usually you set CROSS_COMPILE=/path/to/toolchain/<prefix> make xyz

Code:
CROSS_COMPILE=/opt/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- ARCH=arm64 make -j9 Image

For example to cross compile a kernel... if you use autotools and ./configure script there are also more options you can set like --target= or --toolchain=, but that depends on the source


RE: How to compile on other systems for Pine - utdrmac - 03-08-2017

Running into blocker after installing aarch-* tools onto my Ubuntu desktop:

Code:
drmac@drmac-ubuntu:~$ sudo apt-get install gcc-4.8-aarch64-linux-gnu-base
...
drmac@drmac-ubuntu:~/percona-xtradb-cluster$ cmake . ... \
  -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc-4.8 -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-cpp-4.8
...
(cmake fails)
...
  The C++ compiler "/usr/bin/aarch64-linux-gnu-cpp-4.8" is not able to compile a simple test program
...
drmac@drmac-ubuntu:~/percona-xtradb-cluster$ aarch64-linux-gnu-cpp-4.8 -c
aarch64-linux-gnu-cpp-4.8: fatal error: ‘-c’ is not a valid option to the preprocessor
compilation terminated.
drmac@drmac-ubuntu:~/percona-xtradb-cluster$ aarch64-linux-gnu-cpp-4.8 -S
aarch64-linux-gnu-cpp-4.8: fatal error: ‘-S’ is not a valid option to the preprocessor
compilation terminated.
drmac@drmac-ubuntu:~/percona-xtradb-cluster$ aarch64-linux-gnu-cpp-4.8 -E
^C
drmac@drmac-ubuntu:~/percona-xtradb-cluster$
drmac@drmac-ubuntu:~/percona-xtradb-cluster$ aarch64-linux-gnu-cpp-4.8 --help | grep assemble
 -Wa,<options>            Pass comma-separated <options> on to the assembler
 -Xassembler <arg>        Pass <arg> on to the assembler
 -E                       Preprocess only; do not compile, assemble or link
 -S                       Compile only; do not assemble or link
 -c                       Compile and assemble, but do not link
                          Permissible languages include: c c++ assembler none



RE: How to compile on other systems for Pine - xalius - 03-08-2017

Failing tests are a common problem while cross-compiling since the tests usually try to run their output on the host platform which of course fails if they are aarch64 binaries. I spent a lot of time fixing autotools based projects but I can't really help you with cmake... did you have a look at https://cmake.org/Wiki/CMake_Cross_Compiling?

https://cmake.org/Wiki/CMake_Cross_Compiling#System_introspection deals with your problem