gozfree / gear-lib

Gear-Lib, C library for IOT Embedded Multimedia and Network
MIT License
2.97k stars 805 forks source link

hisi35xx cross platform compiling failed [-Werror=strict-aliasing] #66

Closed ausk closed 2 years ago

ausk commented 3 years ago

Hi I'm compiling the gear-lib using hisi-toolchain。 modify build/pi.inc config to CROSS_PREFIX=aarch64-himix200-linux- Then ./build.sh all pi release

Error occurs:

==== clean hisi libipc done.
==== build hisi libposix done.
==== build hisi libtime done.
==== build hisi liblog done.
libserializer.c: In function 's_wlf':
libserializer.c:172:5: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     s_wl32(s, *(uint32_t *)&f);
     ^~~~~~
libserializer.c: In function 's_wld':
libserializer.c:177:5: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     s_wl64(s, *(uint64_t *)&d);
     ^~~~~~
libserializer.c: In function 's_wbf':
libserializer.c:206:5: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     s_wb32(s, *(uint32_t *)&f);
     ^~~~~~
libserializer.c: In function 's_wbd':
libserializer.c:211:5: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     s_wb64(s, *(uint64_t *)&d);
     ^~~~~~
cc1: all warnings being treated as errors
gozfree commented 3 years ago

you can try to add this cflags " -fno-strict-aliasing" diff --git a/gear-lib/libdarray/Makefile b/gear-lib/libdarray/Makefile index ef46959..b5fc2b2 100644 --- a/gear-lib/libdarray/Makefile +++ b/gear-lib/libdarray/Makefile @@ -40,7 +40,7 @@ ifeq ($(MODE), release) CFLAGS := -O2 -Wall -Werror -fPIC LTYPE := release else -CFLAGS := -g -Wall -Werror -fPIC +CFLAGS := -g -Wall -Werror -fPIC -fno-strict-aliasing

tek-life commented 2 years ago

Hi, @gozfree I am trying to cross-compile this project on X86 Ubuntu. Unfortunately, it failed. The steps list below:

  1. download the v1.1.20 tar ball. wget https://github.com/gozfree/gear-lib/archive/refs/tags/v1.1.20.tar.gz
  2. uncompress and go to the directory run: ./build.sh all pi.
~/Downloads/gear-lib/gear-lib-1.1.20$ ./build.sh all pi
==== clean pi libposix done.
==== clean pi libtime done.
==== clean pi liblog done.
==== clean pi libdarray done.
==== clean pi libthread done.
==== clean pi libgevent done.
==== clean pi libworkq done.
==== clean pi libdict done.
==== clean pi libhash done.
==== clean pi libsort done.
==== clean pi librbtree done.
==== clean pi libringbuffer done.
==== clean pi libvector done.
==== clean pi libbase64 done.
==== clean pi libmedia-io done.
==== clean pi libdebug done.
==== clean pi libfile done.
==== clean pi libconfig done.
==== clean pi libuac done.
==== clean pi libuvc done.
==== clean pi libqueue done.
==== clean pi libplugin done.
==== clean pi libhal done.
==== clean pi libsubmask done.
==== clean pi libsock done.
==== clean pi libptcp done.
==== clean pi librpc done.
==== clean pi librtsp done.
==== clean pi librtmpc done.
==== clean pi libipc done.
test_libposix.o:在函数‘foo’中:
/home/hfli/Downloads/gear-lib/gear-lib-1.1.20/gear-lib/libposix/test_libposix.c:52:对‘get_proc_name’未定义的引用
collect2: error: ld returned 1 exit status
make: *** [test_libposix] Error 1

The toolchain used is: gcc-linaro-10.2.1-2021.04-x86_64_arm-linux-gnueabih

Any suggestion for it?

Thanks.

gozfree commented 2 years ago

please update to https://github.com/gozfree/gear-lib/commit/199b9e0e11fa94f2938c709973c9be2ce2116434, and rebuild it.