opnsense / ports

OPNsense ports on top of FreeBSD
https://opnsense.org/
Other
157 stars 112 forks source link

libunwind-20211201 build failure on aarch64 #143

Closed turboproc closed 2 years ago

turboproc commented 2 years ago

Trying to build OPNSense on an aarch64 architecture (native build on a Rock PI 4, RK3399), the build of ruby-27 and puppet7-7.14 fails because the build of libunwind-1.6.2 fails. Details below:

libtool: compile:  cc -DHAVE_CONFIG_H -I. -I../include -I../include -I../include/tdep-aarch64 -I. -D_GNU_SOURCE -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -MT mi/strerror.lo -MD -MP -MF mi/.deps/strerror.Tpo -c mi/strerror.c  -fPIC -DPIC -o mi/.libs/strerror.o
--- mi/backtrace.lo ---
mi/backtrace.c:71:7: error: no member named 'regs' in 'struct __mcontext'
      unw_getcontext (&uc);
      ^~~~~~~~~~~~~~~~~~~~
../include/libunwind-common.h:127:29: note: expanded from macro 'unw_getcontext'
#define unw_getcontext(uc)              unw_tdep_getcontext(uc)
                                        ^~~~~~~~~~~~~~~~~~~~~~~
../include/libunwind-aarch64.h:237:79: note: expanded from macro 'unw_tdep_getcontext'
  register uint64_t unw_base __asm__ ("x0") = (uint64_t) unw_ctx->uc_mcontext.regs; \
                                                         ~~~~~~~~~~~~~~~~~~~~ ^
1 error generated.
*** [mi/backtrace.lo] Error code 1

make[5]: stopped in /usr/obj/usr/ports/devel/libunwind/work/libunwind-1.6.2/src
--- mi/init.lo ---
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I../include -I../include -I../include/tdep-aarch64 -I. -D_GNU_SOURCE -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -MT mi/init.lo -MD -MP -MF mi/.deps/init.Tpo -c mi/init.c -o mi/init.o >/dev/null 2>&1
--- mi/mempool.lo ---
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I../include -I../include -I../include/tdep-aarch64 -I. -D_GNU_SOURCE -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -MT mi/mempool.lo -MD -MP -MF mi/.deps/mempool.Tpo -c mi/mempool.c -o mi/mempool.o >/dev/null 2>&1
--- mi/strerror.lo ---
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I../include -I../include -I../include/tdep-aarch64 -I. -D_GNU_SOURCE -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -MT mi/strerror.lo -MD -MP -MF mi/.deps/strerror.Tpo -c mi/strerror.c -o mi/strerror.o >/dev/null 2>&1
--- mi/flush_cache.lo ---
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I../include -I../include -I../include/tdep-aarch64 -I. -D_GNU_SOURCE -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -MT mi/flush_cache.lo -MD -MP -MF mi/.deps/flush_cache.Tpo -c mi/flush_cache.c -o mi/flush_cache.o >/dev/null 2>&1
--- os-freebsd.lo ---
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I../include -I../include -I../include/tdep-aarch64 -I. -D_GNU_SOURCE -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -MT os-freebsd.lo -MD -MP -MF .deps/os-freebsd.Tpo -c os-freebsd.c -o os-freebsd.o >/dev/null 2>&1
1 error

make[5]: stopped in /usr/obj/usr/ports/devel/libunwind/work/libunwind-1.6.2/src

make[4]: stopped in /usr/obj/usr/ports/devel/libunwind/work/libunwind-1.6.2/src

make[3]: stopped in /usr/obj/usr/ports/devel/libunwind/work/libunwind-1.6.2
[20220315025913] ===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/devel/libunwind
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/lang/ruby27
*** Error code 1

Stop.

Any clue on what might be happening?

fichtner commented 2 years ago

https://lists.freebsd.org/archives/freebsd-ports/2022-March/001571.html https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262257

turboproc commented 2 years ago

@fichtner looks like this is the same as the first of above links. Did also a manual build of libunwind master https://github.com/libunwind/libunwind/commit/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80 and that seems to run fine. Didn't check all the details but guess that https://github.com/libunwind/libunwind/commit/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80 fixed it.

So question is how do we get this in the OPNSense build.

fichtner commented 2 years ago

FreeBSD ports maintainer has to include it first. Lately ports submissions and committer activity have declined...

turboproc commented 2 years ago

@fichtner , as building in FreeBSD is a kind of new, I solved it for now by creating a small patch file /usr/ports/devel/libunwind/files/patch-include-libunwind-aarch64.h with the following content. This makes sure the commit mentioned above is patched into release 1.6.2.

--- ./include/libunwind-aarch64.h.orig
+++ ./include/libunwind-aarch64.h
@@ -183,7 +183,7 @@ typedef struct unw_tdep_save_loc
   }
 unw_tdep_save_loc_t;

-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
 /* On AArch64, we can directly use ucontext_t as the unwind context,
  * however, the __reserved struct is quite large: tune it down to only
  * the necessary used fields.  */

With a succesful build of libunwind, ruby, haproxy and puppet will build as well.

turboproc commented 2 years ago

@fichtner can confirm that https://github.com/opnsense/ports/commit/c426581358f90ccec75b04574711f0c6dbb19edf solves the issue. Libunwind building fine now on aarch64. Thnx.

fichtner commented 2 years ago

Great, closing then. 😊