Skip to content

golang's go build sometimes uses PWD=. and triggers ccache assertions like 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) #860

@trofi

Description

@trofi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugDoes not work as intended/documented

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions