# Python27 failed to compile after upgrade to 9.0-RELEASE-i386



## beafool (Feb 1, 2012)

I am getting undefined reference error when I try to reinstall all ports (using portupgrade) after upgrade from 8.2 to 9.0.  Remove all packages (*pkg_delete -a*) and reinstall from port tree does not help.  Any idea?


```
./libpython2.7.so: undefined reference to `_sem_timedwait'
./libpython2.7.so: undefined reference to `_sem_getvalue'
./libpython2.7.so: undefined reference to `_sem_destroy'
./libpython2.7.so: undefined reference to `_sem_wait'
./libpython2.7.so: undefined reference to `_sem_init'
./libpython2.7.so: undefined reference to `_sem_post'
./libpython2.7.so: undefined reference to `_sem_trywait'
*** Error code 1

Stop in /usr/ports/lang/python27/work/Python-2.7.2/portbld.shared.
*** Error code 1

Stop in /usr/ports/lang/python27.
*** Error code 1

Stop in /usr/ports/lang/python27.
```

The Python27 compiled okay in my new installation of 9.0-RELEASE-AMD64 on another machine.


----------



## kpa (Feb 1, 2012)

How was the machine upgraded to 9.0? If you did a source based upgrade you should run
`# make delete-old`
`# make delete-old-libs`

in /usr/src to get rid of outdated libraries.


----------



## beafool (Feb 1, 2012)

The machine was upgraded via freebsd-update.  Thank you for the response.


----------



## kpa (Feb 1, 2012)

If you have up to date 9.0-Release sources installed you can still run those commands. It's odd that freebsd-update(8) didn't clean up old files properly... The reason for the compilation failure is most likely /lib/libthr.so.2 that is now obsolete and shouldn't exist on a 9.0 system and the up to date version is /lib/libthr.so.3.


----------



## beafool (Feb 1, 2012)

What I did after your suggestion.

1) *cd /usr/src*
2) *make delete-old*
3) *make delete-old-libs*
4) *cd /usr/ports/lang/python27*
5) *make*
6) same compile error
7) *ls -l /lib/libth**

```
r--r--r--  1 root  wheel  95636 Jan 14 15:50 libthr.so.3
```

8) Install cvsup-without-gui from port and waiting for it to be compiled.

So will do a cvsup again on *default release=cvs tag=RELENG_9_0 solve the problem?


----------



## beafool (Feb 1, 2012)

I actually did a *make clean* before step 5.


----------



## kpa (Feb 1, 2012)

Do a 

`# make clean` in /usr/ports/lang/python27 to make sure there's no old work files left from previous compilations.

Also double check that you have an up to date ports tree in /usr/ports, I recommend using portsnap(8) instead of csup(1) if you're not already using it.

Initial checkout of the tree (may take a long time):
`# portsnap fetch`
`# portsnap extract`

Updating of the ports tree:
`# portsnap fetch`
`# portsnap update`


----------



## kpa (Feb 1, 2012)

Install sysutils/bsdadminscripts and run

`# pkg_libchk`

This should reveal if this is a link library problem with one of the dependencies of lang/python27, recompile ports that are reported missing libraries.


----------



## kpa (Feb 1, 2012)

Also something that didn't occur to me right away, reset the options of lang/python27 to defaults with:

`# cd /usr/ports/lang/python27`
`# make rmconfig`

And try again.


----------



## beafool (Feb 1, 2012)

What I did.


`# rm -R /usr/src`
`# rm -R /usr/ports`
`# pkg_add -r bsdadminscripts`
`# portsnap fetch`
`# portsnap extract`
logout and relogin as root
`# pkg_libchk`
pkg_libchk run for a while, return nothing (no error)
`# cd /usr/local/lang/python27`
`# make rmconfig`
`# make`
same error

```
.o  Modules/zipimport.o  Modules/symtablemodule.o  Modules/xxsubtype.o   -lutil  -lm ;  fi
cc -c -fno-strict-aliasing -O2 -pipe  -fno-strict-aliasing -DNDEBUG -O2 -pipe  -fno-strict-aliasing 
 -I. -IInclude -I./../Include -fPIC -DPy_BUILD_CORE -o Modules/python.o ./../Modules/python.c
cc -pthread -Wl,--export-dynamic -o python  Modules/python.o  -L. -lpython2.7 -lutil   -lm
./libpython2.7.so: undefined reference to `_sem_timedwait'
./libpython2.7.so: undefined reference to `_sem_getvalue'
./libpython2.7.so: undefined reference to `_sem_destroy'
./libpython2.7.so: undefined reference to `_sem_wait'
./libpython2.7.so: undefined reference to `_sem_init'
./libpython2.7.so: undefined reference to `_sem_post'
./libpython2.7.so: undefined reference to `_sem_trywait'
*** Error code 1

Stop in /usr/ports/lang/python27/work/Python-2.7.2/portbld.shared.
*** Error code 1

Stop in /usr/ports/lang/python27.
*** Error code 1

Stop in /usr/ports/lang/python27.
```


By the way, if I `# pkg_add -r python27`, it will be installed, but I don't know will there be any side effect

It also happened to my other FreeBSD 8.2-i386 -> FreeBSD 9.0-i386 machines.  These machines had upgraded using freebsd-update from 7.X->8.1->8.2 before, using GENERIC kernel.

My FreeBSD 8.2-AMD64 -> FreeBSD 9.0-AMD64 computer had compiled okay.


----------



## jsoffer (Feb 16, 2012)

I fixed a very similar problem (with Ruby instead of Python, same symptoms otherwise) by softlinking libpthread.so -> libthr.so at /usr/lib.

What was happening was that *ld* linked to libpthread.a (that, somehow, being a link to libthr.a, contained _sem_init et al); creating the symlink caused the indirect link to libthr.so to appear first at link time (the proper thing to do, I suppose). I don't know why it isn't linking directly to libthr, though.


----------



## beafool (Feb 17, 2012)

Thanks a lot.  The software can be compiled after adding back the missing link.  It seems that after upgrade from 8.2-FreeBSD-i386 to 9.0-FreeBSD-i386, the link got removed.  

Fresh install of 9.0-FreeBSD-i386 and 8.2-FreeBSD-AMD64 -> 9.0-FreeBSD-AMD64 does not have the missing link problem.


----------

