me

/

vinix-ports Public
382 commits 0 issues 0 pull requests 1 contributor Discussions Projects Snippets LOC history Platform CI

Share one Mesa compilation across runtime and SDK packages

diviocity committed 5 days ago · 5b4bdb770ebc50bfd5efad2e6c813c463c5628c4 View patch
Unverified signature 4 files changed +273 -0
mesa-glx-legacy/PKGBUILD.vile new file +37 -0

@@ -0,0 +1,37 @@

1+defpkgbuild(mesa-glx-legacy,

2+ #:pkgname, "mesa-glx-legacy",

3+ #:pkgver, "24.0.9",

4+ #:pkgrel, 1,

5+ #:pkgdesc, "Mesa GLX and indirect DRI renderer for Xorg and Xvfb",

6+ #:arch, [#:x86-64, #:aarch64],

7+ #:url, "https://www.mesa3d.org/",

8+ #:license, "MIT AND SGI-B-2.0 AND BSD-3-Clause",

9+ #:depends, ["llvm17-libs", "musl", "gcc-libs", "libdrm", "libelf", "libx11", "libxcb", "libxext", "libxfixes", "libxshmfence", "libxxf86vm", "expat", "zlib", "zstd"],

10+ #:makedepends, ["llvm17-dev", "linux-headers", "wayland", "wayland-protocols", "xorgproto", "libxrandr"],

11+ #:source, ["https://archive.mesa3d.org/mesa-24.0.9.tar.xz",

12+ "https://raw.githubusercontent.com/alpinelinux/aports/49045b8723e3c2e02f24b11e468631103ef2661b/main/mesa/enable-mali-t600.patch",

13+ "https://raw.githubusercontent.com/alpinelinux/aports/49045b8723e3c2e02f24b11e468631103ef2661b/main/mesa/no-unlink-megadrivers.patch",

14+ "https://raw.githubusercontent.com/alpinelinux/aports/49045b8723e3c2e02f24b11e468631103ef2661b/main/mesa/musl-stacksize.patch"],

15+ #:sha256sums, ["51aa686ca4060e38711a9e8f60c8f1efaa516baf411946ed7f2c265cd582ca4c",

16+ "4cc636d1080f4ce8413145f53a68f90481d2defacbf87c9253a8231c0cec21ba",

17+ "2eac5a17bda598d13d570592c1fb2b5b80eb2e1cd6f01ef04f1a6d7ac9457f0b",

18+ "47fc425a8000c47460f8521389c766a6d181865237dfa60dd4480ccf0a309f21"],

19+ #:prepare, fn() {

20+ for-each(fn(file) {

21+ run("patch", "--batch", "-d", "mesa-24.0.9", "-p1", "-i", string-append("../", file))

22+ }, list("enable-mali-t600.patch", "no-unlink-megadrivers.patch", "musl-stacksize.patch"))

23+ },

24+ #:build, fn() {

25+ run("vinix-mesa", "legacy", "mesa-24.0.9", "build")

26+ run("vinix-ninja", "build", "all")

27+ },

28+ #:check, fn() {

29+ for-each(fn(file) { run("readelf", "-d", string-append("build/", file)) },

30+ list("src/glx/libGL.so", "src/gallium/targets/dri/libgallium_dri.so"))

31+ },

32+ #:package, fn() {

33+ stage := string-append(srcdir(), "/mesa-install")

34+ run("meson", "install", "--no-rebuild", "-C", "build", "--destdir", stage)

35+ run("vinix-mesa", "package", "legacy", stage, pkgdir())

36+ run("install", "-Dm644", "mesa-24.0.9/docs/license.rst", string-append(pkgdir(), "/usr/share/licenses/mesa-glx-legacy/license.rst"))

37+ })

mesa/PKGBUILD.vile new file +48 -0

@@ -0,0 +1,48 @@

1+defpkgbuild(mesa,

2+ #:pkgname, ["mesa", "mesa-gallium-sdk"],

3+ #:pkgver, "24.2.8",

4+ #:pkgrel, 1,

5+ #:pkgdesc, "Mesa EGL, GLES, GBM and Gallium for the Vinix desktop",

6+ #:arch, [#:x86-64, #:aarch64],

7+ #:url, "https://www.mesa3d.org/",

8+ #:license, "MIT AND SGI-B-2.0 AND BSD-3-Clause",

9+ #:depends, ["mesa-platform-headers", "mesa-glx-legacy", "llvm19-libs", "musl", "gcc-libs", "libdrm", "libelf", "libx11", "libxcb", "libxshmfence", "wayland", "expat", "zlib", "zstd"],

10+ #:makedepends, ["llvm19-dev", "linux-headers", "wayland-protocols", "xorgproto", "libxext", "libxfixes", "libxrandr", "libxxf86vm"],

11+ #:source, ["https://archive.mesa3d.org/mesa-24.2.8.tar.xz",

12+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/mesa/29401.patch",

13+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/mesa/23630.patch",

14+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/mesa/riscv64-tls.patch"],

15+ #:sha256sums, ["999d0a854f43864fc098266aaf25600ce7961318a1e2e358bff94a7f53580e30",

16+ "2975b35c7cc0c66074bc38b906863c9b5da90718b2c7764f78b6486466f15061",

17+ "9f29a0cebfebdc8f9aab2452b86b289f863d128f67e197fcb5ad5a886c74dfc1",

18+ "57cb89d086c4c3c0e4fbac3f84ab7409ac13df2a7c540f677d87c1ee8676076f"],

