summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSayed Adel <seiko@imavr.com>2021-11-12 07:54:07 +0200
committerSayed Adel <seiko@imavr.com>2021-11-12 08:10:49 +0200
commitd06f2288e078876f5e0bebde4e844b64a0b0ffee (patch)
tree06b84cfb1aefc558cc73fa309db4267d0b21d27d /numpy
parent2513620bfbb30fa55bbbba1902f29284adab650c (diff)
downloadnumpy-d06f2288e078876f5e0bebde4e844b64a0b0ffee.tar.gz
BLD: Verify the ability to compile C++ sources before initiating the build
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/setup.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index 2c99060ec..3fc0f85f1 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -672,16 +672,29 @@ def configuration(parent_package='',top_path=None):
# but we cannot use add_installed_pkg_config here either, so we only
# update the substitution dictionary during npymath build
config_cmd = config.get_config_cmd()
-
# Check that the toolchain works, to fail early if it doesn't
# (avoid late errors with MATHLIB which are confusing if the
# compiler does not work).
- st = config_cmd.try_link('int main(void) { return 0;}')
- if not st:
- # rerun the failing command in verbose mode
- config_cmd.compiler.verbose = True
- config_cmd.try_link('int main(void) { return 0;}')
- raise RuntimeError("Broken toolchain: cannot link a simple C program")
+ for lang, test_code, note in (
+ ('c', 'int main(void) { return 0;}', ''),
+ ('c++', (
+ 'int main(void)'
+ '{ auto x = 0.0; return static_cast<int>(x); }'
+ ), (
+ 'note: A compiler with support for C++11 language '
+ 'features is required.'
+ )
+ ),
+ ):
+ st = config_cmd.try_link(test_code, lang=lang)
+ if not st:
+ # rerun the failing command in verbose mode
+ config_cmd.compiler.verbose = True
+ config_cmd.try_link(test_code, lang=lang)
+ raise RuntimeError(
+ f"Broken toolchain: cannot link a simple {lang.upper()} "
+ f"program. {note}"
+ )
mlibs = check_mathlib(config_cmd)
posix_mlib = ' '.join(['-l%s' % l for l in mlibs])