Fails to build on FreeBSD
building 'PETSc' extension
/usr/local/bin/mpicc -O2 -pipe -fstack-protector -fno-strict-aliasing -msse2 -fPIC -fPIC -O2 -pipe -fno-omit-frame-pointer -fstack-protector -fno-strict-aliasing -DPETSC_DIR=/usr/local -I/usr/local/include -Isrc/include -I/usr/local/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include/python2.7 -c src/PETSc.c -o build/temp.freebsd-11.1-STABLE-amd64-2.7/src/PETSc.o
/usr/local/bin/mpicc -O2 -pipe -fstack-protector -fno-strict-aliasing -msse2 -fPIC -fPIC -O2 -pipe -fno-omit-frame-pointer -fstack-protector -fno-strict-aliasing -DPETSC_DIR=/usr/local -I/usr/local/include -Isrc/include -I/usr/local/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include/python2.7 -c src/libpetsc4py.c -o build/temp.freebsd-11.1-STABLE-amd64-2.7/src/libpetsc4py.o
/usr/local/bin/mpicc -L/usr/local/lib -Wl,-rpath=/usr/local/lib/gcc6 -L/usr/local/lib/gcc6 -B/usr/local/bin -fstack-protector -O2 -pipe -fstack-protector -fno-strict-aliasing -msse2 -fPIC cc -shared -fstack-protector build/temp.freebsd-11.1-STABLE-amd64-2.7/src/PETSc.o build/temp.freebsd-11.1-STABLE-amd64-2.7/src/libpetsc4py.o -L/usr/local/lib -L/usr/local/lib -Wl,-rpath=/usr/local/lib -lpetsc -lpython2.7 -o build/lib.freebsd-11.1-STABLE-amd64-2.7/petsc4py/lib/PETSc.so
gcc6: error: cc: No such file or directory
Comments (19)
-
-
reporter helloworld.c builds with mpicc fine. Removing 'cc' makes the build succeed.
-
Oh, now I see the problem. Could you enter the interactive python prompt and tell me the output of the following lines?
>>> from distutils import sysconfig >>> sysconfig.get_config_var('CC') >>> sysconfig.get_config_var('LDSHARED')
-
reporter $ python2.7 Python 2.7.15 (default, May 13 2018, 01:10:00) [GCC 4.2.1 Compatible FreeBSD Clang 4.0.0 (tags/RELEASE_400/final 297347)] on freebsd11 Type "help", "copyright", "credits" or "license" for more information. >>> from distutils import sysconfig >>> sysconfig.get_config_var('CC') 'cc' >>> sysconfig.get_config_var('LDSHARED') 'cc -shared -lpthread -L/usr/local/lib -fstack-protector' >>>
-
Ups, I was expecting LDFLAGS to not start with CC. Now I have no clue what's going on. At this point I would need your help to debug the issue. All the logics are in
conf/baseconf.py
. Can you addprint(PLD_SHARED)
right before the call tocompiler.set_executables(...)
and tell me the output ? -
reporter print(PLD_SHARED)
prints/usr/local/bin/mpicc -L/usr/local/lib -Wl,-rpath=/usr/local/lib/gcc6 -L/usr/local/lib/gcc6 -B/usr/local/bin -fstack-protector -O2 -pipe -fstack-protector -fno-strict-aliasing -msse2 -fPIC cc -shared -fstack-protector
cc
in the beginning explains the failure. Removingcc
from the command line lets the build to succeed. -
reporter This unrelated post also confirms that
LDSHARED
begins with the compiler name: https://stackoverflow.com/questions/5986256/python-distutils-gcc-path -
Can you somehow run that under the Python debugger of add a few more
print()
lines around to figure out where the bug comes from? The problem may be in this line:ldshared = [flg for flg in split_quoted(ldshared) if flg not in ldcmd]
. -
Sorry for the trouble, all this is nasty code, but Python's distutils makes it so damn hard to alter compiler/linker commands... As I don't have access to a FreeBSD box, I really need your assistance to figure out the source of the bug.
-
reporter No problem.
I will look in the evening.
-
reporter ldshared=cc -shared
introducescc
through this line:PLD_SHARED = str.join(' ', (PLD, ldshared, ldflags))
Obviously,
LDFLAGS
with leadingcc
brings it in. -
Yes, but please look above, an below the commend
# distutils linker
. After that block, the variableldshared
is supposed to not start withcc
. I cannot figure out yet whycc
is not removed. -
The problem is that anyone out there that builds Python from sources (Apple, Homebrew, Linux distros, Anaconda Python, etc. etc.) all them play tricks with compiler flags and the installed Python makefile from where these flags are taken endup being inconsistent across platforms and distributions and python versions, so it is really a nightmare to get things right for all the cases.
-
reporter After this line:
(ldflags, ldshared, so_ext) = get_config_vars( 'LDFLAGS', 'LDSHARED', 'SO')
ldshared=cc -shared -lpthread -L/usr/local/lib -fstack-protector
- same as get_config_vars('LDSHARED')After this line:
ldshared = str.join(' ', ldshared)
ldshared=-shared
-- the updated valueThen this line:
ldshared = getenv('LDSHARED', ldshared)
sets in to the environment variable
LDSHARED
, which has the valuecc -shared
and it stays this way, withcc
. -
So then you have an environment variable
LDSHARED
set?? From where does it came from? Did you set it or does it come from some outer buildsystem you are using (e.g. some package builder)? -
Tentative fix in this branch, obviously untested: https://bitbucket.org/petsc/petsc4py/branch/dalcinl/fix-ldshared
-
reporter Port infrastructure sets this variable for all python ports for some reason:
LDSHARED?= ${CC} -shared
-
reporter The patch solved this problem, thanks!
-
- changed status to resolved
- Log in to comment
Your build environment seems to be broken. Are you able to compile a minimal MPI code (look for
helloworld.c
in mpi4py sources) using thempicc
compiler wrapper?