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

Can't built main on M1 #84

Open
buffalu opened this issue Dec 1, 2021 · 13 comments
Open

Can't built main on M1 #84

buffalu opened this issue Dec 1, 2021 · 13 comments

Comments

@buffalu
Copy link

buffalu commented Dec 1, 2021

Sup mango team.

I can't build on main right now, seems like something wrong with switchboard dependency. This only happens on M1. If I sync to a build server + build, its okay

   Compiling switchboard-utils v0.1.29
error[E0080]: evaluation of constant value failed
  --> /Users/.../.cargo/registry/src/github.com-1ecc6299db9ec823/switchboard-utils-0.1.29/src/lib.rs:19:18
   |
19 | #[derive(Default,AsBytes,FromBytes,Clone,Debug)]
   |                  ^^^^^^^ attempt to divide `1_usize` by zero
   |
   = note: this error originates in the derive macro `AsBytes` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0080`.
error: could not compile `switchboard-utils` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed

mango-v3 % rustup --version
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.59.0-nightly (207c80f10 2021-11-30)`

% rustc --version
rustc 1.59.0-nightly (207c80f10 2021-11-30)
@buffalu buffalu changed the title Can't built main Can't built main on M1 Dec 1, 2021
@mschneider
Copy link
Contributor

mschneider commented Dec 1, 2021 via email

@dafyddd
Copy link
Contributor

dafyddd commented Dec 1, 2021

I think the solana compiler comes with a rustc. And I use solana-cli 1.8 to compile and don't have any issues.

@bolerap
Copy link

bolerap commented Jan 9, 2022

same error, I also tried with rustc 1.57.0-nightly (2021-09-07) same error. What wrong with me?

@microwavedcola1
Copy link
Contributor

@thanhngvpt @buffalu are you guys using rosetta compatibility mode? m1 is my main driver, and havent had any issues so far

@RohanKapurDEV
Copy link

havent had any issues building on m1 either

@sthornington
Copy link

sthornington commented Mar 3, 2022

The root cause of this is that mango (and switchboard) have #[repr(C)] for some account data structs (SwitchboardDecimal, *Node in matching.rs and *Event in queue.rs), but on ARM, the alignment of i128 is 16 bytes, vs 8 bytes for x86_64. These structs should all be #[repr(packed)] in my opinion, as they are in the serum dex examples.

@sthornington
Copy link

In fact, it looks like SwitchboardDecimal is already packed in the latest...

@sthornington
Copy link

@ckamm did you have any luck upgrading switchboard? I see you pinned the versions to older ones fairly recently...

@ckamm
Copy link
Contributor

ckamm commented Mar 3, 2022

Upgrading switchboard wasn't a priority so I haven't looked at it further. This PR has an upgrade though: #150

@sthornington
Copy link

Gotcha. Yeah I haven’t gotten further enough to see whether switching all the account state structs to repr(packed) fixes everything else. I suspect one day everyone will be forced to switch to proper serdes using borsh rather than bytemuck casting.

@smu160
Copy link

smu160 commented Mar 14, 2022

I ran into the same issue, and I was able to rectify the issue with rustup by switching the active tool-chain.

You can confirm by running: rustup show. If you see stable-x86_64-apple-darwin (default) under active toolchain, you're good to go.

Otherwise, do as follows:

rustup default stable-x86_64-apple-darwin

Try it out:

cargo build

You should be able to build without any platform specific issues now.

@sthornington
Copy link

Yes of course you can fix an issue with bad alignment on ARM by not compiling on ARM. 😀

@namnh06
Copy link

namnh06 commented Apr 18, 2022

I've got the same issue with Ubuntu 20.04
image
image

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

10 participants