19+ #:prepare, fn() {

20+ for-each(fn(file) {

21+ run("patch", "--batch", "-d", "mesa-24.2.8", "-p1", "-i", string-append("../", file))

22+ }, list("29401.patch", "23630.patch", "riscv64-tls.patch"))

23+ },

24+ #:build, fn() {

25+ run("vinix-mesa", "current", "mesa-24.2.8", "build")

26+ run("vinix-ninja", "build", "all")

27+ },

28+ #:check, fn() {

29+ for-each(fn(file) { run("readelf", "-d", string-append("build/", file)) },

30+ list("src/egl/libEGL.so", "src/gbm/libgbm.so", "src/gallium/targets/dri/libgallium-24.2.8.so",

31+ "src/gallium/targets/osmesa/libOSMesa.so", "src/gallium/targets/xa/libxatracker.so"))

32+ },

33+ #:package, fn() {

34+ stage := string-append(srcdir(), "/mesa-install")

35+ staged := string-append(srcdir(), "/mesa-install-complete")

36+ if not(file-exists?(staged)) {

37+ run("meson", "install", "--no-rebuild", "-C", "build", "--destdir", stage)

38+ run("touch", staged)

39+ }

40+ name := get-environment-variable("VPAC_PKGNAME")

41+ profile := if string=?("mesa-gallium-sdk", name) { "sdk" } else { "current" }

42+ run("vinix-mesa", "package", profile, stage, pkgdir())

43+ if string=?("mesa", name) {

44+ ; The release includes this header while omitting the off-screen renderer DSO.

45+ run("install", "-Dm644", "mesa-24.2.8/include/GL/osmesa.h", string-append(pkgdir(), "/usr/include/GL/osmesa.h"))

46+ }

47+ run("install", "-Dm644", "mesa-24.2.8/docs/license.rst", string-append(pkgdir(), "/usr/share/licenses/", name, "/license.rst"))

48+ })

tests/x11/README.md +2 -0

@@ -44,3 +44,5 @@ On AArch64, libelf 0.191-2 built from elfutils and installed with its signed lib

4444The cold AArch64 LLVM build SDK installed eight signed packages, including GCC's shared runtime, libffi, libxml2, XZ, zlib and Zstd. The worker counted 1,413 owned files and links and 21 target ELFs. The host tools verified CMake 3.28.3 from the pinned Ubuntu archive and the matching 17.0.6 and 19.1.4 TableGen programs in the private build environment. The SDK and host-tool receipts are under `xorg/llvm/arm-runtime-sdk-01` and `xorg/llvm/arm-host-tools-01`, manifest SHA-256 `85a0d963c61842d6696c92bd488f3a7b52f5b8441f172a4ff0ced50ca27a32e9` and `f8d1d5aaafbde5b748e8fa7c9888dbe9761ead42001b89d477120b24ecbbe283`.

4545

4646Keep the completed LLVM runtime build tree until its development archive is packaged. Install the signed runtime in the development SDK and set `VINIX_LLVM_BUILD` to the runtime's CMake build directory inside the same worker environment. The recipe compares the built shared object to the installed runtime and asks Ninja for the headers and `llvm-config` using the existing objects. With the variable unset, the source recipe builds those targets independently. Both recipe fixtures reused a configured tree, packaged headers and a versioned `llvm-config`, and rejected a different runtime file. See `xorg/llvm/reuse-dev-fixture-02`, receipt SHA-256 `8123239e3d4ac7ed770df0f1be8d03bf9e214029e22596438a5b3f105033e9b6`. The release builds and LLVM guest checks are separate gates.

47+

48+The Mesa 24.2.8 recipe compiles Gallium once and uses one Meson installation to produce `mesa` and `mesa-gallium-sdk`. EGL, GLES and GBM stay in the runtime archive. The SDK archive carries OSMesa and XA for builds that request them. Both architecture plans resolve the split outputs to the same recipe, and the install fixture confirmed that the two outputs own disjoint paths. See `foundation/release-split-plan-01`, receipt SHA-256 `124659b0ae78559071f072e3845c4c5903da1b2f9a0b523931e422b21ac3b585`. The real Mesa binaries still need the LLVM dependencies and their guest graphics checks.

