FreeBSD and BeagleBone

Jeroen Hofstee freebsd_arm at myspectrum.nl
Mon Jan 30 00:07:25 UTC 2012


Hi Tim,

On 01/21/12 07:34, Tim Kientzle wrote:
> To actually get it to build, I've had to make two changes to U-Boot sources:
>     * In config.mk, remove "-nostdinc" from CPPFLAGS
>     * In Makefile, add /usr/arm-freebsd/usr/lib/libc.a to PLATFORM_LIBS
>
> The first fixes missing stddef.h, stdarg.h headers.  (I'm not
> sure why the -nostdinc works on Linux.)
First of all, the standard c calls are excluded by u-boot on purpose since
these might call the operating system which is not there yet...
However some macro's, typedefs etc from the headers are of interest (like
stdargs, types etc etc). Das U-boot resolves this by including

gcc -print-file-name=include

(when really needed?) The FreeBSD bootstrap gcc is simply too old to 
support
this command, hence the missing includes. I don't know a workaround for it.

> The second is needed to resolve __umodsi3, __udivsi3, etc,
> functions.  (These might be defined in libgcc on Linux, and
> there's some logic here to try to locate libgcc.)
I don't know the exact reason for this:
- it could be as you suggested, it is in a different lib with GNU libc
- or it could be that the FreeBSD bootstrap loader removes it on 
purpose, for
   the same reason as u-boot excludes it. FreeBSD provides libc.a afaik, 
it might
   therefore exclude it from linking against it from the gcc intended to 
build
   the kernel.

But as with the includes, only use it to statically link to function which don't use
system calls..

Hope this clears things up a bit,

Regards,
Jeroen

patch closer to the GNU/Linux build

diff --git a/Makefile b/Makefile

index 36246b6..1ec3de3 100644
--- a/Makefile
+++ b/Makefile
@@ -326,7 +326,7 @@ else
  PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
  endif
  else
-PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) 
-print-libgcc-file-name`) -lgcc
+PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) 
-print-libgcc-file-name`) -lgcc -lc
  endif
  PLATFORM_LIBS += $(PLATFORM_LIBGCC)
  export PLATFORM_LIBS
diff --git a/config.mk b/config.mk
index ddaa477..d6fef21 100644
--- a/config.mk
+++ b/config.mk
@@ -183,7 +183,8 @@ OPTFLAGS= -Os #-fomit-frame-pointer

  OBJCFLAGS += --gap-fill=0xff

-gccincdir := $(shell $(CC) -print-file-name=include)
+# FreeBSD xdev compiler is too old to report include dir.. hardcode instead
+gccincdir := "/usr/arm-freebsd/usr/include"

  CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)                \
         -D__KERNEL__



More information about the freebsd-arm mailing list