[openarena] 01/04: Compile without Altivec for baseline PowerPC CPUs

Simon McVittie smcv at debian.org
Mon Jan 15 09:04:33 UTC 2018


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository openarena.

commit c2438063698e14dc27b453f735b2f8246ff0d592
Author: Simon McVittie <smcv at debian.org>
Date:   Thu Jan 11 08:49:03 2018 +0000

    Compile without Altivec for baseline PowerPC CPUs
    
    Closes: #701630
---
 debian/changelog                                   |   3 +
 ...-instructions-on-PowerPC-unless-requested.patch | 105 +++++++++++++++++++++
 ...NA_081_COMPATIBLE-define-for-network-comp.patch |   4 +-
 ...acro-for-the-game-code-version-so-package.patch |   7 +-
 debian/patches/series                              |   1 +
 5 files changed, 115 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 38a37e8..8ad1b1f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,9 @@
 openarena (0.8.8-21) UNRELEASED; urgency=medium
 
   * Standards-Version: 4.1.3 (no changes required)
+  * d/p/Disable-Altivec-instructions-on-PowerPC-unless-requested.patch:
+    Add patch to compile without Altivec to support baseline powerpc
+    CPUs. This should also work on powerpcspe (Closes: #701630)
 
  -- Simon McVittie <smcv at debian.org>  Fri, 08 Dec 2017 19:12:02 +0000
 
diff --git a/debian/patches/Disable-Altivec-instructions-on-PowerPC-unless-requested.patch b/debian/patches/Disable-Altivec-instructions-on-PowerPC-unless-requested.patch
new file mode 100644
index 0000000..0a7bb19
--- /dev/null
+++ b/debian/patches/Disable-Altivec-instructions-on-PowerPC-unless-requested.patch
@@ -0,0 +1,105 @@
+From: Simon McVittie <smcv at debian.org>
+Date: Wed, 4 Oct 2017 08:38:36 +0100
+Subject: Disable Altivec instructions on PowerPC unless requested
+
+Baseline PowerPC CPUs are not guaranteed to have Altivec instructions
+available, even if they are 64-bit.
+
+Unlike SSE and similar extensions on x86, there does not seem to be
+a way to enable conditional, targeted use of Altivec based on runtime
+detection (which is what ioquake3 wants to do) without also giving the
+compiler permission to use Altivec in code generation; so to not crash
+on the affected CPUs, we'll have to turn it off altogether.
+
+At one point Altivec was an important optimization, because the
+most commonly available PowerPC CPUs (in Apple G4/G5 hardware)
+had the Altivec instructions, and they were a significant benefit
+there. However, Apple haven't sold PowerPC devices for over 10 years,
+some more recently-manufactured PowerPC CPUs like the (64-bit) Freescale
+e5500 omit Altivec, and CPUs in general are a lot faster now than they
+were when the idTech3 engine was first released, hopefully making the
+optimization unnecessary.
+
+This commit uses -mno-altivec to force Altivec instructions not to be
+emitted, unless Altivec is requested via "make USE_ALTIVEC=1". The Apple
+fork of gcc doesn't document the corresponding -fno-altivec option, so
+we'll have to assume that omitting -faltivec is enough (but non-Altivec
+PowerPC Macs haven't been sold for a long time anyway).
+
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701630
+---
+ Makefile                  | 27 +++++++++++++++++++++++----
+ code/qcommon/q_platform.h |  2 +-
+ 2 files changed, 24 insertions(+), 5 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 4f9a310..569c44d 100644
+--- a/Makefile
++++ b/Makefile
+@@ -135,6 +135,10 @@ ifndef USE_LOCAL_HEADERS
+ USE_LOCAL_HEADERS=1
+ endif
+ 
++ifndef USE_ALTIVEC
++USE_ALTIVEC=0
++endif
++
+ #############################################################################
+ 
+ BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH)
+@@ -258,11 +262,19 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu")
+     HAVE_VM_COMPILED=true
+   else
+   ifeq ($(ARCH),ppc)
+-    BASE_CFLAGS += -maltivec
++    ifeq ($(USE_ALTIVEC),1)
++      BASE_CFLAGS += -maltivec -DUSE_ALTIVEC
++    else
++      BASE_CFLAGS += -mno-altivec
++    endif
+     HAVE_VM_COMPILED=true
+   endif
+   ifeq ($(ARCH),ppc64)
+-    BASE_CFLAGS += -maltivec
++    ifeq ($(USE_ALTIVEC),1)
++      BASE_CFLAGS += -maltivec -DUSE_ALTIVEC
++    else
++      BASE_CFLAGS += -mno-altivec
++    endif
+     HAVE_VM_COMPILED=true
+   endif
+   ifeq ($(ARCH),sparc)
+@@ -335,11 +347,18 @@ ifeq ($(PLATFORM),darwin)
+   BASE_CFLAGS = -Wall -Wimplicit -Wstrict-prototypes
+ 
+   ifeq ($(ARCH),ppc)
+-    BASE_CFLAGS += -faltivec
++    ifeq ($(USE_ALTIVEC),1)
++      # -fno-altivec doesn't seem to exist according to
++      # http://www.manpages.info/macosx/gcc.1.html so we'll just have to
++      # hope that the default is no Altivec
++      BASE_CFLAGS += -faltivec -DUSE_ALTIVEC
++    endif
+     OPTIMIZE += -O3
+   endif
+   ifeq ($(ARCH),ppc64)
+-    BASE_CFLAGS += -faltivec
++    ifeq ($(USE_ALTIVEC),1)
++      BASE_CFLAGS += -faltivec -DUSE_ALTIVEC
++    endif
+   endif
+   ifeq ($(ARCH),i386)
+     OPTIMIZE += -march=prescott -mfpmath=sse
+diff --git a/code/qcommon/q_platform.h b/code/qcommon/q_platform.h
+index fc8d40d..3e3f3b5 100644
+--- a/code/qcommon/q_platform.h
++++ b/code/qcommon/q_platform.h
+@@ -41,7 +41,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ #if (defined(powerc) || defined(powerpc) || defined(ppc) || \
+ 	defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)
+ #define idppc 1
+-#if defined(__VEC__)
++#if defined(__VEC__) && defined(USE_ALTIVEC)
+ #define idppc_altivec 1
+ #ifdef MACOS_X  // Apple's GCC does this differently than the FSF.
+ #define VECCONST_UINT8(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
diff --git a/debian/patches/debian/Add-OPENARENA_081_COMPATIBLE-define-for-network-comp.patch b/debian/patches/debian/Add-OPENARENA_081_COMPATIBLE-define-for-network-comp.patch
index 81f0c4f..652f1dc 100644
--- a/debian/patches/debian/Add-OPENARENA_081_COMPATIBLE-define-for-network-comp.patch
+++ b/debian/patches/debian/Add-OPENARENA_081_COMPATIBLE-define-for-network-comp.patch
@@ -27,10 +27,10 @@ Forwarded: not-needed, Debian-specific
  9 files changed, 55 insertions(+), 9 deletions(-)
 
 diff --git a/Makefile b/Makefile
