diff --git a/python/dune/codegen/sumfact/autotune.py b/python/dune/codegen/sumfact/autotune.py
index 59ad1886072619a9fbac956f402f95a7d9e26662..68d81957e00917d55383282c748879f7f96db587 100644
--- a/python/dune/codegen/sumfact/autotune.py
+++ b/python/dune/codegen/sumfact/autotune.py
@@ -198,6 +198,7 @@ def autotune_realization(sf):
     filename = os.path.join(dir, "{}.cc".format(basename))
     logname = os.path.join(dir, "{}.log".format(basename))
     lock = os.path.join(dir, "{}.lock".format(basename))
+    executable = os.path.join(dir, basename)
 
     # Generate and compile a benchmark program
     with cache_restoring():
@@ -205,7 +206,8 @@ def autotune_realization(sf):
             if not os.path.isfile(logname):
                 generate_standalone_code(sf, filename)
 
-                ret = subprocess.call(compiler_invocation(basename, filename))
+                devnull = open(os.devnull, 'w')
+                ret = subprocess.call(compiler_invocation(executable, filename), stdout=devnull, stderr=subprocess.STDOUT)
                 if ret != 0:
                     raise CodegenAutotuneError("Compilation of autotune executable failed. Invocation: {}".format(" ".join(compiler_invocation(name, filename))))
 
@@ -216,9 +218,8 @@ def autotune_realization(sf):
                     call.append(wrapper)
 
                 # Run the benchmark program
-                call.append(basename)
+                call.append(executable)
                 call.append(logname)
-                devnull = open(os.devnull, 'w')
                 ret = subprocess.call(call, stdout=devnull, stderr=subprocess.STDOUT)
                 if ret != 0:
                     raise CodegenAutotuneError("Execution of autotune benchmark failed. Invocation: {}".format(" ".join(call)))