From 95cfcee5a93785689ee35e4e234a798ec0b62cf3 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 15 Jan 2019 11:27:19 -0500 Subject: [PATCH 1/3] Add missing default args for if toolchain can't be found --- loopy/target/c/c_execution.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/loopy/target/c/c_execution.py b/loopy/target/c/c_execution.py index f7622936c..660b6b90b 100644 --- a/loopy/target/c/c_execution.py +++ b/loopy/target/c/c_execution.py @@ -236,7 +236,11 @@ class CCompiler(object): libraries=[], library_dirs=[], defines=[], - source_suffix='c') + undefines=[], + source_suffix='c', + so_ext='.so', + o_ext='.o', + include_dirs=[]) if toolchain is None: # copy in all differing values -- GitLab From ee5dc627d2a7913b1466de8f6ef4bea4eb42bd5c Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 15 Jan 2019 11:47:29 -0500 Subject: [PATCH 2/3] update missing compiler test to actually execute a default toolchain --- test/test_c_execution.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/test_c_execution.py b/test/test_c_execution.py index c355893e4..bf168c11d 100644 --- a/test/test_c_execution.py +++ b/test/test_c_execution.py @@ -323,14 +323,24 @@ def test_missing_compilers(): b=np.arange(10, dtype=np.int32))[1], np.arange(10)) import os path_store = os.environ["PATH"] + ccomp = None try: # test with path wiped out such that we can't find gcc with pytest.raises(ExecError): os.environ["PATH"] = '' - __test(eval_tester, ExecutableCTarget) + ccomp = CCompiler() + __test(eval_tester, ExecutableCTarget, compiler=ccomp) finally: - # make sure we restore the path regardless for future testing + # make sure we restore the path os.environ["PATH"] = path_store + # and, with the path restored we should now be able to properly execute with + # the default (non-guessed) toolchain! + __test(eval_tester, ExecutableCTarget, compiler=ccomp) + + # and test that we will fail if we remove a required attribute + del ccomp.toolchain.undefines + with pytest.raises(AttributeError): + __test(eval_tester, ExecutableCTarget, compiler=ccomp) # next test that some made up compiler can be specified ccomp = CCompiler(cc='foo') -- GitLab From 044ca680c7fe75b35128264cd76468ccd94ac794 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 15 Jan 2019 15:50:28 -0500 Subject: [PATCH 3/3] fix missing toolchain arg for CPP compiler --- loopy/target/c/c_execution.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/loopy/target/c/c_execution.py b/loopy/target/c/c_execution.py index 660b6b90b..60947c7f7 100644 --- a/loopy/target/c/c_execution.py +++ b/loopy/target/c/c_execution.py @@ -287,15 +287,16 @@ class CCompiler(object): class CPlusPlusCompiler(CCompiler): """Subclass of CCompiler to invoke a C++ compiler.""" - def __init__(self, cc='g++', cflags='-std=c++98 -O3 -fPIC'.split(), + def __init__(self, toolchain=None, + cc='g++', cflags='-std=c++98 -O3 -fPIC'.split(), ldflags=[], libraries=[], include_dirs=[], library_dirs=[], defines=[], source_suffix='cpp'): super(CPlusPlusCompiler, self).__init__( - cc=cc, cflags=cflags, ldflags=ldflags, libraries=libraries, - include_dirs=include_dirs, library_dirs=library_dirs, - defines=defines, source_suffix=source_suffix) + toolchain=toolchain, cc=cc, cflags=cflags, ldflags=ldflags, + libraries=libraries, include_dirs=include_dirs, + library_dirs=library_dirs, defines=defines, source_suffix=source_suffix) class IDIToCDLL(object): -- GitLab