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

add recipe for EGL #3192

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions M/Mesa_EGL/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg

name = "Mesa_EGL"
version = v"22.0.0"

# Collection of sources required to complete build
sources = [
GitSource("https://gitlab.freedesktop.org/mesa/mesa.git", "716fc5280adcb1912c817298353c0edc731e76a8"),
DirectorySource("./bundled"),
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/mesa/

atomic_patch -p1 ${WORKSPACE}/srcdir/patches/wl_scanner-no-native.patch
# Note: Currently unused, until `LIBPATH` becomes updated with search path of products with `dont_dlopen=true`
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/relative-dlopen.patch
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/static_assert.patch

apk add py3-mako

mkdir build
cd build

# Make a cross-file for llvm-config
echo "[binaries]" >llvm-cross.ini
echo "llvm-config = '${host_prefix}/tools/llvm-config'" >>llvm-cross.ini

meson -D egl=enabled \
-D gles1=enabled \
-D gles2=enabled \
-D opengl=true \
-D platforms=x11,wayland \
-D glx=dri \
-D c_args="-Wno-implicit-function-declaration" \
-D cpp_rtti=false \
../ \
--cross-file="${MESON_TARGET_TOOLCHAIN}" \
--cross-file=llvm-cross.ini
ninja -j${nproc}
ninja install

# taken from https://metadata.ftp-master.debian.org/changelogs//main/m/mesa/mesa_20.3.5-1_copyright
install_license ../../copyright
"""

# TODO: Hack to ensure we load the right drivers
init_block = """
ENV["LIBGL_DRIVERS_PATH"] = joinpath(artifact_dir, "lib", "dri")
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = [
Platform("x86_64", "linux"; libc="glibc", cxxstring_abi="cxx11"),
Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11"),
]

# The products that we will ensure are always built
products = Product[
LibraryProduct("libEGL", :libEGL),
LibraryProduct("libGLESv1_CM", :libGLESv1_CM),
LibraryProduct("libGLESv2", :libGLESv2),
LibraryProduct("libGL", :libGL),
LibraryProduct("libvulkan_intel", :libvulkan_intel),
LibraryProduct("libvulkan_lvp", :libvulkan_lvp),
LibraryProduct("libvulkan_radeon", :libvulkan_radeon),
LibraryProduct("libxatracker", :libxatracker),
LibraryProduct("libgbm", :libgbm),
LibraryProduct("libglapi", :libglapi),

# Drivers
LibraryProduct("crocus_dri", :crocus_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("iris_dri", :iris_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("libgallium_dri", :libgallium_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("r300_dri", :r300_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("radeonsi_dri", :radeonsi_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("virtio_gpu_dri", :virtio_gpu_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("i915_dri", :i915_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("kms_swrast_dri", :kms_swrast_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("nouveau_dri", :nouveau_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("r600_dri", :r600_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("swrast_dri", :swrast_dri, ["lib/dri"]; dont_dlopen=true),
LibraryProduct("vmwgfx_dri", :vmwgfx_dri, ["lib/dri"]; dont_dlopen=true),
]

# Dependencies that must be installed before this package can be built
dependencies = [
BuildDependency("Wayland_jll"), # FIXME: HostBuildDependency
Copy link
Member

@giordano giordano Feb 26, 2022

Choose a reason for hiding this comment

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

What does the FIXME refer to?

Dependency("libLLVM_jll"; compat="11.0.0"),
Copy link
Member

Choose a reason for hiding this comment

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

So this will work only in julia v1.6?

Copy link
Contributor

Choose a reason for hiding this comment

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

It requires LLVM >= 11 (and I tested successfully on LLVM 12). What's the compat notation for that?

Copy link
Member

Choose a reason for hiding this comment

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

@vchuravy what's the kosher way of dealing with this? Use libLLVM_jll as dependency but not specify a compat? Use libLLVM_jll as a BuildDependency (libllvm will be anyway available at runtime)? Or perhaps follow LLVMExtra now that we have that mechanism in place?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, seeing that this links directly to libLLVM-11jl.so I think the the LLVMExtra's approach is the way to go. I'm actually surprised it worked for you with other Julia versions with different LLVM 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, no, it didn't 😄 I had to switch which libLLVM I imported.

HostBuildDependency(PackageSpec(;name="LLVM_jll", version=v"11.0.1")),
Dependency("Zlib_jll"),
Dependency("libdrm_jll"; compat="2.4.110"),
Dependency("Elfutils_jll"),
Dependency("Expat_jll"; compat="2.2.10"),
Dependency("Zstd_jll"),
BuildDependency("Xorg_xorgproto_jll"),
Dependency("Xorg_libX11_jll"),
Dependency("Xorg_libXext_jll"),
Dependency("Xorg_libXfixes_jll"),
Dependency("Xorg_libxshmfence_jll"),
Dependency("Xorg_libXxf86vm_jll"),
Dependency("Xorg_xf86vidmodeproto_jll"),
giordano marked this conversation as resolved.
Show resolved Hide resolved
Dependency("Xorg_libXrandr_jll"),
Dependency("Wayland_protocols_jll"; compat="1.24"),
giordano marked this conversation as resolved.
Show resolved Hide resolved
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version=v"8", julia_compat="1.6", init_block)
Loading