Skip to content

Commit

Permalink
Merge pull request #412 from jellyfin/win64-clang
Browse files Browse the repository at this point in the history
ci: Add Windows Clang builder
  • Loading branch information
gnattu authored Jul 16, 2024
2 parents 9553f9b + 0b41bc9 commit 27d2232
Show file tree
Hide file tree
Showing 107 changed files with 5,890 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* text eol=lf
*.pnm -diff -text
tests/ref/fate/sub-scc eol=crlf
126 changes: 126 additions & 0 deletions .github/workflows/_meta_win_clang_portable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
on:
workflow_call:
inputs:
release:
required: false
default: false
type: boolean
secrets:
deploy-host:
required: false
deploy-user:
required: false
deploy-key:
required: false

jobs:
build:
name: 'Build Portable FFmpeg'
runs-on: windows-latest
strategy:
fail-fast: true
matrix:
os:
- name: CLANG64
arch: win64
defaults:
run:
shell: msys2 {0}
steps:
- uses: msys2/setup-msys2@v2
with:
update: true
msystem: CLANG64
install: >-
git
curl
wget
zip
mingw-w64-clang-x86_64-toolchain
quilt
diffstat
mingw-w64-clang-x86_64-nasm
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Prepare prefix dir
run: |
mkdir /clang64/ffbuild
- name: Build Portable
run: ./msys2/build.sh

- name: Upload Artifacts
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
name: win-clang-${{ matrix.os.arch }}-portable
path: ./msys2/artifacts

publish:
name: Publish Portable Release
if: ${{ inputs.release }}
runs-on: ubuntu-latest
needs:
- build
strategy:
fail-fast: true
matrix:
arch: [win64]

steps:
- name: Set Versions
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: set_version
with:
script: |
const tag = context.ref.substring(10)
const no_v = tag.replace('v', '')
const dash_index = no_v.lastIndexOf('-')
const major_index = no_v.indexOf('.')
const no_dash = (dash_index > -1) ? no_v.substring(0, dash_index) : no_v
const major = (major_index > -1) ? no_v.substring(0, major_index) : no_v
core.setOutput('tag', tag)
core.setOutput('no-v', no_v)
core.setOutput('no-dash', no_dash)
core.setOutput('major', major)
- name: Download Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: win-clang-${{ matrix.arch }}-portable
path: artifact

- name: Upload GH Release Assets
uses: shogo82148/actions-upload-release-asset@8f032eff0255912cc9c8455797fd6d72f25c7ab7 # v1.7.5
with:
upload_url: ${{ github.event.release.upload_url }}
overwrite: true
asset_path: |
./artifact/**/*.zip
- name: Upload release archive to repo.jellyfin.org
uses: appleboy/scp-action@917f8b81dfc1ccd331fef9e2d61bdc6c8be94634 # v0.1.7
with:
host: ${{ secrets.deploy-host }}
username: ${{ secrets.deploy-user }}
key: ${{ secrets.deploy-key }}
source: artifact/*
strip_components: 1
target: /srv/incoming/ffmpeg/${{ steps.set_version.outputs.no-v }}/windows/${{ matrix.arch }}

- name: Move incoming release into repository
uses: appleboy/ssh-action@029f5b4aeeeb58fdfe1410a5d17f967dacf36262 # v1.0.3
with:
host: ${{ secrets.deploy-host }}
username: ${{ secrets.deploy-user }}
key: ${{ secrets.deploy-key }}
envs: JELLYFIN_VERSION
script_stop: true
script: |
# Create the target folder and move arch directory into it
sudo mkdir -p /srv/repository/main/ffmpeg/windows/${{ steps.set_version.outputs.major }}.x/${{ steps.set_version.outputs.no-v }}/${{ matrix.arch }}
sudo mv -t /srv/repository/main/ffmpeg/windows/${{ steps.set_version.outputs.major }}.x/${{ steps.set_version.outputs.no-v }}/${{ matrix.arch }}/ /srv/incoming/ffmpeg/${{ steps.set_version.outputs.no-v }}/windows/${{ matrix.arch }}/*
sudo chown -R root:root /srv/repository/main/ffmpeg/windows/${{ steps.set_version.outputs.major }}.x/${{ steps.set_version.outputs.no-v }}
# Update symlink for latest-X.x
sudo rm -f /srv/repository/main/ffmpeg/windows/latest-${{ steps.set_version.outputs.major }}.x || true
sudo ln -s /srv/repository/main/ffmpeg/windows/${{ steps.set_version.outputs.major }}.x/${{ steps.set_version.outputs.no-v }} /srv/repository/main/ffmpeg/windows/latest-${{ steps.set_version.outputs.major }}.x || true
5 changes: 5 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ jobs:
architectures: '["win64"]'
release: false

build_portable_windows_clang:
uses: ./.github/workflows/_meta_win_clang_portable.yaml
with:
release: false

build_portable_linux:
uses: ./.github/workflows/_meta_portable.yaml
with:
Expand Down
41 changes: 29 additions & 12 deletions debian/patches/0035-enable-gcc-vectorization-and-lto-auto.patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
Index: jellyfin-ffmpeg/configure
Index: FFmpeg/configure
===================================================================
--- jellyfin-ffmpeg.orig/configure
+++ jellyfin-ffmpeg/configure
@@ -7196,6 +7196,8 @@ if enabled lto; then
--- FFmpeg.orig/configure
+++ FFmpeg/configure
@@ -7195,8 +7195,23 @@ check_optflags -fno-signed-zeros

if enabled lto; then
test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
check_cflags -flto
check_ldflags -flto $cpuflags
+ check_cflags -flto=auto
+ check_ldflags -flto=auto $cpuflags
- check_cflags -flto
- check_ldflags -flto $cpuflags
+ if test "$cc_type" = "clang"; then
+ check_cflags -flto=thin
+ check_ldflags -flto=thin $cpuflags
+ # Clang's LTO fails on Windows, when there are references outside
+ # of inline assembly to nonlocal labels defined within inline assembly,
+ # see https://github.com/llvm/llvm-project/issues/76046.
+ case $target_os in
+ mingw*|win*)
+ disable inline_asm_nonlocal_labels
+ ;;
+ esac
+ else
+ check_cflags -flto
+ check_ldflags -flto $cpuflags
+ check_cflags -flto=auto
+ check_ldflags -flto=auto $cpuflags
+ fi
disable inline_asm_direct_symbol_refs
fi

@@ -7234,7 +7236,9 @@ if enabled icc; then
@@ -7235,7 +7250,9 @@ if enabled icc; then
disable aligned_stack
fi
elif enabled gcc; then
Expand All @@ -22,10 +39,10 @@ Index: jellyfin-ffmpeg/configure
check_cflags -Werror=format-security
check_cflags -Werror=implicit-function-declaration
check_cflags -Werror=missing-prototypes
Index: jellyfin-ffmpeg/libavcodec/x86/cabac.h
Index: FFmpeg/libavcodec/x86/cabac.h
===================================================================
--- jellyfin-ffmpeg.orig/libavcodec/x86/cabac.h
+++ jellyfin-ffmpeg/libavcodec/x86/cabac.h
--- FFmpeg.orig/libavcodec/x86/cabac.h
+++ FFmpeg/libavcodec/x86/cabac.h
@@ -183,6 +183,9 @@ av_noinline
#else
av_always_inline
Expand Down
83 changes: 83 additions & 0 deletions msys2/PKGBUILD/10-mingw-w64-brotli/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Maintainer: J. Peter Mugaas <[email protected]>

_realname=brotli
pkgbase=mingw-w64-jellyfin-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-jellyfin-${_realname}")
pkgver=1.1.0
pkgrel=1
pkgdesc="Brotli compression library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://github.com/google/brotli'
msys2_references=(
"pypi: brotli"
"cpe: cpe:/a:google:brotli"
)
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-python-setuptools"
"${MINGW_PACKAGE_PREFIX}-python-build"
"${MINGW_PACKAGE_PREFIX}-python-installer"
"${MINGW_PACKAGE_PREFIX}-python-wheel"
)
license=('spdx:MIT')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/google/brotli/archive/v${pkgver}.tar.gz")
sha256sums=('e720a6ca29428b803f4ad165371771f5398faba397edf6778837a18599ea13ff')

prepare() {
cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
cd "${srcdir}/${_realname}-${pkgver}"

${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation

declare -a extra_config
if check_option "debug" "n"; then
extra_config+=("-DCMAKE_BUILD_TYPE=Release")
else
extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
fi

mkdir -p "${srcdir}/build-${MSYSTEM}-static" && cd "${srcdir}/build-${MSYSTEM}-static"

MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
${MINGW_PREFIX}/bin/cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX}/ffbuild/ \
"${extra_config[@]}" \
-DBUILD_SHARED_LIBS=OFF \
-DENABLE_STATIC=ON \
-DBUILD_STATIC_LIBS=ON \
../${_realname}-${pkgver}

${MINGW_PREFIX}/bin/cmake --build .
}

check() {
:
}

package_brotli() {
cd "${srcdir}"/build-${MSYSTEM}-static
DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --install .

install -D -m644 "${srcdir}"/brotli-${pkgver}/LICENSE "${pkgdir}${MINGW_PREFIX}/ffbuild/share/licenses/${_realname}/LICENSE"

# Let ffmpeg also statically link to brotlicommon
sed -s "s|-lbrotlidec|-lbrotlidec\ -lbrotlicommon|g" -i "${pkgdir}"${MINGW_PREFIX}/ffbuild/lib/pkgconfig/libbrotlidec.pc
sed -s "s|-lbrotlidec|-lbrotlidec\ -lbrotlicommon|g" -i "${pkgdir}"${MINGW_PREFIX}/ffbuild/lib/pkgconfig/libbrotlienc.pc
}

# template start; name=mingw-w64-splitpkg-wrappers; version=1.0;
# vim: set ft=bash :

# generate wrappers
for _name in "${pkgname[@]}"; do
_short="package_${_name#${MINGW_PACKAGE_PREFIX}-jellyfin-}"
_func="$(declare -f "${_short}")"
eval "${_func/#${_short}/package_${_name}}"
done
# template end;
70 changes: 70 additions & 0 deletions msys2/PKGBUILD/10-mingw-w64-bzip2/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Maintainer: Alexey Pavlov <[email protected]>
# Contributor: Renato Silva <[email protected]>

_realname=bzip2
pkgbase=mingw-w64-jellyfin-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-jellyfin-${_realname}"
pkgver=1.0.8
pkgrel=3
pkgdesc="A high-quality data compression program (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://sourceware.org/bzip2/"
msys2_references=(
"cpe: cpe:/a:bzip:bzip2"
)
license=("custom")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
options=('strip' 'staticlibs')
source=("https://mirrors.kernel.org/sourceware/bzip2/bzip2-${pkgver}.tar.gz"
"bzip2-cygming-1.0.6.src.all.patch"
"bzip2-buildsystem.all.patch"
"bzip2-1.0.6-progress.all.patch")
sha256sums=('ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269'
'7e67f77172b19f3e6c1f0875b1d3e9cb79211f8e1c752794ef9afd3704f928cf'
'e519a50a4adaf05b18650d3e9d644badc66e80ca86063681ffe9a2c2226319d0'
'f93e6b50082a8e880ee8436c7ec6a65a8f01e9282436af77f95bb259b1c7f7f7')

export FF_MINGW_PREFIX="${MINGW_PREFIX}/ffbuild"

prepare() {
cd "${srcdir}/${_realname}-${pkgver}"
# remove files that are created by patches.
rm -rf README.CYGMING | true
rm -rf aclocal.m4 | true
rm -rf configure.ac | true
rm -rf libbz2.def.in | true
rm -rf bzip2.pc.in | true
rm -rf Makefile.in | true

patch -p1 -i "$srcdir/"bzip2-cygming-1.0.6.src.all.patch
patch -p1 -i "$srcdir/"bzip2-buildsystem.all.patch
patch -p1 -i "$srcdir/"bzip2-1.0.6-progress.all.patch

autoreconf -fi
}

build() {
mkdir -p "${srcdir}/build-${CARCH}"
cd "${srcdir}/build-${CARCH}"
../${_realname}-${pkgver}/configure \
--prefix=${FF_MINGW_PREFIX} \
--build=${MINGW_CHOST} \
--host=${MINGW_CHOST} \
--target=${MINGW_CHOST} \
--disable-shared

make all-libs
}

check() {
:
}

package() {
cd "${srcdir}/build-${CARCH}"
make DESTDIR="${pkgdir}" install
# rm "${pkgdir}${MINGW_PREFIX}/bin/bz"{diff,grep,more}
install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${FF_MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
Loading

0 comments on commit 27d2232

Please sign in to comment.