There may be a linking/build issue in libgc, but I'm not sure. | #ifdef __cplusplus | extern "C" | #endif | char GC_init (); | int | main () | { | return GC_init (); | ; | return 0; | } configure:8240: result: no configure:8247: checking GC library location configure:8249: result: /usr/local configure:8255: checking /usr/local configure:8258: checking for GC_init in -lgc configure:8283: /nxb-bin/usr/bin/cc -o conftest -O2 -pipe -fno-strict-aliasing -I$(srcdir)/libwc -I/usr/include/openssl -I/usr/local/include -I/usr/local/include -L/usr/local/lib conftest.c -lgc -lm >&5 /usr/local/lib/libgc.so: undefined reference to `__stack_base__' cc: error: linker command failed with exit code 1 (use -v to see invocation) configure:8283: $? = 1 configure: failed program was:
devel/boehm-gc build log. http://tasty.ysv.freebsd.org/data/11aarch64-default/2015-06-28_18h00m31s /logs/boehm-gc-7.4.2_3.log
This is a problem with devel/boehm-gc. In include/private/gcconfig.h there is a list of architectures it supports, and within each a list of supported operating systems. We need to add FreeBSD/arm64 to this list.
(In reply to Andrew Turner from comment #2) Yeah, was looking at that, but need the maintainer or someone who knows this header file better than I. A short attempt (at least a pointer to the right locations), looks something like this: --- gcconfig.h.orig 2014-06-03 06:08:02.000000000 +0000 +++ gcconfig.h 2015-06-28 23:10:15.475514000 +0000 @@ -97,7 +97,7 @@ # endif # if defined(__aarch64__) # define AARCH64 -# if !defined(LINUX) +# if !defined(LINUX) || !defined(FREEBSD) # define NOSYS # define mach_type_known # endif @@ -402,6 +402,10 @@ # define I386 # define mach_type_known # endif +# if defined(FREEBSD) && defined(__aarch64__) +# define AARCH64 +# define mach_type_known +# endif # if defined(FREEBSD) && (defined(__amd64__) || defined(__x86_64__)) # define X86_64 # define mach_type_known @@ -1998,6 +2022,16 @@ extern char _end[]; # define DATAEND ((ptr_t)(&_end)) # endif +# ifdef FREEBSD +# define OS_TYPE "FREEBSD" +# define DYNAMIC_LOADING +# define HEURISTIC2 + extern char etext[]; + extern int __data_start[]; +# define DATASTART ((ptr_t)__data_start) + extern void *__stack_base__; +# define STACKBOTTOM ((ptr_t)__stack_base__) +# endif # ifdef NOSYS /* __data_start is usually defined in the target linker script. */ extern int __data_start[];
Created attachment 158170 [details] boehm-gc-7.4.2_4.diff Sean, Your patch was included in the PORTREVISION. Did you experience any problem?
That patch is wrong, FreeBSD doesn't define __stack_base__ for one. I had a look at it, but found issues I need to fix in base before we can get it working.
(In reply to Andrew Turner from comment #5) Yes, it should be as following: # define FREEBSD_STACKBOTTOM
Created attachment 158296 [details] patch-include_private_gcconfig.h This patch works for me (add AArch64 support to Boehm GC) But now I'm stuck at this point: cc -I. -I. -O2 -pipe -fno-strict-aliasing -I./libwc -I/usr/include/openssl -I/usr/local/include -I/usr/local/include -DHAVE_CONFIG_H -DAUXBIN_DIR=\"/usr/local/libexec/w3m\" -DCGIBIN_DIR=\"/usr/local/libexec/w3m/cgi-bin\" -DHELP_DIR=\"/usr/local/share/w3m\" -DETC_DIR=\"/usr/local/etc\" -DCONF_DIR=\"/usr/local/etc/w3m\" -DRC_DIR=\"~/.w3m\" -DLOCALEDIR=\"/usr/local/share/locale\" -o mktable mktable.o dummy.o Str.o hash.o myctype.o -L/usr/local/lib -lm -lX11 -lgc sort funcname.tab | /usr/bin/awk -f ./functable.awk > functable.tab ./mktable 100 functable.tab > functable.c *** Signal 11 Stop. make[1]: stopped in /wrkdirs/usr/ports/www/w3m/work/w3m-0.5.3 *** Error code 1
Created attachment 158297 [details] boehm-gc build log on AArch64
Created attachment 158298 [details] attempt to build w3m on AArch64
Patch was merged into mainline https://github.com/ivmai/bdwgc/commit/2282b2013a5a06b8e28225076f4b263d735676f8
The upstream change isn't enough, the tests are all failing: andrew@arm64:~/bdwgc % ./cordtest GC Warning: Out of memory - trying to allocate requested amount (8224 bytes)... Insufficient memory for GC_all_nils
(In reply to Andrew Turner from comment #11) Also we have same problem trying to build www/w3m on MIPS.
Regarding w3m, powerpc64 is also affected. But it works here if I take the threaded boehm-gc iso the default, non threaded version.
Created attachment 158394 [details] Fix for upstream git I've committed all the fixes needed on the FreeBSD side. The attached patch, against Boehm GC from git, gets the arm64 case closer to the other FreeBSD architectures. The tests pass both with and without it.
(In reply to Andrew Turner from comment #14) Did you tried to build w3m port? It fails at this point: cc -I. -I. -O2 -pipe -fno-strict-aliasing -I./libwc -I/usr/include/openssl -I/usr/local/include -I/usr/local/include -DHAVE_CONFIG_H -DAUXBIN_DIR=\"/usr/local/libexec/w3m\" -DCGIBIN_DIR=\"/usr/local/libexec/w3m/cgi-bin\" -DHELP_DIR=\"/usr/local/share/w3m\" -DETC_DIR=\"/usr/local/etc\" -DCONF_DIR=\"/usr/local/etc/w3m\" -DRC_DIR=\"~/.w3m\" -DLOCALEDIR=\"/usr/local/share/locale\" -o mktable mktable.o dummy.o Str.o hash.o myctype.o -L/usr/local/lib -lm -lX11 -lgc sort funcname.tab | /usr/bin/awk -f ./functable.awk > functable.tab ./mktable 100 functable.tab > functable.c *** Signal 11
Created attachment 158430 [details] boehm-gc-7.4.2_4.diff - Add FreeBSD/aarch64 support - Fix __alloc_size__ availability detection (Clang)
(In reply to Carlos Jacobo Puga Medina from comment #16) With that patch I can build boehm-gc and w3m on arm64.
(In reply to Andrew Turner from comment #17) Great! Patch is ready to be committed.
Created attachment 158436 [details] boehm-gc-7.4.2_4.diff
Created attachment 158437 [details] boehm-gc-7.4.2_4.diff Patch reworked including fix for undeclared identifier 'BUS_PAGE_FAULT'
Created attachment 158438 [details] boehm-gc tests log
Created attachment 158450 [details] 11aarch64-default.log It passed all tests with CFLAGS=-DNO_INCREMENTAL
I've updated the kernel in base r285268 to correctly pass the code and address of the failing data when userland tries to access invalid memory. This fixes th gctest for me as it was trying to us this data.
(In reply to Andrew Turner from comment #23) Andrew, The bdwgc issue was reopened to add more fixes for upstream: https://github.com/ivmai/bdwgc/issues/74 Add what you consider necessary.
A commit references this bug: Author: brd Date: Wed Jul 8 20:57:19 UTC 2015 New revision: 391600 URL: https://svnweb.freebsd.org/changeset/ports/391600 Log: Patch devel/boehm-gc to build on AArch64. PR: 201183 Submitted by: Carlos Jacobo Puga Medina <cpm@fbsd.es>, andrew, sbruno Approved by: bdrewery (mentor) Changes: head/devel/boehm-gc/Makefile head/devel/boehm-gc/files/patch-include_gc__config__macros.h head/devel/boehm-gc/files/patch-include_private_gc__priv.h head/devel/boehm-gc/files/patch-include_private_gcconfig.h head/devel/boehm-gc/files/patch-os__dep.c