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:


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


should become




in that directory.

Then go back:

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


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

Then add

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

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.




I found the tip to remove the FALLOCATE line from the sqlite Makefile here: (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 *

To see if you are a human *

This site uses Akismet to reduce spam. Learn how your comment data is processed.