Skip to content

Build fails if sccache is installed #604

@DCNick3

Description

@DCNick3

Repro

I am unable to build aegisub with meson if I have sccache in PATH. I have stumbled upon this when building the aegisub-arch1t3cht-git AUR package, but this also happens with the upstream Aegisub too.

I get a lot of error messages looking like this:

[123/305] Compiling C++ object aegisub.p/src_ass_exporter.cpp.o
FAILED: [code=1] aegisub.p/src_ass_exporter.cpp.o 
/usr/bin/sccache c++ -Iaegisub.p -I. -I.. -I../libaegisub/include -Isrc/libresrc -I../src/libresrc -Isrc -I../src -Isubprojects/LuaJIT-04dca7911ea255f37be799c18d74c305b921c1a6/src -I../subprojects/LuaJIT-04dca7911ea255f37be799c18d74c305b921c1a6/src -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-6 -I/usr/include/fribidi -I/usr/include -I/usr/lib/wx/include/gtk3-unicode-3.2 -I/usr/include/wx-3.2 -I/usr/include/AL -I/usr/include/hunspell -I/usr/include/uchardet -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cloudproviders -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glycin-2 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/atk-1.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/pixman-1 -I/usr/include/gio-unix-2.0 -I/usr/include/libmount -I/usr/include/blkid -fdiagnostics-color=always -DNDEBUG -fpch-preprocess -include agi_pre.h -Wall -Winvalid-pch -Wextra -Wpedantic -std=c++20 -O3 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -D_FORTIFY_SOURCE=2 -fPIE -pthread -D_REENTRANT -DWXUSINGDLL -D__WXGTK3__ -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -DBOOST_CHRONO_DYN_LINK=1 -DBOOST_ALL_NO_LIB -MD -MQ aegisub.p/src_ass_exporter.cpp.o -MF aegisub.p/src_ass_exporter.cpp.o.d -o aegisub.p/src_ass_exporter.cpp.o -c ../src/ass_exporter.cpp
cc1plus: warning: aegisub.p/agi_pre.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: agi_pre.h: No such file or directory
compilation terminated.

Reason

This seems down to an unfortunate combination of three factors:

  1. meson will use sccache automatically if it is installed. It's not very well documented, but can be inferred from reading [1] and [2]
  2. sccache does not support PCH well: [3]
  3. Aegisub uses PCH by default

Possible workarounds

  1. Uninstall sccache
  2. Disable meson's sccache usage by setting CC and CXX environment variables to gcc and g++ respectively. A more explicit workaround was requested from meson, but is not implemented.

The workaround 2 does work when building AUR packages too: CC=gcc CXX=g++ makepkg. Make sure to remove the src directory beforehand though, meson aggressively caches the detected compiler.

Possible fixes

I am not sure what would be the best fix for Aegisub. There doesn't seem to be a per-project opt-out from using meson, so the only way I see is disabling use of pre-compiled headers, which will probably make builds slower.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions