From 5e48d094a6113c620f5ccb99bc54968221490f50 Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Thu, 30 Apr 2020 15:05:56 +0200 Subject: [PATCH] jit: Smarter CustomCompiler --- devito/compiler.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/devito/compiler.py b/devito/compiler.py index 5e5bc224eb..2c1d95e152 100644 --- a/devito/compiler.py +++ b/devito/compiler.py @@ -489,9 +489,12 @@ def __init__(self, *args, **kwargs): class CustomCompiler(Compiler): + """ Custom compiler based on standard environment flags. + If no environment flags are found, defaults to the GNUCompiler. + Notes ----- Currently honours CC, CFLAGS and LDFLAGS, with defaults similar to the @@ -500,6 +503,14 @@ class CustomCompiler(Compiler): or otherwise default to ``-fopenmp``. """ + def __new__(cls, *args, **kwargs): + if any(i in environ for i in ['CC', 'CXX', 'CFLAGS', 'LDFLAGS']): + obj = super().__new__(cls, *args, **kwargs) + obj.__init__(*args, **kwargs) + return obj + else: + return GNUCompiler(*args, **kwargs) + def __init__(self, *args, **kwargs): super(CustomCompiler, self).__init__(*args, **kwargs)