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

Build ffmpeg for linux-arm, linux-arm64, linux-x86 #6288

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

kvnp
Copy link

@kvnp kvnp commented May 19, 2024

This PR adds the targets linux-arm, linux-arm64 as part of ppy/osu-deploy#170. Will be updated once #6255 is merged.

@kvnp kvnp changed the title Add targets linux-arm, linux-arm64 Build ffmpeg for linux-arm, linux-arm64 May 19, 2024
@bdach bdach requested a review from FreezyLemon May 20, 2024 06:39
Copy link
Contributor

@FreezyLemon FreezyLemon left a comment

Choose a reason for hiding this comment

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

Some notes:

  • Please remove changes not related to the Linux build (macOS bump, merging the Windows build process). These are out of scope and maybe change the resulting binaries which would need testing
  • The x86 build doesn't work. x86 support is not necessary so you don't need to include it at all, but if you do want to include it, please make sure it works.

I wonder if there's a way to achieve the same builds using cross-compilation similar to the Windows build scripts. That would make it a lot easier to compile these locally (installing QEMU and docker is fairly hefty for these simple builds). That said, it's not a high priority or blocking issue.

.github/workflows/build-ffmpeg.yml Outdated Show resolved Hide resolved
Comment on lines 131 to 141
strategy:
matrix:
include:
- { name: macOS-universal, path: osu.Framework.NativeLibs/runtimes/osx/native }
- { name: linux-arm64, path: osu.Framework.NativeLibs/runtimes/linux-arm64/native}
- { name: linux-arm, path: osu.Framework.NativeLibs/runtimes/linux-arm/native}
- { name: linux-x64, path: osu.Framework.NativeLibs/runtimes/linux-x64/native}
- { name: linux-x86, path: osu.Framework.NativeLibs/runtimes/linux-x86/native}
- { name: win-arm64, path: osu.Framework.NativeLibs/runtimes/win-arm64/native}
- { name: win-x64, path: osu.Framework.NativeLibs/runtimes/win-x64/native}
- { name: win-x86, path: osu.Framework.NativeLibs/runtimes/win-x86/native}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a fan of this. This will create 8 separate "Update FFmpeg binaries" PRs every time this workflow is run.

options: -v ${{ github.workspace }}:/workspace -w /workspace -e DEBIAN_FRONTEND=noninteractive
run: |
apt-get update -y -qq
apt-get install -y build-essential curl nasm libva-dev libvdpau-dev
Copy link
Contributor

Choose a reason for hiding this comment

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

libva-dev and libvdpau-dev can be removed from this list. They are from an older version of the build process but were accidentally kept in the dependency list.

nasm is only required for x86 and x86_64 builds.

Comment on lines 21 to 33

if [ $(uname -m) == "x86_64" ]; then
ARCH="x64"
elif [ $(uname -m) == "i686" ]; then
ARCH="x86"
elif [ $(uname -m) == "aarch64" ]; then
ARCH="arm64"
elif [ $(uname -m) == "armv7l" ]; then
ARCH="arm"
else
echo "Unsupported architecture: $(uname -m)"
exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this to the top (like the arch-related stuff in the other build scripts)

Co-authored-by: FreezyLemon <[email protected]>
@smoogipoo
Copy link
Contributor

This one can be updated now that #6255 has been merged.

@pull-request-size pull-request-size bot added size/M and removed size/L labels Jul 6, 2024
@kvnp
Copy link
Author

kvnp commented Jul 6, 2024

Some notes:

  • Please remove changes not related to the Linux build (macOS bump, merging the Windows build process). These are out of scope and maybe change the resulting binaries which would need testing
  • The x86 build doesn't work. x86 support is not necessary so you don't need to include it at all, but if you do want to include it, please make sure it works.

linux-x86 now builds after disabling asm. I'm not sure about the performance implications, but I'm glad to be one step ahead for now. According to this issue, GCC is having trouble building FFMPEG for x86 32-bit on a 64-bit system. I would open a new PR when this is fixed.

I wonder if there's a way to achieve the same builds using cross-compilation similar to the Windows build scripts. That would make it a lot easier to compile these locally (installing QEMU and docker is fairly hefty for these simple builds). That said, it's not a high priority or blocking issue.

I find it much easier to set up Docker than to try to piece together a cross-compilation toolchain. If multiplatform images are needed, which is the case here, Docker can install the QEMU binaries by itself with a single command. I would leave it as is for now, but would like to revisit this in the future when I have more experience with cross compiling on Linux.

@kvnp kvnp changed the title Build ffmpeg for linux-arm, linux-arm64 Build ffmpeg for linux-arm, linux-arm64, linux-x86 Jul 7, 2024
Copy link
Contributor

@FreezyLemon FreezyLemon left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my review. I left some feedback, sadly the dpkg change breaks the scripts for me (I'm not on a Debian-based distro).

linux-x86 now builds after disabling asm. I'm not sure about the performance implications, ...

It's cool that you got it to work, but without someone confirming that the binaries are usable in terms of performance, I'm not entirely sure it's a great idea to include them..

I find it much easier to set up Docker than to try to piece together a cross-compilation toolchain.

FFmpeg really doesn't require much of a toolchain, basically gcc/clang plus the GNU assembler. It shouldn't be more complicated than the Windows script that already exists. To be fair, Docker is still simpler, but it's just not my preference.

Comment on lines +222 to +224
if [ "$(dpkg --print-architecture)" = "i386" ]; then
apt-get install -y nasm
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

--disable-asm on x86 Linux should mean that this is not needed

Comment on lines +9 to +20
if [ "$(dpkg --print-architecture)" = "amd64" ]; then
arch="x64"
elif [ "$(dpkg --print-architecture)" = "i386" ]; then
arch="x86"
elif [ "$(dpkg --print-architecture)" = "arm64" ]; then
arch="arm64"
elif [ "$(dpkg --print-architecture)" = "armhf" ]; then
arch="arm"
else
echo "Unsupported architecture: $(dpkg --print-architecture)"
exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use dpkg for this. uname is available almost everywhere while dpkg is Debian-specific.

Comment on lines +59 to +63
if [ "$arch" = "x86" ] && [ "$(uname -s)" = "Linux" ]; then
FFMPEG_FLAGS+=(
--disable-asm
)
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be moved to build-linux.sh (the other platforms also do arch-specific changes inside their own build scripts, see for example build-win.sh lines 23 - 38)

@sr229
Copy link
Contributor

sr229 commented Oct 29, 2024

Looks like ARM64 runners will be available in the end of the year and is available now for GitHub Enterprise Cloud/Team orgs. I suggest holding off this one until this becomes generally available.

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

Successfully merging this pull request may close these issues.

4 participants