mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.53k stars 1.61k forks source link

`test_pch_with_address_sanitizer` failure #11755

Open benoit-pierre opened 1 year ago

benoit-pierre commented 1 year ago

Describe the bug

The test_generate_gir_with_address_sanitizer test fails on my machine when sccache is used.

Testsuite output

▸ ./run_unittests.py -v -ktest_generate_gir_with_address_sanitizer
[…]
[3/22] Precompiling header '../test cases/common/13 pch/withIncludeFile/pch/prog.h'
[4/22] Precompiling header '../test cases/common/13 pch/c/pch/prog.h'
[5/22] Precompiling header '../test cases/common/13 pch/withIncludeDirectories/pch/prog.h'
[6/22] Precompiling header '../test cases/common/13 pch/mixed/pch/func.h'
[7/22] Precompiling header '../test cases/common/13 pch/mixed/pch/main.h'
[8/22] Compiling C object withIncludeFile/prog.p/prog.c.o
[9/22] Compiling C object withIncludeDirectories/prog.p/prog.c.o
[10/22] Compiling C object c/prog.p/prog.c.o
[11/22] Compiling C++ object mixed/prog.p/main.cc.o
FAILED: mixed/prog.p/main.cc.o
sccache c++ -Imixed/prog.p -Imixed '-I../test cases/common/13 pch/mixed' -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -fpch-preprocess -include main.h -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -MD -MQ mixed/prog.p/main.cc.o -MF mixed/prog.p/main.cc.o.d -o mixed/prog.p/main.cc.o -c '../test cases/common/13 pch/mixed/main.cc'
cc1plus: warning: mixed/prog.p/main.h.gch: not a PCH file [-Winvalid-pch]
cc1plus: error: one or more PCH files were found, but they were invalid
<command-line>: fatal error: main.h: No such file or directory
compilation terminated.
[12/22] Precompiling header '../test cases/common/13 pch/generated/pch/prog.h'
[13/22] Compiling C object mixed/prog.p/func.c.o
[14/22] Linking target withIncludeFile/prog
[15/22] Linking target c/prog
[16/22] Linking target withIncludeDirectories/prog
[17/22] Precompiling header '../test cases/common/13 pch/cpp/pch/prog.hh'
ninja: build stopped: subcommand failed.
[…]

System parameters

Analysis

It looks like this might be a bug in sccache:

# with ccache
▸ CC='ccache gcc' CXX='ccache g++' meson setup -Db_sanitize=address -Db_lundef=false build_ccache
[…]
▸ ninja -C build_ccache -v mixed/prog.p/main.h.gch
ninja: Entering directory `build_ccache'
[1/1] ccache g++ -Imixed/prog.p -Imixed -I../mixed -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -x c++-header -MD -MQ mixed/prog.p/main.h.gch -MF mixed/prog.p/main.h.gch.d -o mixed/prog.p/main.h.gch -c ../mixed/pch/main.h
▸ file build_ccache/mixed/prog.p/main.h.gch
build_ccache/mixed/prog.p/main.h.gch: GCC precompiled header (version 014) for C++
# with sccache
▸ CC='sccache gcc' CXX='sccache g++' meson setup -Db_sanitize=address -Db_lundef=false build_sccache
[…]
▸ ninja -C build_sccache -v mixed/prog.p/main.h.gch
ninja: Entering directory `build_sccache'
[1/1] sccache g++ -Imixed/prog.p -Imixed -I../mixed -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -x c++-header -MD -MQ mixed/prog.p/main.h.gch -MF mixed/prog.p/main.h.gch.d -o mixed/prog.p/main.h.gch -c ../mixed/pch/main.h
▸ file build_sccache/mixed/prog.p/main.h.gch
build_sccache/mixed/prog.p/main.h.gch: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
benoit-pierre commented 1 year ago

See https://github.com/mozilla/sccache/issues/1748.

benoit-pierre commented 1 year ago

Maybe meson should make sscache support opt-in, or at least prefer ccache if both are installed.