Skip to content

Commit 756865d

Browse files
committed
grafana: Fix cross
``` go-1.25.4/share/go/pkg/tool/linux_amd64/link: running aarch64-unknown-linux-gnu-gcc failed: exit status 1 aarch64-unknown-linux-gnu-gcc -m64 -s -o $WORK/b001/exe/gen -rdynamic /build/go-link-507658645/go.o aarch64-unknown-linux-gnu-gcc: error: unrecognized command-line option '-m64' ``` Above error happens because something `go generate` uses `$CC` which is the for host compiler https://www.github.com/golang/go/blob/b194f5d24a71e34f147c90e4351d80ac75be55de/src/cmd/cgo/gcc.go#L1763 https://www.github.com/golang/go/blob/b194f5d24a71e34f147c90e4351d80ac75be55de/src/cmd/cgo/gcc.go#L1724 `CGO_DISABLED=0` used to work to disable compiler usage but it does not work anymore.
1 parent 388709d commit 756865d

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

pkgs/servers/monitoring/grafana/default.nix

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
tzdata,
88
wire,
99
yarn-berry_4,
10+
yarn-berry_4-fetcher,
11+
buildPackages,
1012
python3,
1113
jq,
1214
moreutils,
@@ -44,7 +46,8 @@ buildGoModule (finalAttrs: {
4446
};
4547

4648
missingHashes = ./missing-hashes.json;
47-
offlineCache = yarn-berry_4.fetchYarnBerryDeps {
49+
# Since this is not a dependency attribute the buildPackages has to be specified.
50+
offlineCache = buildPackages.yarn-berry_4-fetcher.fetchYarnBerryDeps {
4851
inherit (finalAttrs) src missingHashes;
4952
hash = "sha256-CAEhdKsFMUuIs8DsJ9xSr2FRdBp4fPUWyvjC6FuiyG8=";
5053
};
@@ -69,17 +72,19 @@ buildGoModule (finalAttrs: {
6972

7073
proxyVendor = true;
7174

75+
depsBuildBuild = [ buildPackages.stdenv.cc ];
76+
7277
nativeBuildInputs = [
7378
wire
7479
jq
7580
moreutils
7681
removeReferencesTo
7782
# required to run old node-gyp
78-
(python3.withPackages (ps: [ ps.distutils ]))
83+
(python3.pythonOnBuildForHost.withPackages (ps: [ ps.distutils ]))
7984
faketty
8085
nodejs
8186
yarn-berry_4
82-
yarn-berry_4.yarnBerryConfigHook
87+
yarn-berry_4-fetcher.yarnBerryConfigHook
8388
]
8489
++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild.xcbuild ];
8590

@@ -88,7 +93,7 @@ buildGoModule (finalAttrs: {
8893
overrideModAttrs = (
8994
old: {
9095
nativeBuildInputs = lib.filter (
91-
x: lib.getName x != (lib.getName yarn-berry_4.yarnBerryConfigHook)
96+
x: lib.getName x != (lib.getName buildPackages.yarn-berry_4-fetcher.yarnBerryConfigHook)
9297
) old.nativeBuildInputs;
9398
}
9499
);
@@ -99,9 +104,14 @@ buildGoModule (finalAttrs: {
99104
wire gen -tags oss ./pkg/server
100105
wire gen -tags oss ./pkg/cmd/grafana-cli/runner
101106
102-
GOARCH= CGO_ENABLED=0 go generate ./kinds/gen.go
103-
GOARCH= CGO_ENABLED=0 go generate ./public/app/plugins/gen.go
104-
107+
# ```
108+
# go-1.25.4/share/go/pkg/tool/linux_amd64/link: running aarch64-unknown-linux-gnu-gcc failed: exit status 1
109+
# aarch64-unknown-linux-gnu-gcc -m64 -s -o $WORK/b001/exe/gen -rdynamic /build/go-link-507658645/go.o
110+
# aarch64-unknown-linux-gnu-gcc: error: unrecognized command-line option '-m64'
111+
# ```
112+
# Above log is due to https://github.com/golang/go/blob/b194f5d24a71e34f147c90e4351d80ac75be55de/src/cmd/cgo/gcc.go#L1763
113+
CC="$CC_FOR_BUILD" LD="$CC_FOR_BUILD" GOOS= GOARCH= CGO_ENABLED=0 go generate ./kinds/gen.go
114+
CC="$CC_FOR_BUILD" LD="$LD_FOR_BUILD" GOOS= GOARCH= CGO_ENABLED=0 go generate ./public/app/plugins/gen.go
105115
'';
106116

107117
postBuild = ''

0 commit comments

Comments
 (0)