c - gcc plugins with arm64 cross compiler : cannot open shared object file -
i trying compute sizes of each struct @ compile time using gcc plugin. searching, came across this article.
i tried out on test program below native x64 gcc compiler , got following results.
#include <stdio.h> struct test { int a; unsigned long b; char p[100]; }; int main(int argc, const char *argv[]) { struct test t; t.a = 10; t.a += 1; scanf("%s", t.p); scanf("%lu", &t.b); scanf("%d", &t.a); printf("%d\n", t.a); return 0; }
results :-
loaded structsizes plugin (gcc 5.4.0..) ignoring unnamed struct struct '_io_file' has incomplete type struct '_io_file' has incomplete type struct '_io_file' has incomplete type ignoring unnamed struct ignoring unnamed struct ignoring unnamed struct struct '_io_jump_t' has incomplete type struct '_io_file' has incomplete type struct '_io_marker' has incomplete type struct '_io_file' has incomplete type struct '_io_marker' has size 192 [bits] struct '_io_marker' has size 192 [bits] struct '_io_file' has incomplete type struct '_io_file' has size 1728 [bits] struct '_io_file' has size 1728 [bits] struct '_io_file_plus' has incomplete type struct '_io_file_plus' has incomplete type struct '_io_file_plus' has incomplete type struct '_io_file_plus' has incomplete type struct '_io_file' has size 1728 [bits] struct '_io_file' has size 1728 [bits] struct '_io_file' has size 1728 [bits] struct 'test' has size 960 [bits] struct 'test' has size 960 [bits]
now try same aarch64 cross compiler. version of cross compiler have :-
> aarch64-linux-gnu-gcc --version aarch64-linux-gnu-gcc (ubuntu/linaro 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609
i compile gcc plugin :-
$ aarch64-linux-gnu-gcc -g -i/usr/lib/gcc-cross/aarch64-linux-gnu/5/plugin/include -fpic -shared -o structsizes.so structsizes.cc $ file structsizes.so structsizes.so: elf 64-bit lsb shared object, arm aarch64, version 1 (sysv), dynamically linked, buildid[sha1]=64b00b52af267537f94d8c4c651f3235e7c7b722, not stripped
now, try compile test.c :-
$ aarch64-linux-gnu-gcc -fplugin=./structsizes.so -fplugin-arg-structsizes-log=/tmp/logfile -o test test.c cc1: error: cannot load plugin ./structsizes.so ./structsizes.so: cannot open shared object file: no such file or directory
why error occur? tried linaro binary toolchain downloaded , got same error. missing?
the plugin runs part of compiler, still needs built host machine, regardless of target of compiler might be. whilst it's more happy build them, x86 program cross-compiler can't use aarch64 shared object, tells you.
Comments
Post a Comment