tools/vinix-mesa.v new file +186 -0

@@ -0,0 +1,186 @@

1+// Configure the two Mesa releases with separate driver search paths.

2+module main

3+

4+import os

5+

6+fn config_tool(root string, major string, arch string) ![]string {

7+ prefix := os.join_path(root, 'usr/lib/llvm' + major)

8+ binary := os.join_path(prefix, 'bin/llvm-config')

9+ mut commands := [][]string{}

10+ if os.uname().machine == arch {

11+ commands << [binary]

12+ }

13+ // QEMU starts the requested target executable with its installed loader.

14+ // llvm-config derives include/lib paths from its own executable name.

15+ commands << ['qemu-' + arch, '-L', root, '-E',

16+ 'LD_LIBRARY_PATH=' + root + '/usr/lib:' + root + '/lib', binary]

17+ for args in commands {

18+ mut probe := args.clone()

19+ probe << '--prefix'

20+ result := os.exec(probe)

21+ if result.exit_code == 0 && os.real_path(result.output.trim_space()) == os.real_path(prefix) {

22+ return args

23+ }

24+ }

25+ return error('could not run ${binary} with its installed prefix ${prefix}')

26+}

27+

28+fn machine_string(value string) string {

29+ return "'" + value.replace('\\', '\\\\').replace("'", "\\'") + "'"

30+}

31+

32+fn configure(profile string, source string, build string) ! {

33+ if profile !in ['current', 'legacy'] {

34+ return error('use current (24.2.8) or legacy (24.0.9)')

35+ }

36+ legacy := profile == 'legacy'

37+ root := os.getenv('VPAC_MAKEPKG_ROOT')

38+ arch := os.getenv_opt('VPAC_TARGET_ARCH') or { os.uname().machine }

39+ if !os.is_abs_path(root) || arch !in ['x86_64', 'aarch64'] {

40+ return error('set VPAC_MAKEPKG_ROOT to the installed x86_64 or aarch64 SDK')

41+ }

42+ config := config_tool(root, if legacy { '17' } else { '19' }, arch)!

43+ cross := os.abs_path(build) + '.mesa.ini'

44+ os.write_file(cross, '[binaries]\nllvm-config = [' +

45+ config.map(machine_string(it)).join(', ') + ']\n')!

46+ mut drivers := if legacy { ['swrast'] } else { ['llvmpipe', 'softpipe'] }

47+ drivers << ['r600', 'radeonsi', 'nouveau', 'virgl', 'zink']

48+ if arch == 'x86_64' {

49+ drivers << ['r300', 'svga', 'i915', 'iris', 'crocus']

50+ } else {

51+ drivers << ['vc4', 'v3d', 'freedreno', 'lima', 'panfrost', 'etnaviv', 'tegra']

52+ if legacy {

53+ drivers << ['r300', 'kmsro']

54+ }

55+ }

56+ mut args := [source, build, '--cross-file', cross, '--wrap-mode=nofallback', '-Db_ndebug=true',

57+ '-Db_lto=false', '-Doptimization=1', '-Dbackend_max_links=1', '-Dbuild-tests=false',

58+ '-Dgallium-drivers=' + drivers.join(','), '-Dvulkan-drivers=', '-Dvulkan-layers=',

59+ '-Dgallium-rusticl=false', '-Dgallium-va=disabled', '-Dgallium-vdpau=disabled',

60+ '-Dgallium-nine=false', '-Dllvm=enabled', '-Dshared-llvm=enabled', '-Dshared-glapi=enabled',

61+ '-Dopengl=true']

62+ path := if legacy { '/usr/lib/xorg/modules/dri' } else { '/usr/lib/mesa24/dri' }

63+ args << ['-Dplatforms=x11,wayland', '-Dglx=dri', '-Dgbm=enabled', '-Degl=enabled', '-Dgles1=enabled',

64+ '-Dgles2=enabled', '-Ddri-drivers-path=' + path, '-Ddri3=enabled']

65+ // The current build emits both the runtime and the optional SDK package.

66+ if legacy {

67+ args << ['-Dgallium-xa=disabled', '-Dosmesa=false']

68+ } else {

69+ args << ['-Dgallium-xa=enabled', '-Dosmesa=true']

70+ if arch == 'x86_64' {

71+ args << '-Dintel-clc=system'

72+ }

73+ }

74+ os.execvp('vinix-meson', args)!

75+}

76+

77+fn legacy_file(path string) bool {

78+ return path.starts_with('usr/lib/xorg/modules/dri/') || path.starts_with('usr/lib/libGL.so')

79+ || path.starts_with('usr/lib/libglapi.so') || path == 'usr/lib/pkgconfig/gl.pc'

80+}

81+

82+fn sdk_file(path string) bool {

83+ return path.starts_with('usr/lib/libOSMesa.so') || path.starts_with('usr/lib/libxatracker.so')

84+ || path in ['usr/lib/pkgconfig/osmesa.pc', 'usr/lib/pkgconfig/xatracker.pc'] || path.starts_with('usr/include/xa_')

85+}

86+

87+fn arm_alias(profile string, path string) string {

88+ name := os.file_name(path)

89+ return match path {

90+ 'usr/lib/libGL.so.1', 'usr/lib/libglapi.so.0' {

91+ if profile == 'legacy' { 'usr/lib/vinix-x11-software/' + name } else { '' }

92+ }

93+ 'usr/lib/libEGL.so.1', 'usr/lib/libgbm.so.1' {

94+ if profile == 'current' { 'usr/lib/vinix-x11-software/egl/' + name } else { '' }

95+ }

96+ 'usr/lib/xorg/modules/dri/libgallium_dri.so', 'usr/lib/xorg/modules/dri/swrast_dri.so',

97+ 'usr/lib/xorg/modules/dri/kms_swrast_dri.so' {

98+ if profile == 'legacy' { 'usr/lib/dri/' + name } else { '' }

99+ }

100+ else { '' }

101+ }

102+}

103+

104+fn package_files(profile string, stage string, output string) ! {

105+ if profile !in ['current', 'legacy', 'sdk'] || !os.is_dir(os.join_path(stage, 'usr')) {

106+ return error('expected Mesa profile and a populated Meson installation')

107+ }

108+ arch := os.getenv_opt('VPAC_TARGET_ARCH') or { os.uname().machine }

109+ root := os.real_path(stage)

110+ mut copies := map[string]string{}

111+ mut files := os.walk_ext(os.join_path(root, 'usr'), '')

112+ files.sort()

113+ for file in files {

114+ path := file[root.len + 1..]

115+ wanted := match profile {

116+ 'legacy' { legacy_file(path) }

117+ 'sdk' { sdk_file(path) }

118+ else {

119+ !legacy_file(path) && !sdk_file(path) && path !in [

120+ 'usr/include/EGL/eglplatform.h',

121+ 'usr/include/KHR/khrplatform.h',

122+ ]

123+ }

124+ }

125+ if !wanted {

126+ continue

127+ }

128+ // The Vinix loader opens driver paths with O_NOFOLLOW. Preserve one

129+ // copy of each Mesa DSO while making all its aliases regular files.

130+ source := os.real_path(file)

131+ if !source.starts_with(root + '/') || !os.is_file(source) {

132+ return error('unresolved or external Mesa install path: ${path}')

133+ }

134+ dst := os.join_path(output, path)

135+ os.mkdir_all(os.dir(dst))!

136+ st := os.stat(source)!

137+ identity := '${st.dev}:${st.inode}'

138+ if previous := copies[identity] {

139+ os.link(previous, dst)!

140+ } else {

141+ os.cp(source, dst)!

142+ copies[identity] = dst

143+ }

144+ if arch == 'aarch64' {

145+ alias := arm_alias(profile, path)

146+ if alias != '' {

147+ dest := os.join_path(output, alias)

148+ os.mkdir_all(os.dir(dest))!

149+ os.link(dst, dest)!

150+ }

151+ }

152+ }

153+ required := match profile {

154+ 'legacy' { ['libGL.so.1', 'libglapi.so.0', 'xorg/modules/dri/swrast_dri.so'] }

155+ 'sdk' {

156+ ['libOSMesa.so', 'libxatracker.so', 'pkgconfig/osmesa.pc', 'pkgconfig/xatracker.pc']

157+ }

158+ else {

159+ ['libEGL.so.1', 'libgbm.so.1', 'libGLESv2.so.2', 'libgallium-24.2.8.so',

160+ 'mesa24/dri/swrast_dri.so']

161+ }

162+ }

163+ for name in required {

164+ if !os.is_file(os.join_path(output, 'usr/lib', name)) {

165+ return error('missing required ${profile} Mesa output: ${name}')

166+ }

167+ }

168+}

169+

170+fn main() {

171+ if os.args.len == 5 && os.args[1] == 'package' {

172+ package_files(os.args[2], os.args[3], os.args[4]) or {

173+ eprintln(err)

174+ exit(1)

175+ }

176+ return

177+ }

178+ if os.args.len != 4 {

179+ eprintln('usage: vinix-mesa PROFILE MESA_SOURCE_DIR BUILD_DIR')

180+ exit(2)

181+ }

182+ configure(os.args[1], os.args[2], os.args[3]) or {

183+ eprintln(err)

184+ exit(1)

185+ }

186+}