Created
October 20, 2019 01:56
-
-
Save vddvss/ca9a3d38fb526768d85f3261f2839555 to your computer and use it in GitHub Desktop.
Workaround-rustc-1.37-code-generation-issue-on-ppc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 934fbe8f307027dd54d6c89e1c713cd59d02b820 Mon Sep 17 00:00:00 2001 | |
From: Colin Samples <colin.samples+git@gmail.com> | |
Date: Sat, 21 Sep 2019 14:00:21 -0400 | |
Subject: [PATCH] Workaround rustc 1.37 code generation issue on ppc | |
This patch works around an issue where rustc v1.37 emits incorrect code for | |
rsvg_internal::rect::intersect(), resulting in an incorrect x coordinate for the | |
intersection rectangle, which trips an assertion in librsvg. This issue does not | |
occur with rustc v1.36, v1.38 beta, or v1.39 nightly. | |
The patch forces a volatile access for the x coordinate when compiled for | |
ppc64le, which corrects the code generation. | |
--- | |
rsvg_internals/src/rect.rs | 15 ++++++++++++++- | |
1 file changed, 14 insertions(+), 1 deletion(-) | |
diff --git a/rsvg_internals/src/rect.rs b/rsvg_internals/src/rect.rs | |
index f1ab4ed5..2fd32f68 100644 | |
--- a/rsvg_internals/src/rect.rs | |
+++ b/rsvg_internals/src/rect.rs | |
@@ -2,6 +2,19 @@ use cairo; | |
use crate::float_eq_cairo::ApproxEqCairo; | |
+#[cfg(target_arch = "powerpc64")] | |
+use std::ptr; | |
+ | |
+#[cfg(target_arch = "powerpc64")] | |
+fn get_x1(x1: &f64) -> f64 { | |
+ unsafe { ptr::read_volatile(x1) } | |
+} | |
+ | |
+#[cfg(not(target_arch = "powerpc64"))] | |
+fn get_x1(x1: &f64) -> f64 { | |
+ *x1 | |
+} | |
+ | |
pub trait RectangleExt { | |
fn new(x: f64, y: f64, width: f64, height: f64) -> cairo::Rectangle; | |
fn is_empty(&self) -> bool; | |
@@ -35,7 +48,7 @@ impl RectangleExt for cairo::Rectangle { | |
if x2 > x1 && y2 > y1 { | |
cairo::Rectangle { | |
- x: x1, | |
+ x: get_x1(&x1), | |
y: y1, | |
width: x2 - x1, | |
height: y2 - y1, | |
-- | |
2.23.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment