|
2 | 2 | from __future__ import unicode_literals
|
3 | 3 |
|
4 | 4 | import contextlib
|
5 |
| -import distutils.sysconfig |
6 | 5 | import os
|
7 | 6 | import pipes
|
8 | 7 | import shutil
|
|
13 | 12 | from setuptools.command.build_ext import build_ext as _build_ext
|
14 | 13 |
|
15 | 14 |
|
16 |
| -PYPY = '__pypy__' in sys.builtin_module_names |
17 |
| - |
18 |
| - |
19 | 15 | def _get_cflags(compiler):
|
20 | 16 | return ' '.join('-I{}'.format(p) for p in compiler.include_dirs)
|
21 | 17 |
|
22 | 18 |
|
23 |
| -def _get_ldflags_pypy(): |
24 |
| - if PYPY: # pragma: no cover (pypy only) |
25 |
| - return '-L{} -lpypy-c'.format( |
26 |
| - os.path.dirname(os.path.realpath(sys.executable)), |
27 |
| - ) |
28 |
| - else: |
29 |
| - return None |
30 |
| - |
31 |
| - |
32 |
| -def _get_ldflags_pkg_config(): |
33 |
| - try: |
34 |
| - return subprocess.check_output(( |
35 |
| - 'pkg-config', '--libs', |
36 |
| - 'python-{}.{}'.format(*sys.version_info[:2]), |
37 |
| - )).decode('UTF-8').strip() |
38 |
| - except (subprocess.CalledProcessError, OSError): |
39 |
| - return None |
40 |
| - |
41 |
| - |
42 |
| -def _get_ldflags_bldlibrary(): |
43 |
| - return distutils.sysconfig.get_config_var('BLDLIBRARY') |
44 |
| - |
45 |
| - |
46 |
| -def _get_ldflags(): |
47 |
| - for func in ( |
48 |
| - _get_ldflags_pypy, |
49 |
| - _get_ldflags_pkg_config, |
50 |
| - _get_ldflags_bldlibrary, |
51 |
| - ): |
52 |
| - ret = func() |
53 |
| - if ret is not None: |
54 |
| - return ret |
55 |
| - else: |
56 |
| - raise AssertionError('Could not determine ldflags!') |
57 |
| - |
58 |
| - |
59 | 19 | def _check_call(cmd, cwd, env):
|
60 | 20 | envparts = [
|
61 | 21 | '{}={}'.format(k, pipes.quote(v))
|
@@ -113,7 +73,7 @@ def _raise_error(msg):
|
113 | 73 |
|
114 | 74 | env.update({
|
115 | 75 | 'CGO_CFLAGS': _get_cflags(self.compiler),
|
116 |
| - 'CGO_LDFLAGS': _get_ldflags(), |
| 76 | + 'CGO_LDFLAGS': '-Wl,--unresolved-symbols=ignore-all', |
117 | 77 | })
|
118 | 78 | cmd_build = (
|
119 | 79 | 'go', 'build', '-buildmode=c-shared',
|
|
0 commit comments