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

golangci-lint does not build on darwin-x86_64 - undefined symbols #168984

Closed
wlcx opened this issue Apr 16, 2022 · 7 comments · Fixed by #181669
Closed

golangci-lint does not build on darwin-x86_64 - undefined symbols #168984

wlcx opened this issue Apr 16, 2022 · 7 comments · Fixed by #181669
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin 6.topic: golang

Comments

@wlcx
Copy link
Contributor

wlcx commented Apr 16, 2022

golangci-lint on unstable does not build on darwin-x86_64. This seems to have been caused by #166801 which switched the go version from 1.17 to 1.18 (to fix another (runtime) bug!)

See hydra: https://hydra.nixos.org/job/nixpkgs/trunk/golangci-lint.x86_64-darwin

/nix/store/gynxiihx8rd89nid1ma8pmj9b3nd3kzz-go-1.18.1/share/go/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
Undefined symbols for architecture x86_64:
  "_SecTrustEvaluateWithError", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustEvaluateWithError_trampoline.abi0 in go.o
  "_utimensat", referenced from:
      _syscall.libc_utimensat_trampoline.abi0 in go.o
ld: symbol(s) not found for architecture x86_64
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

FYI (sorry to ping but not really sure who else I would ask)
@arriven @siraben - author/merger of #166801
@Mic92 - arbitrary maintainer

nix run nixpkgs#nix-info -- -m
 - system: `"x86_64-darwin"`
 - host os: `Darwin 20.6.0, macOS 10.16`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.5.1`
 - channels(root): `"nixpkgs-22.05pre344086.568e0bc498e"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
@arriven
Copy link
Contributor

arriven commented Apr 17, 2022

I think the issue is related to this commit in upstream go golang/go@6027b21
Also upstream issue for which that commit was introduced golang/go#49616

@zowoq
Copy link
Contributor

zowoq commented Apr 17, 2022

The stdenv we use for x86_64-darwin is too old, currently it's 10.12. It failed to build in #166801, it should have been marked as broken then. e.g.

# TODO: Remove once nixpkgs uses macOS SDK 10.14+ for x86_64-darwin
# Undefined symbols for architecture x86_64: "_SecTrustEvaluateWithError"
broken = stdenv.isDarwin && stdenv.isx86_64;

@arriven
Copy link
Contributor

arriven commented Apr 17, 2022

@zowoq I'm a bit new to nixos, is that broken declaration used just for the documentation purposes or it may force nixos-rebuild to build the derivation locally if conditions are met?

@eqyiel
Copy link
Contributor

eqyiel commented Apr 25, 2022

@arriven if you need it to build locally in the meantime you can create an overlay like this

self: super: {
  golangci-lint = super.golangci-lint.override ({
    # Override https://github.com/NixOS/nixpkgs/pull/166801 which changed this
    # to buildGo118Module because it does not build on Darwin.
    buildGoModule = super.buildGoModule;
  });
}

And if you're using nixos-rebuild, you can configure nixpkgs.overlays = [ (import /path/to/this/file.nix) ]; or inline it like

{
  # ...

  nixpkgs.overlays = [ 
    (self: super: { 
      # ...
    })
  ];

  # ...
}

@sagikazarmark
Copy link
Member

Unfortunately golangci-lint breaks with Go 1.18 projects if it's built with 1.17 at the moment, so this only works if you run it in a 1.17 project.

YorikSar added a commit to YorikSar/dotfiles that referenced this issue Apr 27, 2022
Fix golangci-lint according to recommendation in comment
NixOS/nixpkgs#168984 (comment)
cixel added a commit to cixel/config that referenced this issue Apr 27, 2022
The update to 1.18 broke hugo and golangci-lint. I wasn't really using
hugo, so I'm just commenting it out for now.

To fix golangci-lint, add an overlay which builds it with 1.17.

See:
 * NixOS/nixpkgs#168984
 * golang/go#49616
@burdiyan
Copy link

Are there any plans to update Apple SDK on x86_64-darwin? I've been dealing with a lot of pain recently using Nix on Darwin because of that.

@sagikazarmark
Copy link
Member

There is an open issue about updating the SDK: #101229

You can try the above comment for changing the Go version back to 1.17.

An alternative is using a prebuilt version of golangci-lint. For example: https://github.com/sagikazarmark/go-bin-flake

(Note: it's not a very nice solution, but works for the moment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin 6.topic: golang
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants