Bug 256008 - Mk/Uses/linux.mk: Add support for arm64/aarch64 (Linuxulator supports these ARCHS)
Summary: Mk/Uses/linux.mk: Add support for arm64/aarch64 (Linuxulator supports these A...
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Port Management Team
URL: https://github.com/freebsd/freebsd-po...
Keywords: feature, needs-qa
Depends on:
Blocks: 247219
  Show dependency treegraph
 
Reported: 2021-05-19 17:49 UTC by Ed Maste
Modified: 2021-08-04 02:30 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2021-05-19 17:49:19 UTC
Mk/Uses/linux.mk has:

.ifndef ONLY_FOR_ARCHS
ONLY_FOR_ARCHS=         amd64 i386
ONLY_FOR_ARCHS_REASON=  Linux compatibility is only available on amd64 and i386
.endif

Linuxulator also supports arm64/aarch64 (support started being added in 2018). There are increasing amounts of bug fixes over time and we could limit ports support to FreeBSD 13 and up.
Comment 1 Vincent Milum Jr 2021-07-15 07:29:50 UTC
Just noting here so we have a reference point.

The editors/sublime-text4 port is using this feature on Aarch64 and is the perfect test case to validate when it works.

This was briefly discussed on Twitter: https://twitter.com/Ericbsd/status/1415402574728077313
Comment 2 Vincent Milum Jr 2021-07-17 19:42:36 UTC
Okay, this is turning into a much larger body of work, so I'm going to start documenting things as I find them.

1) bsd.sites.mk also needs updating to include aarch64 before linux.mk will work. Both in the centos and epel7 sections need aarch64 support.

2) emulators/linux_base-c7: compat-libstdc++-33-3.2.3-72.el7 doesn't exist on aarch64.

3) emulators/linux_base-c7: redhat-lsb-core has a different filename between i386/amd64 and aarch64.

Currently it looks like linux.mk assumes that all archs have the same file list when doing a "makesum" - this assumption is no longer true on aarch64 with the two noted files above. We'll need to come up with a way to provide a dynamic file list that'll work on all arches for makesum to work properly.
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2021-07-18 02:24:11 UTC
@Ed/Vince If this ends up being a tracking issue, please feel free to self-assign and created separate dependent issues
Comment 4 Vincent Milum Jr 2021-07-19 03:40:27 UTC
Here is my personal work-in-progress attempt to get emulators/linux_base-c7 working.

Currently, its pulling in a PLIST from some unknown location, so throwing errors attempting to make the package. Even outright deleting the pkg-plist.amd64 and pkg-plist.i386 files, there are still references to i386 being included SOMEWHERE. I'm currently at a loss on this one.

https://github.com/darkain/freebsd-ports/commit/e44f5edb91f8d354debdaf343694793b9f52854a
Comment 5 Vincent Milum Jr 2021-07-24 20:15:55 UTC
https://reviews.freebsd.org/D29288
"Fix the 'linux' rc script on aarch64"

This will need to be backported to 13-STABLE

Also, things are starting to work! :-O

https://twitter.com/DarkainMX/status/1419018099668316165
Comment 6 Vincent Milum Jr 2021-07-25 20:33:58 UTC
Patch set:
https://patch-diff.githubusercontent.com/raw/freebsd/freebsd-ports/pull/113.diff

WARNING: SOME OF THESE CHANGE BREAK I386/AMD64

TODO:

- Check each individual c7 port to see if they have architecture specific pkg-plist files, and generate a new file for Aarch64

- linux-c7-dri is all kinds of broken and has sections of i386/amd64 upstream packages commented out, rather than properly architecture gated

- At least one port had issues with DISTFILES, but I don't remember which or what that issue was off the top of my head. This issue only effected "makesum" though, so I temporarily disabled DISTFILES while making the checksums on one of these, and then re-enabled it afterwards.
Comment 7 Vincent Milum Jr 2021-08-01 06:24:47 UTC
Updated almost all C7 ports to build on Aarch64. Currently there are 7 left giving me troubles that I've yet to look into exactly why, but should be easy enough to tackle once I get some time.

Remaining 7 ports:
devel/linux-c7-strace
devel/linux-c7-sdl20
audio/linux-c7-alsa-plugins-oss
audio/linux-c7-libsndfile
audio/linux-c7-pulseaudio-libs
audio/linux-c7-flac
audio/linux-c7-alsa-plugins-pulseaudio
Comment 8 Edward Tomasz Napierala freebsd_committer 2021-08-02 13:45:33 UTC
Nice!  Note that linux-c7-strace one isn’t going to work as-is, due to ptrace(2) missing on aarch64.  But let me know when you have the port ready; implementing ptrace(2) is on my TODO list.
Comment 9 Vincent Milum Jr 2021-08-02 17:19:28 UTC
> linux-c7-strace one isn’t going to work as-is, due to ptrace(2) missing on aarch64.

That's really handy to know! 

Yeah, right now, I've just been making sure the ports properly extract the upstream archives and put files in the correct places, and then have an updated plist file to built a FreeBSD package out of. 

Only a small handful of the ports have I actively tried using and running.

Several though, I'm not sure exactly how to test, since many are just a single shared object file, and not knowing what relies on those to test with.
Comment 10 Vincent Milum Jr 2021-08-03 00:29:05 UTC
(In reply to Edward Tomasz Napierala from comment #8)

I went back and looked at what was wrong with linux-c7-strace, it was just a 32-bit vs 64-bit dependency reference in the Makefile. So the port is good, just need that ptrace(2) work now!

https://github.com/freebsd/freebsd-ports/pull/113/commits/f8deb033a14a905048eaddc51a370a80f15272fa