The problem
One liner is enough to crash ccache-4.3 on linux (no real files needed):
$ CCACHE_BASEDIR=$PWD PWD=. ccache x86_64-pc-linux-gnu-gcc -c -o $PWD/a.o a.c
ccache: Util.cpp:731: std::string Util::get_relative_path(nonstd::sv_lite::string_view, nonstd::sv_lite::string_view): failed assertion: Util::is_absolute_path(dir)
Aborted (core dumped)
It looks like ccache assumes that PWD is an absolute path. go build seems to violate that assumption by explicitly setting PWD=. around it's syscall.exec wrapper.
Background
Originally I noticed the failure on a https://github.com/opencontainers/runc project when built a Gentoo package where we expliictly force external linker as gcc driver (wrapped by ccache):
cd .
/usr/lib/go/pkg/tool/linux_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -installsuffix shared -buildmode=pie -buildid=Q7_wZ_YlesqPCjBc6U2F/RBxeVJ4mTbNE9awu8_Te/Bm_l1y2h5QdMzXxLgLUh/Q7_wZ_YlesqPCjBc6U2F -X main.gitCommit=ff819c7e9184c13b7c2607fe6c30ae19403a7aff -X main.version=1.0.0-rc92 -extld=x86_64-pc-linux-gnu-gcc $WORK/b001/_pkg_.a
# github.com/opencontainers/runc
/usr/lib/go/pkg/tool/linux_amd64/link: running x86_64-pc-linux-gnu-gcc failed: signal: aborted (core dumped)
ccache: Util.cpp:731: std::string Util::get_relative_path(nonstd::sv_lite::string_view, nonstd::sv_lite::string_view): failed assertion: Util::is_absolute_path(dir)
make: *** [Makefile:34: runc] Error 2
The above smaller example was extracted from it.
The problem
One liner is enough to crash
ccache-4.3on linux (no real files needed):It looks like
ccacheassumes thatPWDis an absolute path.go buildseems to violate that assumption by explicitly settingPWD=.around it'ssyscall.execwrapper.Background
Originally I noticed the failure on a https://github.com/opencontainers/runc project when built a Gentoo package where we expliictly force external linker as
gccdriver (wrapped by ccache):The above smaller example was extracted from it.