Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
aports
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alpine
aports
Commits
3aa827ec
Commit
3aa827ec
authored
10 months ago
by
Celeste
Browse files
Options
Downloads
Patches
Plain Diff
community/wezterm: fix build with rust 1.78
parent
f6f3fe49
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!65453
community/wezterm: fix build with rust 1.78
Pipeline
#232276
skipped
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
community/wezterm/APKBUILD
+3
-1
3 additions, 1 deletion
community/wezterm/APKBUILD
community/wezterm/rust1.78-from_raw_parts.patch
+154
-0
154 additions, 0 deletions
community/wezterm/rust1.78-from_raw_parts.patch
with
157 additions
and
1 deletion
community/wezterm/APKBUILD
+
3
−
1
View file @
3aa827ec
...
...
@@ -3,7 +3,7 @@
pkgname
=
wezterm
pkgver
=
20240203.110809
_pkgver
=
"
${
pkgver
/./-
}
-5046fc22"
pkgrel
=
1
pkgrel
=
2
pkgdesc
=
"GPU-accelerated cross-platform terminal emulator and multiplexer written in Rust"
url
=
"https://wezfurlong.org/wezterm/"
# s390x blocked by nix crate
...
...
@@ -53,6 +53,7 @@ subpackages="
source
=
"
https://github.com/wez/wezterm/releases/download/
$_pkgver
/wezterm-
$_pkgver
-src.tar.gz
link-against-system-libs.patch
rust1.78-from_raw_parts.patch
"
builddir
=
"
$srcdir
/wezterm-
$_pkgver
"
options
=
"net"
...
...
@@ -161,4 +162,5 @@ fonts() {
sha512sums
=
"
2413e1537ed4cf699f0754d76f35cd679591e4e215e782fab61f5bd7c4615e3916398e16709445406ef241e3fb721111daed917c546abb1f5130109b40bb2774 wezterm-20240203-110809-5046fc22-src.tar.gz
d4c13f079dd0348d60eed577a0467cf4da9b202c5c959902b0626019c95d945d2a91023bc6844c19d5a3aecaa8d0de007966a6a2113549fe5328c3c8de79381f link-against-system-libs.patch
a13edbf756ef697ecc640103589d686043f4790b36ac0867a777c47cae1b6cd7482eca229d514fb6feb61e5b274c564e304eacad90001dff82e3dc01f20a3ffa rust1.78-from_raw_parts.patch
"
This diff is collapsed.
Click to expand it.
community/wezterm/rust1.78-from_raw_parts.patch
0 → 100644
+
154
−
0
View file @
3aa827ec
Patch-Source: https://github.com/wez/wezterm/commit/67d4ba9f76470a7ff1f3e7609119cdbb9d33024c
--
From 67d4ba9f76470a7ff1f3e7609119cdbb9d33024c Mon Sep 17 00:00:00 2001
From: Wez Furlong <wez@wezfurlong.org>
Date: Sat, 4 May 2024 15:53:28 -0700
Subject: [PATCH] fix when running on rust 1.78
std::slice::from_raw_parts will now panic if the ptr is null.
Resolve this by adding our own wrapper that translates that
case to an empty slice.
---
wezterm-font/src/ftwrap.rs | 60 +++++++++++--------------
wezterm-font/src/rasterizer/freetype.rs | 4 +-
2 files changed, 29 insertions(+), 35 deletions(-)
diff --git a/wezterm-font/src/ftwrap.rs b/wezterm-font/src/ftwrap.rs
index 5f06a3fb809..5c9bf128631 100644
--- a/wezterm-font/src/ftwrap.rs
+++ b/wezterm-font/src/ftwrap.rs
@@ -260,10 +260,7 @@
impl Face {
}
let bytes = unsafe {
- std::slice::from_raw_parts(
- sfnt_name.string as *const u8,
- sfnt_name.string_len as usize,
- )
+ from_raw_parts(sfnt_name.string as *const u8, sfnt_name.string_len as usize)
};
let encoding = match (sfnt_name.platform_id as u32, sfnt_name.encoding_id as u32) {
@@ -350,14 +347,12 @@
impl Face {
{
let mm = &*mm;
- let styles =
- std::slice::from_raw_parts(mm.namedstyle, mm.num_namedstyles as usize);
+ let styles = from_raw_parts(mm.namedstyle, mm.num_namedstyles as usize);
let instance = &styles[vidx];
- let axes = std::slice::from_raw_parts(mm.axis, mm.num_axis as usize);
+ let axes = from_raw_parts(mm.axis, mm.num_axis as usize);
for (i, axis) in axes.iter().enumerate() {
- let coords =
- std::slice::from_raw_parts(instance.coords, mm.num_axis as usize);
+ let coords = from_raw_parts(instance.coords, mm.num_axis as usize);
let value = coords[i].to_num::<f64>();
let default_value = axis.def.to_num::<f64>();
let scale = if default_value != 0. {
@@ -436,7 +431,7 @@
impl Face {
pub fn pixel_sizes(&self) -> Vec<u16> {
let sizes = unsafe {
let rec = &(*self.face);
- std::slice::from_raw_parts(rec.available_sizes, rec.num_fixed_sizes as usize)
+ from_raw_parts(rec.available_sizes, rec.num_fixed_sizes as usize)
};
sizes
.iter()
@@ -494,7 +489,7 @@
impl Face {
let sizes = unsafe {
let rec = &(*self.face);
- std::slice::from_raw_parts(rec.available_sizes, rec.num_fixed_sizes as usize)
+ from_raw_parts(rec.available_sizes, rec.num_fixed_sizes as usize)
};
if sizes.is_empty() {
return Err(err);
@@ -723,24 +718,12 @@
impl Face {
let data = result.assume_init();
let mut palettes = vec![];
- let name_ids = if data.palette_name_ids.is_null() {
- &[]
- } else {
- std::slice::from_raw_parts(data.palette_name_ids, data.num_palettes as usize)
- };
- let flagses = if data.palette_flags.is_null() {
- &[]
- } else {
- std::slice::from_raw_parts(data.palette_flags, data.num_palettes as usize)
- };
- let entry_name_ids = if data.palette_entry_name_ids.is_null() {
- &[]
- } else {
- std::slice::from_raw_parts(
- data.palette_entry_name_ids,
- data.num_palette_entries as usize,
- )
- };
+ let name_ids = from_raw_parts(data.palette_name_ids, data.num_palettes as usize);
+ let flagses = from_raw_parts(data.palette_flags, data.num_palettes as usize);
+ let entry_name_ids = from_raw_parts(
+ data.palette_entry_name_ids,
+ data.num_palette_entries as usize,
+ );
let entry_names: Vec<String> = entry_name_ids
.iter()
@@ -777,10 +760,8 @@
impl Face {
ft_result(FT_Get_Sfnt_Name(self.face, i, sfnt_name.as_mut_ptr()), ())
.context("FT_Get_Sfnt_Name")?;
let sfnt_name = sfnt_name.assume_init();
- let bytes = std::slice::from_raw_parts(
- sfnt_name.string as *const u8,
- sfnt_name.string_len as usize,
- );
+ let bytes =
+ from_raw_parts(sfnt_name.string as *const u8, sfnt_name.string_len as usize);
let encoding = match (sfnt_name.platform_id as u32, sfnt_name.encoding_id as u32) {
(TT_PLATFORM_MACINTOSH, TT_MAC_ID_JAPANESE)
@@ -1472,6 +1453,19 @@
impl FreeTypeStream {
}
}
+/// Wrapper around std::slice::from_raw_parts that allows for ptr to be
+/// null. In the null ptr case, an empty slice is returned.
+/// This is necessary because it is common for freetype to encode
+/// empty arrays in that way, and rust 1.78 will panic if a null
+/// ptr is passed in.
+pub(crate) unsafe fn from_raw_parts<'a, T>(ptr: *const T, size: usize) -> &'a [T] {
+ if ptr.is_null() {
+ &[]
+ } else {
+ std::slice::from_raw_parts(ptr, size)
+ }
+}
+
#[derive(Debug)]
pub struct PaletteInfo {
pub num_palettes: usize,
diff --git a/wezterm-font/src/rasterizer/freetype.rs b/wezterm-font/src/rasterizer/freetype.rs
index 9f9cf334243..2e7a366a1cb 100644
--- a/wezterm-font/src/rasterizer/freetype.rs
+++ b/wezterm-font/src/rasterizer/freetype.rs
@@ -20,8 +20,8 @@
use cairo::{Content, Context, Extend, Format, ImageSurface, Matrix, Operator, Re
use config::{DisplayPixelGeometry, FreeTypeLoadFlags, FreeTypeLoadTarget};
use std::cell::RefCell;
use std::f64::consts::PI;
+use std::mem;
use std::mem::MaybeUninit;
-use std::{mem, slice};
use wezterm_color_types::{linear_u8_to_srgb8, SrgbaPixel};
pub struct FreeTypeRasterizer {
@@ -93,7 +93,7 @@
impl FontRasterizer for FreeTypeRasterizer {
// pitch is the number of bytes per source row
let pitch = ft_glyph.bitmap.pitch.abs() as usize;
let data = unsafe {
- slice::from_raw_parts_mut(
+ crate::ftwrap::from_raw_parts(
ft_glyph.bitmap.buffer,
ft_glyph.bitmap.rows as usize * pitch,
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment