[gobject-introspection] customize_compiler: also replace the linker command if CC is set
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] customize_compiler: also replace the linker command if CC is set
- Date: Sun, 30 Dec 2018 13:29:09 +0000 (UTC)
commit d1e234ec171e9f60bd54837071ef60ca7b0568c7
Author: Christoph Reiter <reiter christoph gmail com>
Date: Sat Dec 29 19:42:08 2018 +0100
customize_compiler: also replace the linker command if CC is set
Otherwise when you set CC=clang then distuils will still use gcc for linking.
While it seems we don't invoke the link command atm this shouldn't hurt.
The upstream customize_compiler() does the same thing on macOS and there is a bug
for enabling it everywhere: https://bugs.python.org/issue24935
giscanner/ccompiler.py | 5 ++++-
tests/scanner/test_ccompiler.py | 5 +++++
2 files changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index 8ea99445..aee6a1af 100644
--- a/giscanner/ccompiler.py
+++ b/giscanner/ccompiler.py
@@ -45,7 +45,10 @@ def customize_compiler(compiler):
get_config_vars('CC', 'CXX', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
if 'CC' in os.environ:
- cc = os.environ['CC']
+ newcc = os.environ['CC']
+ if 'LDSHARED' not in os.environ and ldshared.startswith(cc):
+ ldshared = newcc + ldshared[len(cc):]
+ cc = newcc
if 'CXX' in os.environ:
cxx = os.environ['CXX']
if 'LDSHARED' in os.environ:
diff --git a/tests/scanner/test_ccompiler.py b/tests/scanner/test_ccompiler.py
index ac50e245..dd8700d8 100644
--- a/tests/scanner/test_ccompiler.py
+++ b/tests/scanner/test_ccompiler.py
@@ -62,6 +62,11 @@ class UnixCCompilerTest(unittest.TestCase):
except ValueError:
self.fail('%r is not a subsequence of %r' % (list1, list2))
+ def test_link_args_override(self):
+ with Environ(dict(CC="foobar")):
+ compiler = CCompiler()
+ self.assertEqual(compiler.compiler.linker_so[0], "foobar")
+
def compile_args(self, environ={}, compiler_name='unix',
pkg_config_cflags=[], cpp_includes=[],
source='a.c', init_sections=[]):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]