pkg not building on FreeBSD 8

I was building the new pkg port in a jail on FreeBSD and it would not compile.

If you are getting the following error when trying to build pkg (pkgng) on FreeBSD then likely you need to upgrade to at least FreeBSD version 8.3.

sqlite3.c:23531: error: 'posix_fallocate' undeclared here (not in a function)

I am not sure why but Posix FALLOCATE was probably not yet available on 8.2 or at least did not work properly.

I upgraded my src repo to releng8.3 and rebuilt world and then it worked (although I had another issue because of optimization, which we will come back to).

If upgrading is not an option then you can go into the sqlite Makefile in the work/pkg-1.1.2/external/sqlite/ directory.
Delete the line that says:

-DHAVE_POSIX_FALLOCATE=1

if it is the last line in a series of options make sure you don’t have a trailing \ on the previous line so:

-DHAVE_STRERROR_R=1 \
-DHAVE_POSIX_FALLOCATE=1

should become

-DHAVE_STRERROR_R=1

then

make

in that directory.

Then go back:

cd ../../../..

make

Which should work fine and you should be able to make install. Now onto the next issue I had which was because I have optimizations enabled in make.conf for ports…

After getting past the error above I now have this error:

pkg_repo.c: In function 'read_pkg_file':
pkg_repo.c:408: warning: 'fts_info' may be used uninitialized in this function
pkg_repo.c:407: warning: 'st_size' may be used uninitialized in this function

Well in that case disable anything past just -O level optimization for this particular port.

If you have something like:

.if ${.CURDIR:M*/usr/ports*}
CFLAGS=-Os -march=k6-3 -pipe -fomit-frame-pointer
CXXFLAGS=-Os -march=k6-3 -pipe -fomit-frame-pointer
.endif

Then add

.if ${.CURDIR:M*/usr/ports/ports-mgmt/pkg*}
CFLAGS=-O -march=k6-3 -pipe -fomit-frame-pointer -fno-strict-aliasing
.endif

after it. Notice the -O with no number or “s”.

Generally you shouldn’t set CFLAGS or CXXFLAGS across the board in make.conf. The only reason I am doing it is because I am compiling for an embedded machine with limited RAM and flash drive space. This very often causes compilation errors on FreeBSD so always be prepared for that.

 

 

References:

I found the tip to remove the FALLOCATE line from the sqlite Makefile here:
http://nhh.mo-blog.jp/ttt/2013/05/freebsd_portsda.html (Japanese language)

One thought on “pkg not building on FreeBSD 8

Leave a Reply

Your email address will not be published. Required fields are marked *


5 − 4 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>