From 271bab7f93d73e0b80517699f29d0a5e88bc41b5 Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Sun, 18 Apr 2021 16:27:36 -0600 Subject: [PATCH] BLD: handle gcc on MacOS * gracefully handle the case where `gcc` toolchain in use on MacOS has been built from source using `clang` by `spack` (so it really is `gcc` in use, not `clang`) * we could try to add regression testing, but a few problems: - `using_clang()` is inside `setup.py`, which probably can't be safely imported because it has unguarded statements/ code blocks that run right away - testing build issues is typically tricky with mocking, etc. (though in this case, probably just need to move `using_clang()` somewhere else and then test it against a variety of compiler metadata strings --- package/setup.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/package/setup.py b/package/setup.py index bdbe9ade8a7..224ef9bd8e7 100755 --- a/package/setup.py +++ b/package/setup.py @@ -253,7 +253,19 @@ def using_clang(): compiler = new_compiler() customize_compiler(compiler) compiler_ver = getoutput("{0} -v".format(compiler.compiler[0])) - return 'clang' in compiler_ver + if 'Spack GCC' in compiler_ver: + # when gcc toolchain is built from source with spack + # using clang, the 'clang' string may be present in + # the compiler metadata, but it is not clang + is_clang = False + elif 'clang' in compiler_ver: + # by default, Apple will typically alias gcc to + # clang, with some mention of 'clang' in the + # metadata + is_clang = True + else: + is_clang = False + return is_clang def extensions(config):