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

Error when trying to build nomad master on apple M2 #5

Closed
valodzka opened this issue Mar 30, 2023 · 8 comments
Closed

Error when trying to build nomad master on apple M2 #5

valodzka opened this issue Mar 30, 2023 · 8 comments

Comments

@valodzka
Copy link

# github.com/shoenig/go-m1cpu
../gopath/pkg/mod/github.com/shoenig/go-m1cpu@v0.1.4/cpu.go:65:33: error: use of undeclared identifier 'kIOMainPortDefault'; did you mean 'kIOMasterPortDefault'?
   IOServiceGetMatchingServices(kIOMainPortDefault, matching, &iter);
                                ^~~~~~~~~~~~~~~~~~
                                kIOMasterPortDefault
/nix/store/qgi0x5iwmrbxvbjfqx1kbc16xj49pnk1-apple-framework-IOKit-11.0.0/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:103:19: note: 'kIOMasterPortDefault' declared here
const mach_port_t kIOMasterPortDefault;
                  ^
1 error generated.
make[1]: *** [GNUmakefile:97: pkg/darwin_arm64/nomad] Error 2
make: *** [GNUmakefile:267: dev] Error 2
@shoenig
Copy link
Owner

shoenig commented Mar 30, 2023

Hi @valodzka it looks like you're using Nix, and I suspect that's related. Building Nomad works fine for me using just a normal git clone and make dev

➜ uname -a
Darwin malice.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:46 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6020 arm64
➜ git clone https://github.com/hashicorp/nomad
Cloning into 'nomad'...
remote: Enumerating objects: 250132, done.
remote: Counting objects: 100% (184/184), done.
remote: Compressing objects: 100% (108/108), done.
remote: Total 250132 (delta 88), reused 143 (delta 74), pack-reused 249948
Receiving objects: 100% (250132/250132), 371.87 MiB | 29.92 MiB/s, done.
Resolving deltas: 100% (175531/175531), done.
nomad on main
➜ make dev
==> Formatting HCL
==> Removing old development build...
==> Building pkg/darwin_arm64/nomad with tags ui  ...
go: downloading github.com/mitchellh/go-testing-interface v1.14.2-0.20210821155943-2d9075ca8770
go: downloading github.com/opencontainers/runc v1.1.5

nomad on main
➜ file pkg/darwin_arm64/nomad
pkg/darwin_arm64/nomad: Mach-O 64-bit executable arm64

@valodzka
Copy link
Author

valodzka commented Mar 30, 2023

It looks like you're using Nix, and I suspect that's related

Yes, it's build using nix-shell (very basic only for go installation and without isolation so I'm not sure if it is related).

uname -a
Darwin aden.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct  9 20:19:12 PDT 2022; root:xnu-8792.41.9~3/RELEASE_ARM64_T6020 arm64 arm Darwin

For the reference v1.5.2 is working for me:

$ git checkout v1.5.2
Previous HEAD position was 77719aac9 fix host port handling for ipv6, fixes #16550
HEAD is now at 9a2fdb5f5 Generate files for 1.5.2 release

$ make dev
==> Formatting HCL
==> Removing old development build...
==> Building pkg/darwin_arm64/nomad with tags ui  ...
go: downloading github.com/shoenig/test v0.6.2

$ git reset --hard 03a90f497aad75c8a505be2661e3f39daa1db6fc
HEAD is now at 03a90f497 docker: move pause container recovery to after `SetConfig` (#16713)

$ make dev
==> Formatting HCL
==> Removing old development build...
==> Building pkg/darwin_arm64/nomad with tags ui  ...
# github.com/shoenig/go-m1cpu
../gopath/pkg/mod/github.com/shoenig/go-m1cpu@v0.1.4/cpu.go:65:33: error: use of undeclared identifier 'kIOMainPortDefault'; did you mean 'kIOMasterPortDefault'?
   IOServiceGetMatchingServices(kIOMainPortDefault, matching, &iter);
                                ^~~~~~~~~~~~~~~~~~
                                kIOMasterPortDefault
/nix/store/qgi0x5iwmrbxvbjfqx1kbc16xj49pnk1-apple-framework-IOKit-11.0.0/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:103:19: note: 'kIOMasterPortDefault' declared here
const mach_port_t kIOMasterPortDefault;
                  ^
1 error generated.
make[1]: *** [GNUmakefile:97: pkg/darwin_arm64/nomad] Error 2
make: *** [GNUmakefile:267: dev] Error 2

apple-framework-IOKit-11.0.0 is it supported version or some other required?

@shoenig
Copy link
Owner

shoenig commented Mar 30, 2023

So if I lookup IOKit in the System Info app, I see

IOKit:

  Version:	2.0.2
  Obtained from:	Unknown
  Last Modified:	2/9/23, 3:39 AM
  Get Info String:	I/O Kit Framework, Apple Computer Inc
  Location:	/System/Library/Frameworks/IOKit.framework
  Private:	No

And I think you'd also need the CoreFoundation framework,

CoreFoundation:

  Version:	6.9
  Obtained from:	Unknown
  Last Modified:	2/9/23, 3:39 AM
  Location:	/System/Library/Frameworks/CoreFoundation.framework
  Private:	No

@ZhongRuoyu
Copy link
Contributor

It seems that Nix is using an older SDK. This should be fixed by #6.

@ZhongRuoyu
Copy link
Contributor

For the reference v1.5.2 is working for me:

m1cpu was only added to nomad after the 1.5.2 release: hashicorp/nomad#16672

shoenig added a commit to hashicorp/nomad that referenced this issue Apr 5, 2023
https://github.com/shoenig/go-m1cpu/releases/tag/v0.1.5

which may also help with the Nix package for Nomad, which makes use of
the older IOKit framework version

shoenig/go-m1cpu#5
shoenig added a commit to hashicorp/nomad that referenced this issue Apr 5, 2023
https://github.com/shoenig/go-m1cpu/releases/tag/v0.1.5

which may also help with the Nix package for Nomad, which makes use of
the older IOKit framework version

shoenig/go-m1cpu#5
@shoenig
Copy link
Owner

shoenig commented Apr 5, 2023

@valodzka can you try again building Nomad from main? We just pulled in the fix above for Big Sur users which may help here.

@valodzka
Copy link
Author

valodzka commented Apr 6, 2023

Yes, it works now.
By the way I tried to build nomad only for this pull request hashicorp/nomad#16723
It pretty trivial but solves some anoyance when using ipv6 with nomad. I'll apreciate if you will take a look.

@valodzka valodzka closed this as completed Apr 6, 2023
shoenig added a commit to hashicorp/nomad that referenced this issue Apr 10, 2023
https://github.com/shoenig/go-m1cpu/releases/tag/v0.1.5

which may also help with the Nix package for Nomad, which makes use of
the older IOKit framework version

shoenig/go-m1cpu#5
@CorbanR
Copy link

CorbanR commented Jul 5, 2023

interestingly enough I'm still getting this issue on an M2 for both nomad and rclone. I am also using NIX.

It appears that rclone very recently updated the go-m1cpu to v0.1.6 as of about 4 days ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants