Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: invalid option -E passed to ccache #47092

Closed
abhisekp opened this issue Jul 8, 2021 · 4 comments
Closed

cmd/cgo: invalid option -E passed to ccache #47092

abhisekp opened this issue Jul 8, 2021 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@abhisekp
Copy link

abhisekp commented Jul 8, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/abhisek/.cache/go-build"
GOENV="/home/abhisek/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/abhisek/.gvm/pkgsets/go1.16/global/pkg/mod"
GONOPROXY="bitbucket.org/xxxxxxxxxx"
GONOSUMDB="bitbucket.org/xxxxxxxxxx"
GOOS="linux"
GOPATH="/home/abhisek/.gvm/pkgsets/go1.16/global"
GOPRIVATE="bitbucket.org/xxxxxxxxxx"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/abhisek/.gvm/gos/go1.16"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/abhisek/.gvm/gos/go1.16/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16"
GCCGO="gccgo"
AR="ar"
CC="ccache"
CXX="ccache"
CGO_ENABLED="1"
GOMOD="/home/abhisek/go/src/influxdb/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="gcc -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3058954447=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I installed ccache. From then on I'm getting the issue. I'm not sure how to resolve this.
I've uninstalled ccache, tried to even build ccache from src and install. All in vain.
I also tried reinstalling go.
The current installation is using gvm.
Even I tried reinstalling and using system wide go but I'm always seeing this issue when I run go via cmdline. I do not see this error while running using my IDE. My primary is zsh but I also tried using bash. Same issue.
I also reset my .zshrc file but still the same issue.

What did you expect to see?

▶ go run main.go
<NORMAL OUTPUT>

What did you see instead?

▶ go run main.go
# runtime/cgo
ccache: invalid option -- 'E'
Usage:
    ccache [options]
    ccache compiler [compiler options]
    compiler [compiler options]          (via symbolic link)

Common options:
    -c, --cleanup              delete old files and recalculate size counters
                               (normally not needed as this is done
                               automatically)
    -C, --clear                clear the cache completely (except configuration)
        --config-path PATH     operate on configuration file PATH instead of the
                               default
    -d, --directory PATH       operate on cache directory PATH instead of the
                               default
        --evict-older-than AGE remove files older than AGE (unsigned integer
                               with a d (days) or s (seconds) suffix)
    -F, --max-files NUM        set maximum number of files in cache to NUM (use
                               0 for no limit)
    -M, --max-size SIZE        set maximum size of cache to SIZE (use 0 for no
                               limit); available suffixes: k, M, G, T (decimal)
                               and Ki, Mi, Gi, Ti (binary); default suffix: G
    -X, --recompress LEVEL     recompress the cache to level LEVEL (integer or
                               "uncompressed") using the Zstandard algorithm;
                               see "Cache compression" in the manual for details
    -o, --set-config KEY=VAL   set configuration item KEY to value VAL
    -x, --show-compression     show compression statistics
    -p, --show-config          show current configuration options in
                               human-readable format
    -s, --show-stats           show summary of configuration and statistics
                               counters in human-readable format
    -z, --zero-stats           zero statistics counters

    -h, --help                 print this help text
    -V, --version              print version and copyright information

Options for scripting or debugging:
        --checksum-file PATH   print the checksum (64 bit XXH3) of the file at
                               PATH
        --dump-manifest PATH   dump manifest file at PATH in text format
        --dump-result PATH     dump result file at PATH in text format
        --extract-result PATH  extract data stored in result file at PATH to the
                               current working directory
    -k, --get-config KEY       print the value of configuration key KEY
        --hash-file PATH       print the hash (160 bit BLAKE3) of the file at
                               PATH
        --print-stats          print statistics counter IDs and corresponding
                               values in machine-parsable format

See also the manual on <https://ccache.dev/documentation.html>.
@mknyszek mknyszek changed the title ccache error with go # runtime/cgo ccache: invalid option -- 'E' cmd/cgo: invalid option -E passed to ccache Jul 8, 2021
@mknyszek
Copy link
Contributor

mknyszek commented Jul 8, 2021

I'm not sure I understand the problem (then again, I don't know ccache very well, beyond what it is). That looks like a bad flag passed to ccache, but is it passed by Go? Is the problem that that the Go command and cgo are invoking the C compiler with a flag that ccache doesn't understand? I've updated the title based on this understanding, but if that doesn't seem correct feel free to fix it.

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 8, 2021
@mknyszek mknyszek added this to the Backlog milestone Jul 8, 2021
@mknyszek
Copy link
Contributor

mknyszek commented Jul 8, 2021

FWIW, I'm not sure if you're going to find the expertise on the issue tracker for working with ccache. It might be more productive (and get more visibility from more Go users) if you ask on the golang-nuts Google group. If there's a bug or a feature request or a change you think we should make, then we can follow-up here in the issue tracker.

@mpx
Copy link
Contributor

mpx commented Jul 9, 2021

When ccache is run as cc you should see the usual options including -E. Your go env output shows that CC and CXX are incorrectly set to ccache. cc is typically a symbolic link to ccache and it wraps the underlying compiler.

Some Linux distrbutions use ccache as the default compiler, and I've found it generally works fine with the Go toolchain.

@ianlancetaylor
Copy link
Contributor

I agree: the ccache command is not a compiler, and you should not set the environment variable CC to ccache. Closing because this is not a bug in Go.

@golang golang locked and limited conversation to collaborators Jul 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants