Repository: scipy/scipy

Issue:
scipy fails compilation when building from source
[scipy_build_tail.log](https://github.com/scipy/scipy/files/1876872/scipy_build_tail.log)

Building the scipy source from tip fails when compiling : 
This might be the offending line: Dont know how the line in BLOCK text showed up
**-L"Using built-in specs**

`
/opt/amba/cv22_third/tv2/exe/gfortran -Wall -g -Wall -g -shared build/temp.linux-x86_64-3.5/scipy/integrate/_quadpackmodule.o -L/opt/amba/cv22_third/tv2/release/atlas/3.10.3/lib -L"Using built-in specs.
`

PLEASE HELP. BLOCKING DEVELOPMENT 

### Error message:
```
building 'scipy.integrate._odepack' extension
compiling C sources
C compiler: gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -v -fPIC

```

### Scipy/Numpy/Python version information:
```
<<Output from 'import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)'>>

Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'scipy' has no attribute '__version__'

```




Discussion:
UPDATE:

upon removing the extra_link_args (-Wl, --version-script=) by commenting line#214 compilation succeeded. or upon cleaning up the list ext.extra_link_args
Guess, setup.py does not clear() the list before appending new stuff or is it the expected behavior.
Why does odepack needs version info of quadpack ?

This change in setup.py fixes issue.

```
214                     ext.extra_link_args.clear()
215                     ext.extra_link_args.append('-Wl,--version-script=' + script_fn)

```
@aisri  Is this issue resolved? We don't have much information to work with so I don't know how we can help. 
@ilayn I got it resolved by making changes to your setup.py script. These are the lines I changed. You can review these changes 

```
> 214                     ext.extra_link_args.clear()
> 215                     ext.extra_link_args.append('-Wl,--version-script=' + script_fn)
```
The problem is that we can't understand what the cause was in the first place. Could you provide your system and configuration? Otherwise this is a special fix for your own system.
`/usr/bin/ld: anonymous version tag cannot be combined with other version tags` - seems to be an unusual issue, unclear what is causing it here.
I got the same error (scipy 1.0.1 is fine). I'm using CentOS 7.5, gcc 4.8.5, ld/binutils 2.27-28.
My ~/.numpy-site.cfg is:

> [mkl]
> library_dirs = /opt/intel/compilers_and_libraries_2017/linux/mkl/lib/intel64
> lapack_libs = mkl_rt
> mkl_libs=mkl_rt
> extra_link_args = -Wl,-rpath=/opt/intel/compilers_and_libraries_2017/linux/mkl/lib/intel64

The build succeeds if I comment out the 'extra_link_args'.

I have the same problem

Sys-info:

binutils: 2.31.1
numpy: 1.15.3
site.cfg:
```bash
[openblas]
...
extra_link_args = ...
```
GCC 8.2.0
Debian 9u6

It successfully compiles with the above fix.
This small addition also seems to work fine (simply remove any version-script flags already in the argument list):
```python
ext.extra_link_args = [arg for arg in ext.extra_link_args if not "version-script" in arg]
```

Are we willing to make the fix proposed above without perhaps fully understanding the issue? I don't see a linked PR.
The fix from @zerothi seems fine to make in any case. Let's do that.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -211,6 +211,8 @@ def build_extension(self, ext):
                 script_fn = os.path.join(self.build_temp, 'link-version-{}.map'.format(ext.name))
                 with open(script_fn, 'w') as f:
                     f.write(text)
+                    # line below fixes gh-8680
+                    ext.extra_link_args = [arg for arg in ext.extra_link_args if not "version-script" in arg]
                     ext.extra_link_args.append('-Wl,--version-script=' + script_fn)
 
             old_build_ext.build_extension(self, ext)


Test patch: