Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

gcc-4.8: add library paths reported by system linker #691

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

svenpeter42
Copy link

Right now only part of the system's libc is symlinked into the conda env - namely the startup files crtXXX.o.
In addition the path to the actual shared object libc.so also needs to be added to the spec file in case a custom
linker is used inside the conda env (e.g. because binutils is requested).

This fixes the following error I get when I conda build a package that requires both gcc-4.8 and binutils:
/home/speter/miniconda2/envs/_build/bin/ld: cannot find -lc collect2: error: ld returned 1 exit status Installation failed: gcc is not able to compile a simple 'Hello, World' program.

cc @stuarteberg

Right now only part of the system's libc is symlinked into the conda env - namely the startup files crtXXX.o.
In addition the path to the actual shared object libc.so also needs to be added to the spec file in case a custom
linker is used inside the conda env (e.g. because binutils is requested).
#
# Linux Portability Issue #2.5: linker also needs to find the rest of libc (i.e. libc.so in addition to crtXXX.o)
#
for library_path in $(/usr/bin/ld --verbose | grep SEARCH_DIR | sed -r 's/SEARCH_DIR\("=?([^"]*)"\);/ \1/g'); do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the full path to the system /usr/bin/ld instead of ld is a good idea. (It avoids problems if the user has a custom install of binutils.) While you're at it, can you also fix the call to ld on line 49, above?

@stuarteberg
Copy link
Contributor

You should bump the build number.

@stuarteberg
Copy link
Contributor

LGTM.

@stuarteberg
Copy link
Contributor

@frol: Just in case it matters for your gcc-5 package -- @svenpeter42 discovered that the gcc-4.8 post-link.sh script doesn't work properly if the user has also installed binutils via conda. This PR fixes it, so I guess it should also be added to gcc-5, if you're still maintaining that recipe. (At the moment, there is no "official" binutils package from conda, so this will only affect a very small minority of users.)

If you're not still maintaining the gcc-5 recipe, then sorry for the spam. :-)

@ccordoba12
Copy link
Contributor

Pinging @mingwandroid about this one.

@frol
Copy link
Contributor

frol commented Jul 25, 2016

Thank you for pinging me! I do still maintain gcc-5 package (and also gcc-6) as well as I maintain conda-forge/binutils feedstock.

@ostrokach
Copy link

Is anything holding back this PR? I just spent half a day tring to figure out why conda's gcc / mpich was giving me an error ld: cannot find -lc:

$ mpicc -o mpi_hello_world mpi_hello_world.c
/home/{username}/anaconda/envs/{projectname}/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status

unless I specified -L/usr/lib/x86_64-linux-gnu.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants