Skip to content

compiler.run produces a runresult with undefined stdout and stderr rather than an error on use #15417

@apache-hb

Description

@apache-hb

Describe the bug
The result of compiler.run has a stdout field that contains UNDEFINED

To Reproduce

project(
  'configure-file-int-repro',
  'c',
  meson_version : '>= 1.3.0',
  version : '0.1',
  default_options : ['warning_level=3'],
)

cc = meson.get_compiler('c')

result = cc.run(
'''
int main() {
  printf("5\n");
  return 0;
}
'''
)

cdata = configuration_data()
cdata.set('VALUE', result.stdout().strip())

config = configure_file(
  output : 'thing.h',
  configuration : cdata,
)

sources = [
  'configure_file_int_repro.c',
]

exe = executable(
  'configure-file-int-repro',
  sources,
  install : true,
)
#include <stdio.h>

#include "thing.h"

#define PROJECT_NAME "configure-file-int-repro"

#if VALUE != 5
#error "VALUE is not defined"
#endif

int main(int argc, char **argv) {
    if (argc != 1) {
        printf("%s takes no arguments.\n", argv[0]);
        return 1;
    }
    printf("This is project %s.\n", PROJECT_NAME);
    return 0;
}

This fails with ../configure_file_int_repro.c:8:2: error: "VALUE is not defined" and thing.h contains

/*
 * Autogenerated by the Meson build system.
 * Do not edit, your changes will be lost.
 */

#pragma once

#define VALUE UNDEFINED

Expected behavior
Using the runresult of a failed run should produce an error.

system parameters

elliothb@ELLIOT-SERVER:~/github/configure-file-int-repro$ meson --version
1.10.0
elliothb@ELLIOT-SERVER:~/github/configure-file-int-repro$ ninja --version
1.10.1
elliothb@ELLIOT-SERVER:~/github/configure-file-int-repro$ uname -a
Linux ELLIOT-SERVER 6.16.5-WSL2-STABLE+ #1 SMP PREEMPT_DYNAMIC Fri Sep  5 02:14:51 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
elliothb@ELLIOT-SERVER:~/github/configure-file-int-repro$ python3 --version
Python 3.10.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions