Skip to content

cmd/compile: -embedcfg flag is undocumented #71942

@pjebs

Description

@pjebs

Go version

go 1.24.0

Output of go env in your module/workspace:

AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/x/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/x/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/15/70nsj6sx3ln38_59dth_0p2w0000gn/T/go-build897804675=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/x/Documents/compiler/go.mod'
GOMODCACHE='/Users/x/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/x/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/Cellar/go/1.24.0/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/x/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/Cellar/go/1.24.0/libexec/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I have a sub-package (hence no go.mod):

=== name.txt ===
X-MEN

=== sub.go ===
package sub

import _ "embed"


//go:embed name.txt
var Name string

I ran go tool compile -importcfg importcfg

=== importcfg ===
packagefile internal/goarch=/Users/x/Library/Caches/go-build/f6/f65dfbc44b7fc3256f82a913154e9b346ba39604d4215d25ea8209ca7a06c414-d
packagefile internal/abi=/Users/x/Library/Caches/go-build/e8/e81f4d153c4ecd6e5a65208601c8d7b94e22bdc6dfc9a9d8748f7f96835a1288-d
packagefile internal/unsafeheader=/Users/x/Library/Caches/go-build/30/30ae79d8bb02cb48dc8dfb22d8c6fe566f053f19ed48807ee4afb4f17d9c79ec-d
packagefile internal/cpu=/Users/x/Library/Caches/go-build/1d/1dc1423b7d1cd33482d1bb462938442063f34f6d6cfc4658c9aac7fba32528a1-d
packagefile internal/bytealg=/Users/x/Library/Caches/go-build/af/af0d8e7da0088e05c6f21b664e4490c0b9eae31056211781a7bb569bc8ce34f3-d
packagefile internal/byteorder=/Users/x/Library/Caches/go-build/e3/e31305e922cc6b0824d91a1e6dc86fe28bbe0faeb5002d4632f36a142fba6608-d
packagefile internal/chacha8rand=/Users/x/Library/Caches/go-build/62/62472955c90055aa6f4aafd26ddfb7b17cabcc56cb3d996ce127438dc6847b92-d
packagefile internal/coverage/rtcov=/Users/x/Library/Caches/go-build/e9/e936ae6477e50e97428eb73a547c464b50438547fd00f3ec9816f6e0089726b2-d
packagefile internal/godebugs=/Users/x/Library/Caches/go-build/ca/ca53f641aa6f01f90c272e67cd032e5b7dad14a3327dad0bee410d9817ed70d4-d
packagefile internal/goexperiment=/Users/x/Library/Caches/go-build/02/02740d9b59da9f160fee17509acc6fbffcd50981a9364d2b250cc718bff68be6-d
packagefile internal/goos=/Users/x/Library/Caches/go-build/f8/f855b7b73cf8645d28b92a304a809410272b7f183c39afaeb3390ac9c1ed0b9c-d
packagefile internal/profilerecord=/Users/x/Library/Caches/go-build/cb/cbb1ebb0e2cb64d1161550a7960df855213d7d5976668bf9b136e83f1d187a3d-d
packagefile internal/runtime/atomic=/Users/x/Library/Caches/go-build/fe/fe1bd249d67e1a9b521c2957d966ec1181f2c696c3cf3f5ca80130b043bab0c3-d
packagefile internal/runtime/exithook=/Users/x/Library/Caches/go-build/1f/1f7313f524c9bdec913b683bb93120ce7e8b11697e4b195821bf40b5775cad78-d
packagefile internal/asan=/Users/x/Library/Caches/go-build/7d/7dad48e87431f736bb3b1acdcaaba7bd954049d91e0848fc4f07337807e800fd-d
packagefile internal/msan=/Users/x/Library/Caches/go-build/19/1902c3631e862edd6e17f63581f5d4939f387a5252bcab5bc5a4ed9cea013184-d
packagefile internal/race=/Users/x/Library/Caches/go-build/9d/9d0b0b84d24764133b8bc3c45505b7904236a2066a3320cb5883df5c946bc405-d
packagefile internal/runtime/math=/Users/x/Library/Caches/go-build/5a/5abaef58cc2f484eae13611c76ba8a3a95447e86c0d99de0fb11d6e4aeb95614-d
packagefile internal/runtime/sys=/Users/x/Library/Caches/go-build/23/23a5ce86acee3b8b62cd4a6d6ecccb05e42e874930ff3595a93041f16180f0d7-d
packagefile internal/runtime/maps=/Users/x/Library/Caches/go-build/15/1596bb4293372ac631b092ee7ba7bac21750a5ab48e8e7d2eab9cbc95b380d19-d
packagefile internal/stringslite=/Users/x/Library/Caches/go-build/c9/c972a2d0d193ba8cf5f3aa1c9d532fd843c94ab61c308a32986256154d8ce138-d
packagefile runtime=/Users/x/Library/Caches/go-build/d4/d4e452e1de6af1745a89ea54aa79be9981095e05f2af7ea40a677aa3c0e4d283-d
packagefile internal/reflectlite=/Users/x/Library/Caches/go-build/a1/a161093bc46e0fb4c4892a246a0b4e01be09906f0569a4ccf588e7731562175e-d
packagefile errors=/Users/x/Library/Caches/go-build/29/298afc218eff7183e2e0f4b3f064aaed72c7d2676fa1f3b255f3eebb62870f95-d
packagefile sync/atomic=/Users/x/Library/Caches/go-build/69/695b76f5d8491e0db427cfeec117cf33e429e6de77dd6d1cdb421414c259ba91-d
packagefile internal/sync=/Users/x/Library/Caches/go-build/81/81490f1daaf2269e415d03d315fc7aea3010aaee2b187acc004da84bd16e6f4c-d
packagefile sync=/Users/x/Library/Caches/go-build/22/226b41001111550658ef9252c3aa17ad49217d534e128f7a9d797325af3f94b7-d
packagefile io=/Users/x/Library/Caches/go-build/27/275c6b54095daf676f8bce5c9c163aa713581bcedff1755c11c230c4ec197b4d-d
packagefile internal/oserror=/Users/x/Library/Caches/go-build/84/843f5514d617999f66d552914cb5e694b0be6a5914cb250ecd30c097b9513cda-d
packagefile unicode/utf8=/Users/x/Library/Caches/go-build/c3/c3d780b02dd4c29ccb0866def62a5ed6ea46cc3c25b71f84c49e8e392997b022-d
packagefile path=/Users/x/Library/Caches/go-build/76/76cf82bbce3b17890d46aaf5a9d6bd472522138b712167c08fd9cc7f7a52a45f-d
packagefile cmp=/Users/x/Library/Caches/go-build/68/68a77cfe6dd685c840ceca81453a4351aabdae8033d4a838df2e27c7fc9544b5-d
packagefile iter=/Users/x/Library/Caches/go-build/77/77840c3b8b6e578efd7fc68dab2467ed0abb847424d93bba2e886b443e56cbda-d
packagefile math/bits=/Users/x/Library/Caches/go-build/28/28fa9b5ca6ef50f443e2da99f46858ac7d9b344a8d7ec47c026f97c0598fdd4d-d
packagefile slices=/Users/x/Library/Caches/go-build/e0/e069f94148905826fa9dfbff5405927252a6498f4e71fba5069c658f3d3a3733-d
packagefile internal/bisect=/Users/x/Library/Caches/go-build/a0/a014bbe344c982107d70bc446e37b9ce8a5494f4370ee841a32da9e80d4d1541-d
packagefile internal/godebug=/Users/x/Library/Caches/go-build/2a/2a88c366f381329f249f9be40c7d05939e5d49278e2ce96d0823f8703de9eac8-d
packagefile internal/itoa=/Users/x/Library/Caches/go-build/5d/5d82ffc935c498db3ff85d57b0f4339755b543f9d619d166a25677bb76d8d40a-d
packagefile syscall=/Users/x/Library/Caches/go-build/cb/cb0339b99962e3289e196e461df7ee2ca197f5a9689b3947adeb1e77c8f4a32b-d
packagefile time=/Users/x/Library/Caches/go-build/f2/f2702e22ca4bd59ab326cf9cb8f339abf3570a65b528185116fc754e253377e2-d
packagefile io/fs=/Users/x/Library/Caches/go-build/0f/0fe00edcf1c24f7463232934fe6109de6fb94d7b58fe0dbf5192078d303ef4ad-d
packagefile embed=/Users/x/Library/Caches/go-build/82/82605b3dd8baaceebca51df7fd6ad8e0a3c4ef3fbf8c8ef2d0351074adda24bb-d
packagefile test/plugin/sub/tmp1671232560/src=/Users/x/Library/Caches/go-build/a4/a4a3c6fcafa07452587656b00f9446c00bab5e6444612b22bd21cdb13eefbb48-d

What did you see happen?

Error:

invalid go:embed: build system did not supply embed configuration

What did you expect to see?

I expected it to successfully compile and produce an *.o or *.a file.

Running it with go build ... works. It successfully sees the file and embeds it.

If it's not allowed, the https://pkg.go.dev/cmd/compile documentation should make note of that.

NOTE: When I remove the embed directive, it works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.DocumentationIssues describing a change to documentation.FrozenDueToAgecompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions