upgrading coreutils results in posix_fadvise errors

I'm trying to upgrade the ports tree on an old system but I am getting an error upgrading coreutils. I am unsure how to proceed. Any helpful suggestions would be welcome.


Code:
FreeBSD hammer 8.3-RELEASE-p3 FreeBSD 8.3-RELEASE-p3 #0: Mon Jun 11 23:52:38 UTC 2012     root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386


# /usr/ports/sysutils/coreutils]# make

Code:
===>  Building for coreutils-8.20_2
gmake  all-recursive
gmake[1]: Entering directory `/usr/ports/sysutils/coreutils/work/coreutils-8.20'
Making all in po
gmake[2]: Entering directory `/usr/ports/sysutils/coreutils/work/coreutils-8.20/po'
gmake[2]: Leaving directory `/usr/ports/sysutils/coreutils/work/coreutils-8.20/po'
Making all in .
gmake[2]: Entering directory `/usr/ports/sysutils/coreutils/work/coreutils-8.20'
  CC     lib/fadvise.o
In file included from lib/fadvise.c:18:
lib/fadvise.h:46: error: 'POSIX_FADV_NORMAL' undeclared here (not in a function)
lib/fadvise.h:47: error: 'POSIX_FADV_SEQUENTIAL' undeclared here (not in a function)
lib/fadvise.h:48: error: 'POSIX_FADV_NOREUSE' undeclared here (not in a function)
lib/fadvise.h:49: error: 'POSIX_FADV_DONTNEED' undeclared here (not in a function)
lib/fadvise.h:50: error: 'POSIX_FADV_WILLNEED' undeclared here (not in a function)
lib/fadvise.h:51: error: 'POSIX_FADV_RANDOM' undeclared here (not in a function)
lib/fadvise.c: In function 'fdadvise':
lib/fadvise.c:28: warning: implicit declaration of function 'posix_fadvise'
gmake[2]: *** [lib/fadvise.o] Error 1
gmake[2]: Leaving directory `/usr/ports/sysutils/coreutils/work/coreutils-8.20'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/ports/sysutils/coreutils/work/coreutils-8.20'
gmake: *** [all] Error 2
*** Error code 1

Stop in /usr/ports/sysutils/coreutils.
*** Error code 1

Stop in /usr/ports/sysutils/coreutils.
 
Well I'm no FreeBSD expert, so I "googled" your problem to "confirm" my suspicions: http://lists.freebsd.org/pipermail/freebsd-stable/2012-January/065475.html.

My initial hunch is your ports tree isn't up to date, or you were playing with a custom compiler (or the CFLAGS in the /etc/make.conf).

1) If your ports tree isn't up to date, try portsnap(8)(), or some other method revolving around devel/subversion. If you're unsure how to do that, check out: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html.

2) If you've been playing with the compiler, try using the default settings. If you play with those things, be prepared to accept the consequences.

So, to solve your problem, you may wanna try using ports-mgmt/portupgrade or ports-mgmt/portmaster and recompile it along with all dependencies. So, if I were you, I'd try:

Code:
# portsnap fetch update
# portupgrade -N -f -r coreutils

Hope this helps ;)
 
Sorry, I always mix the '-r' and '-R' flags :P

The portupgrade command should look like this: # portupgrade -N -f -R coreutils.
 
Thanks for the suggestion. I haven't played with custom compiler settings but there does seem to be a problem with the ports tree. Why would portupgrade try and install an older version (coreutils-8.20_1) than what manually running make would install (coreutils-8.20_2)?

# /usr/ports/sysutils/coreutils]# make
Code:
===>  Building for coreutils-8.20_2

# /usr/ports/sysutils/coreutils]# make
Code:
** Found already installed package(s) of 'sysutils/coreutils': coreutils-8.20_1

I try running ports-mgmt/portmaster and see what happens.
 
The previous post was made in error.

# portupgrade -N -f -R coreutils
Code:
** Found already installed package(s) of 'sysutils/coreutils': coreutils-8.20_1
 
Well, to begin with, you should check portupgrade(1), or type in the terminal

Code:
$ man portupgrade

To exit that page, press 'q'. You can do that for almost any program, ($ man some_program_name). There you can see what those flags I suggested do for you. And you see, '-N' is used only to install new things (so if coreutils is already present, portupgrade won't budge), in which case you should run this command:

# portupgrade -f -R coreutils

Also, make sure, you run # portsnap fetch update before running the portupgrade, or all will be for naught!

And also (even if what you did was successful) read portupgrade(1) and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html thorougly, to understand what you're actually doing.
 
jozze said:
Also, make sure, you run # portsnap fetch update before running the portupgrade, or all will be for naught!
Also, check the contents of the file /usr/ports/UPDATING before doing any updating.
 
Thank you all for your suggestions.

Yes I have already run # portsnap fetch update. Also I have checked /usr/ports/UPDATING but there seems to be no mention of coreutils or posix_fadvise. Yes I should have double checked the flags before running commands I find online. I will try # portupgrade -f -R coreutils and see what happens.
 
Unfortunately the error persists.

# portupgrade -f -R coreutils

Code:
In file included from lib/fadvise.c:18:
lib/fadvise.h:46: error: 'POSIX_FADV_NORMAL' undeclared here (not in a function)
lib/fadvise.h:47: error: 'POSIX_FADV_SEQUENTIAL' undeclared here (not in a function)
lib/fadvise.h:48: error: 'POSIX_FADV_NOREUSE' undeclared here (not in a function)
lib/fadvise.h:49: error: 'POSIX_FADV_DONTNEED' undeclared here (not in a function)
lib/fadvise.h:50: error: 'POSIX_FADV_WILLNEED' undeclared here (not in a function)
lib/fadvise.h:51: error: 'POSIX_FADV_RANDOM' undeclared here (not in a function)
lib/fadvise.c: In function 'fdadvise':
lib/fadvise.c:28: warning: implicit declaration of function 'posix_fadvise'
gmake[2]: *** [lib/fadvise.o] Error 1
gmake[2]: Leaving directory `/usr/ports/sysutils/coreutils/work/coreutils-8.20'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/ports/sysutils/coreutils/work/coreutils-8.20'
gmake: *** [all] Error 2
*** Error code 1

Stop in /usr/ports/sysutils/coreutils.
*** Error code 1

Stop in /usr/ports/sysutils/coreutils.
** Command failed [exit code 1]: /usr/bin/script -qa /tmp/portupgrade20130420-79862-cb76up-0 env UPGRADE_TOOL=portupgrade UPGRADE_PORT=coreutils-8.20_1 UPGRADE_PORT_VER=8.20_1 make
** Fix the problem and try again.
** Listing the failed packages (-:ignored / *:skipped / !:failed)
        ! sysutils/coreutils (coreutils-8.20_1) (unknown build error)
 
Hmmm ... now that is weird. Not only it tried to rebuild the old version, but the error persists.

I have checked the source code, and that part of code is only executed if you have this POSIX thing enabled. However, it's not read from the make config flags (I checked for this and for the depenencies) so I guess it's read from your shell variables, but I'm not sure.

Could you show your environment table?
 
Another thing you could try is # portupgrade -f -R -C coreutils, wait for perl configuration flags to pop up, and make sure you have 'THREADS' and 'PTHREAD' disabled, because

1) PTHREAD means POSIX threads, and maybe that's what's wrong,
2) THREADS on i386 machine might not be such a good idea to begin with.

I think you can have threading support on single-core CPUs, but I am not sure. For starters, disable just PTHREAD and if this doesn't solve the problem, try unchecking THREADS as well.
 
# env

Code:
TERM=screen
SHELL=/usr/local/bin/bash
SSH_CLIENT=
SSH_TTY=/dev/pts/0
USER=user
ENV=/home/user/.shrc
TERMCAP=SC|screen|VT 100/ANSI X3.64 virtual terminal:\
        :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:bs:bt=\E[Z:\
        :cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:\
        :do=^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:\
        :le=^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:\
        :li#48:co#128:am:xn:xv:LP:sr=\EM:al=\E[L:AL=\E[%dL:\
        :cs=\E[%i%d;%dr:dl=\E[M:DL=\E[%dM:dc=\E[P:DC=\E[%dP:\
        :im=\E[4h:ei=\E[4l:mi:IC=\E[%d@:ks=\E[?1h\E=:\
        :ke=\E[?1l\E>:vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l:\
        :ti=\E[?1049h:te=\E[?1049l:us=\E[4m:ue=\E[24m:so=\E[3m:\
        :se=\E[23m:md=\E[1m:mr=\E[7m:me=\E[m:ms:\
        :Co#8:pa#64:AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:AX:G0:\
        :as=\E(0:ae=\E(B:\
        :ac=\140\140aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00:\
        :k0=\E[10~:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:\
        :k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:\
        :F1=\E[23~:F2=\E[24~:kb=^H:kh=\E[1~:@1=\E[1~:kH=\E[4~:\
        :@7=\E[4~:kN=\E[6~:kP=\E[5~:kI=\E[2~:kD=\E[3~:ku=\EOA:\
        :kd=\EOB:kr=\EOC:kl=\EOD:km:
PAGER=more
FTP_PASSIVE_MODE=YES
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/user/bin
MAIL=/var/mail/user
STY=2545.update
BLOCKSIZE=K
INPUTRC=/usr/local/etc/inputrc
PWD=/usr/ports/sysutils/coreutils
EDITOR=vi
SHLVL=3
HOME=/root
LOGNAME=user
WINDOW=0
SSH_CONNECTION=
_=/usr/bin/env
OLDPWD=/usr/local/etc
 
OK, so it's not from your shell environment, there is no such option in the /usr/ports/KNOBS, so my guess is, it would have to be from one of dependencies -- perl. Try rebuilding perl, like I said before, without the threading support, and tell me if it helps.
 
I ran # portupgrade -f -R -C coreutils and 'PTHREADS' were enabled for perl. I turned off 'PTHREADS' but the problem persists.

The options currently enabled for Perl are 'PERL_MALLOC', 'PERL_64BITINT', 'USE_PERL'
 
OK, I checked the sources again. It says, if you have function posix_fadvise(), then that thing will enable itself. Manpages say FreeBSD has it there, so posix_fadvise(2) gives some results.

So your trouble seems to be that even though you have function posix_fadvise, the compiler doesn't see it. What's weird, is that the appropriate header *is present* in the sources (there is #include <fcntl.h> entry in the lib/fadvise.h), but for some reason it doesn't see it. Maybe this is one of those times, when you should manually link against libc (with -c).

I don't know how confident you are in your C programming skills; if you are, maybe you could play and try to debug it manually, write a patch and suggest it to the port maintainer.

I think the problem lies with either the 'ports', or the 'world'. Did you upgrade to 8.3 from an older version of FreeBSD? If so, maybe it would be a good idea to retrace your steps.
 
Yes was upgrading from 8.2 to 8.3

Yes, there is an #include <fcntl.h> entry in the file lib/fadvise.h.

How would I go about manual linking? If it hoses the system I'm not too worried because I can revert the system back to a state before I starting upgrading.

I have no faith in my C programming skills. In the worst case I reinstall using a 9.1 CD.
 
I meant this: usually don't have to give the '-lc' flag to the compiler (and probably shouldn't mess with the CFLAGS, unless you're willing to take the risk), so I'd rather not (posix_f)advise that :D.

My idea is this: when you were upgrading the world, there were some problems in the libc libraray. So if I were you,

1) I'd make snapshots of my filesystems for backup, (it's really really really important you do that!)
2) try to rebuild the world.

You don't have to follow any specific branch, I think just rebuilding it for starters should do the trick; if it doesn't, maybe you cold follow the STABLE branch.

But before you do that, make sure you read enough documentation. It does sound intimidating at first, but once you go through with it, you'll see it's not that bad ;)
 
Back
Top