From 246095da49e848ff866628b0aab40322ca25cab2 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Fri, 16 Jan 2026 14:25:40 +0100 Subject: [PATCH] nir/meson: only try to generate the nir_opt_algebraic tests when requested Anything listed in a meson target's `output` is expected to exist once the command has run. If it's missing, meson/ninja will run the command again to try to generate it, resulting in a ton of files getting re-generated/re-compiled for no reason. Fixes: 4c30c44b750607d9ab41 ("nir: Generate unit tests for nir_opt_algebraic") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14667 Part-of: --- src/compiler/nir/meson.build | 8 ++++---- src/compiler/nir/nir_opt_algebraic.py | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build index 243c5faf46b..19aed0f72f1 100644 --- a/src/compiler/nir/meson.build +++ b/src/compiler/nir/meson.build @@ -44,13 +44,12 @@ nir_opcodes_c = custom_target( nir_opt_algebraic = custom_target( 'nir_opt_algebraic', input : 'nir_opt_algebraic.py', - output : ['nir_opt_algebraic.c', 'nir_opt_algebraic_pattern_test.cpp'], - command : [prog_python, '@INPUT@', '--out', '@OUTPUT0@', '--out-tests', '@OUTPUT1@'] + - (with_tests ? ['--build-tests'] : []), + output : ['nir_opt_algebraic.c'] + (with_tests ? ['nir_opt_algebraic_pattern_test.cpp'] : []), + command : [prog_python, '@INPUT@', '--out', '@OUTPUT0@'] + + (with_tests ? ['--build-tests', '--out-tests', '@OUTPUT1@'] : []), depend_files : nir_algebraic_depends, ) nir_opt_algebraic_c = nir_opt_algebraic[0] -nir_opt_algebraic_pattern_test_cpp = nir_opt_algebraic[1] nir_intrinsics_h = custom_target( 'nir_intrinsics.h', @@ -411,6 +410,7 @@ if with_tests # Split the compile of nir_opt_algebraic_pattern_tests into multiple compilation # units, as it takes about of minute of compile time all together. + nir_opt_algebraic_pattern_test_cpp = nir_opt_algebraic[1] nir_opt_algebraic_pattern_tests = [] foreach i : range(8) nir_opt_algebraic_pattern_tests += static_library( diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index ba3e6417a4f..c1a59ddcfdf 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -4282,10 +4282,13 @@ for s in [8, 16]: parser = argparse.ArgumentParser() parser.add_argument('--out', required=True) -parser.add_argument('--out-tests', required=True) +parser.add_argument('--out-tests') parser.add_argument('--build-tests', action='store_true') args = parser.parse_args() +if args.build_tests and not args.out_tests: + parser.error("--build-tests requires --out-tests") + passes = [] passes.append(nir_algebraic.AlgebraicPass(