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

Support building on arm64 macOS #1460

Merged
merged 1 commit into from Jan 18, 2021

Conversation

m0rg-dev
Copy link
Contributor

What it says on the tin.

As it stands right now building rpm natively on a M1 box just gets you error: No compatible architectures found for build if you try to rpmbuild anything, so we need to detect when __arm64__ is defined and set the build architecture to aarch64.

lib/rpmrc.c Outdated
@@ -1039,6 +1039,8 @@ static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os)
strcpy(un.machine, "i386");
#elif defined(__x86_64__)
strcpy(un.machine, "x86_64");
#elif defined(__arm64__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The preferred define from ARM is __aarch64__, can you change to that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done.

@Conan-Kudo
Copy link
Member

@digitalagedragon The change looks good, could you squash the new commit into the original one and add in the body of the commit why this is being done?

Previously, trying to run rpmbuild on a M1 machine returns "error: No compatible architectures found for build".
Since RPM detects its architecture on macOS just by looking at what architecture flags are defined at compile time, this adds a clause to detect aarch64.
@m0rg-dev
Copy link
Contributor Author

How's that look?

@pmatilai
Copy link
Member

Looks fine to me as such.

But just out of curiosity, what does uname return on these systems? The OSX detection code originates from sometime 2005, which is a long long time ago...

@m0rg-dev
Copy link
Contributor Author

It returns arm64.

Honestly, I'm not sure why rpm doesn't just use un.machine directly (perhaps with an explicit s/arm64/aarch64/ case now), but defaultMachine is pretty vigilant about not trusting un.machine on any system so I figure there's some kind of reason...

@rb2k
Copy link
Contributor

rb2k commented Dec 21, 2020

Semi related: For enabling NDB you would need a small amount of patching.
We've had this patch running in production for a while and it seems to do the trick on macOS:

#1465

@pmatilai
Copy link
Member

Fair enough. The arch detection in rpm is just crazy, but that's not your fault...
Thanks for the patch!

@pmatilai pmatilai merged commit 4345ee0 into rpm-software-management:master Jan 18, 2021
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

Successfully merging this pull request may close these issues.

None yet

4 participants