-index febefca..3b21833 100644
+index c5a7ca4..84204cf 100644
 --- a/Makefile
 +++ b/Makefile
-@@ -847,6 +847,10 @@ endif
+@@ -866,6 +866,10 @@ endif
  
  BASE_CFLAGS += -DPRODUCT_VERSION=\\\"$(VERSION)\\\"
  
diff --git a/debian/patches/debian/Use-a-cpp-macro-for-the-game-code-version-so-package.patch b/debian/patches/debian/Use-a-cpp-macro-for-the-game-code-version-so-package.patch
index 82b6ac2..e511549 100644
--- a/debian/patches/debian/Use-a-cpp-macro-for-the-game-code-version-so-package.patch
+++ b/debian/patches/debian/Use-a-cpp-macro-for-the-game-code-version-so-package.patch
@@ -1,6 +1,7 @@
 From: Simon McVittie <smcv at debian.org>
 Date: Sun, 26 Feb 2012 17:38:46 +0000
-Subject: Use a cpp macro for the game-code version so packages can override it
+Subject: Use a cpp macro for the game-code version so packages can override
+ it
 
 Also draw it at a variable location, so it's right-aligned.
 
@@ -13,10 +14,10 @@ Forwarded: not-needed, Debian-specific
  3 files changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/Makefile b/Makefile
-index 4f9a310..febefca 100644
+index 569c44d..c5a7ca4 100644
 --- a/Makefile
 +++ b/Makefile
-@@ -185,7 +185,7 @@ ifeq ($(SDL_CFLAGS),)
+@@ -189,7 +189,7 @@ ifeq ($(SDL_CFLAGS),)
  endif
  
  # version info
diff --git a/debian/patches/series b/debian/patches/series
index eee0bba..24957f2 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,6 +4,7 @@ Makefile-confine-LIB-to-the-one-platform-that-needs-it-na.patch
 build-canonicalize-all-ARM-variants-to-arm-matching-q_pla.patch
 build-define-ARCH_STRING-in-Makefile-on-Linux-and-other-G.patch
 Pick-up-date-from-SOURCE_DATE_EPOCH-for-reproducible-buil.patch
+Disable-Altivec-instructions-on-PowerPC-unless-requested.patch
 debian/Use-a-cpp-macro-for-the-game-code-version-so-package.patch
 debian/Request-confirmation-if-a-user-enables-auto-download.patch
 debian/Add-OPENARENA_081_COMPATIBLE-define-for-network-comp.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openarena.git



More information about the Pkg-games-commits mailing list