Skip to content

"Failed to stat include file ...: No such file or directory" with meson projects #2510

@dezgeg

Description

@dezgeg

To reproduce, first pick an example meson project and build it once:

git clone https://github.com/MusicPlayerDaemon/mpc.git
cd mpc
meson setup build
ninja -C build

Now rebuild one file with debug prints on:

SCCACHE_LOG=debug SCCACHE_START_SERVER=1 SCCACHE_NO_DAEMON=1 sccache &
touch src/args.c && ninja -C build

Output:

ninja: Entering directory `build'
[0/2] Compiling C object mpc.p/src_args.c.o[2025-12-05T15:42:36Z DEBUG sccache::server] handle_client: compile
[2025-12-05T15:42:36Z DEBUG sccache::server] check_compiler: Supported compiler
[2025-12-05T15:42:36Z DEBUG sccache::server] parse_arguments: Ok: ["-Impc.p", "-I.", "-I..", "-I../src", "-I../subprojects/libmpdclient/include", "-Isubprojects/libmpdclient", "-I../subprojects/libmpdclient", "-fdiagnostics-color=always", "-D_FILE_OFFSET_BITS=64", "-Wall", "-Winvalid-pch", "-Wextra", "-Wpedantic", "-std=c99", "-O0", "-g", "-D_GNU_SOURCE", "-fvisibility=hidden", "-Wcast-qual", "-Wdouble-promotion", "-Wmissing-declarations", "-Wmissing-prototypes", "-Wshadow", "-Wstrict-prototypes", "-Wunused", "-Wstrict-prototypes", "-Wvla", "-Wwrite-strings", "-Wno-deprecated-declarations", "-MD", "-MQ", "mpc.p/src_args.c.o", "-MF", "mpc.p/src_args.c.o.d", "-o", "mpc.p/src_args.c.o", "-c", "../src/args.c"]
[2025-12-05T15:42:36Z DEBUG sccache::compiler::compiler] [src_args.c.o]: get_cached_or_compile: ["-Impc.p", "-I.", "-I..", "-I../src", "-I../subprojects/libmpdclient/include", "-Isubprojects/libmpdclient", "-I../subprojects/libmpdclient", "-fdiagnostics-color=always", "-D_FILE_OFFSET_BITS=64", "-Wall", "-Winvalid-pch", "-Wextra", "-Wpedantic", "-std=c99", "-O0", "-g", "-D_GNU_SOURCE", "-fvisibility=hidden", "-Wcast-qual", "-Wdouble-promotion", "-Wmissing-declarations", "-Wmissing-prototypes", "-Wshadow", "-Wstrict-prototypes", "-Wunused", "-Wstrict-prototypes", "-Wvla", "-Wwrite-strings", "-Wno-deprecated-declarations", "-MD", "-MQ", "mpc.p/src_args.c.o", "-MF", "mpc.p/src_args.c.o.d", "-o", "mpc.p/src_args.c.o", "-c", "../src/args.c"]
[2025-12-05T15:42:36Z DEBUG sccache::compiler::c] Failed to stat include file /home/dezgeg/mpc/build/src/args.c: No such file or directory (os error 2)
[2025-12-05T15:42:36Z DEBUG sccache::compiler::c] Disabling preprocessor cache mode
[2025-12-05T15:42:36Z DEBUG sccache::compiler::compiler] [src_args.c.o]: generate_hash_key took 0.018 s
[2025-12-05T15:42:36Z DEBUG sccache::compiler::compiler] [src_args.c.o]: Hash key: 5d1237295116f8faba99f272a846d52dd372556d8d637395840d941c0d97c3f8
[2025-12-05T15:42:36Z DEBUG sccache::compiler::compiler] [src_args.c.o]: Cache hit in 0.000 s
[2025-12-05T15:42:36Z DEBUG sccache::server] compile result: cache hit

Problematic line is: Failed to stat include file /home/dezgeg/mpc/build/src/args.c: No such file or directory (os error 2) - it should not have the /build/ subdirectory.

If we look at the preprocessor's output we see that it should be is /home/dezgeg/mpc/build/../src/args.c:

/usr/bin/cc -x c -E -Impc.p -I. -I.. -I../src -I../subprojects/libmpdclient/include -Isubprojects/libmpdclient -I../subprojects/libmpdclient -MD -MF mpc.p/src_args.c.o.d -MQ mpc.p/src_args.c.o -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c99 -O0 -g -D_GNU_SOURCE -fvisibility=hidden -Wcast-qual -Wdouble-promotion -Wmissing-declarations -Wmissing-prototypes -Wshadow -Wstrict-prototypes -Wunused -Wstrict-prototypes -Wvla -Wwrite-strings -Wno-deprecated-declarations ../src/args.c | grep 'args.c'

# 0 "../src/args.c"
# 1 "../src/args.c"
# 5 "../src/args.c" 2

The problematic part of the code seems to be

let normalized = normalize_path(&path_buf);
- the normalize_path() call for a string like ../src/args.c just throws away the ../ prefix.

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