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
please remove altivec optimization for linux PPC #181
Comments
|
+set com_altivec 0 |
|
I'm pretty sure the code should have noticed the CPU doesn't support AltiVec and set that cvar to zero by default. Might actually be a bug. |
|
yes it build with altivec by default i been modify the makefile for disable the altivec optimization |
|
Okay, this is weird: We check for Altivec support at runtime in Com_Init(), which calls Com_DetectAltivec(), which calls Sys_GetProcessorFeatures()...which never ever checks for Altivec support. That is a bug too; just pushed a fix for it. So that being said, I get the impression this isn't a problem with this non-Altivec CPU running our custom Altivec code, but rather we are instructing the compiler to build a binary that uses Altivec for generic math, like the amd64 version might use SSE2 instructions instead of the FPU. So...this is still a legit bug. Is it -maltivec that's causing the problem? We should at least have a flag to avoid compiling with that flag. That flag exists because we (historically) needed it to enable the Altivec extensions for our custom code, but the compiler wouldn't otherwise generate Altivec instructions...apparently this isn't true anymore? |
|
Yes and no, pratically now there are PowerPc with altivec and PowerPc without Luigi |
|
My point was -maltivec (if that's the actual flag causing problems) use to not generate any Altivec instructions by itself, but rather allowed you to use the C intrinsic functions for altivec (vec_splat() and all the others). If it's now generating Altivec code that we can't carefully gate off behind the com_altivec cvar, we need to find a way to make this do the right thing again. |
|
Gordon , i found another issue i face it on Quad G5 and On X5000 too .. dont build exit with error because this cant be negative i switched in: and build was continue |
That's what the option is primarily documented to do, at least. From the gcc man page (my emphasis):
Could the functions that call Altivec intrinsics perhaps be moved into a separate translation unit ( In Debian we have an open bug report asking to not use Does everything (in particular the QVM bytecode interpreter) work correctly on a non-Altivec CPU in a build without |
This looks unrelated. Please open separate issues for separate compilation failures. |
|
ok smc will do it now |
|
smc , i cant test on linux ppc because on quad g5 too ioquake3 dont build because the sdl2 issue. |
That's not what it used to do, as far as I recall. Yes, unless there's a command line that only enables the Altivec C extensions, we'll need to move the Altivec-specific pieces to their own file and use -maltivec only there. That's frustrating. Maybe something like -maltivec -mabi=no-altivec works? Or -maltivec -mcpu=7400 ? Also: Is there an -faltivec option now? That's what Apple used in their GCC, and it didn't specify any codegen behaviors beyond the C extensions were available for use. Maybe mainline GCC sync'd up to that? --ryan. |
|
Tested on Osx PPC and there building and working right. |
Yes, this is a problem with the GCC that ships with Linux, which is a different fork of GCC (and specifically: has different options for Altivec support on the command line). |
|
Makefile ppc64 no altivec no 64bit os fixed |
|
Here is that change in a more useful form: diff --git a/Makefile b/Makefile
index d65d9bf..b333ace 100644
--- a/Makefile
+++ b/Makefile
@@ -340,11 +340,11 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "
gnu")
HAVE_VM_COMPILED=true
else
ifeq ($(ARCH),ppc)
- BASE_CFLAGS += -maltivec
+ BASE_CFLAGS +=
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),ppc64)
- BASE_CFLAGS += -maltivec
+ BASE_CFLAGS += -g -O2 -mcpu=e5500 -mno-altivec -mtune=e5500
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),sparc)
@@ -392,7 +392,7 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gn
u")
BASE_CFLAGS += -m32
else
ifeq ($(ARCH),ppc64)
- BASE_CFLAGS += -m64
+ BASE_CFLAGS += -m32
endif
endif
else # ifeq Linux
@@ -412,11 +412,11 @@ ifeq ($(PLATFORM),darwin)
-DMAC_OS_X_VERSION_MIN_REQUIRED=1050
ifeq ($(ARCH),ppc)
- BASE_CFLAGS += -arch ppc -faltivec
- OPTIMIZEVM += -O3
+ BASE_CFLAGS += -arch ppc
+ OPTIMIZEVM += -O3
endif
ifeq ($(ARCH),ppc64)
- BASE_CFLAGS += -arch ppc64 -faltivec
+ BASE_CFLAGS += -g -O2 -mcpu=e5500 -mno-altivec -mtune=e5500
endif
ifeq ($(ARCH),x86)
OPTIMIZEVM += -march=prescott -mfpmath=sse
@@ -724,11 +724,11 @@ ifeq ($(PLATFORM),openbsd)
HAVE_VM_COMPILED=true
else
ifeq ($(ARCH),ppc)
- BASE_CFLAGS += -maltivec
+ BASE_CFLAGS += -g -O2 -mcpu=e5500 -mno-altivec -mtune=e5500
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),ppc64)
- BASE_CFLAGS += -maltivec
+ BASE_CFLAGS += -g -O2 -mcpu=e5500 -mno-altivec -mtune=e5500
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),sparc64)I'm fairly sure that isn't the correct patch, but it's a step in the right direction. Thank you for testing this. If you go back to the original ioquake3 Makefile, and then remove all mentions of |
|
Going once... |
|
I have a G3 iBook somewhere, I'll see if I can get Linux on it. Leave this open a little longer. |
|
hi sorry for late reply. on G3 with linux you will face the same issue . the issue is use the -maltivec or -faltivec option will not fix the issue on not altivec machine |
This is not enough information to make a change, because we do not know what "fixed the makefile" means. The change that I quoted in #181 (comment) (which is what you attached in #181 (comment) converted into a form we can review) is not suitable for applying to ioquake3, because it is really several changes:
Please test the change that I asked you to test: remove all mentions of If removing all the |
Baseline PowerPC CPUs (such as those in G3 Mac systems) are not guaranteed to have Altivec instructions available. 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. Bug: ioquake#181 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701561
Baseline PowerPC CPUs are not guaranteed to have Altivec instructions available, even if they are 64-bit: the Freescale PowerPC e5500 is an example of a semi-recent 64-bit PowerPC without Altivec. Many older 32-bit PowerPCs, such as the Motorola G3, also don't have Altivec. 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. 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 Macs are a relic of the past in any case). Bug: ioquake#181 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701561
|
Please try smcv@c93cfa8c which I think might address this? (Untested, I don't have a non-Altivec PowerPC) To build a 32-bit binary on a 64-bit kernel, compile with |
Baseline PowerPC CPUs are not guaranteed to have Altivec instructions available, even if they are 64-bit: the Freescale PowerPC e5500 is an example of a semi-recent 64-bit PowerPC without Altivec. Many older 32-bit PowerPCs, such as the Motorola G3, also don't have Altivec. 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. 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 Macs are a relic of the past in any case). Bug: ioquake#181 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701561
|
The c93cfa8 commit resolves the issue - compiles and runs on my PowerPC e5500 machine (non-altivec). Many thanks. |
Baseline PowerPC CPUs are not guaranteed to have Altivec instructions available, even if they are 64-bit: the Freescale PowerPC e5500 is an example of a semi-recent 64-bit PowerPC without Altivec. Many older 32-bit PowerPCs, such as the Motorola G3, also don't have Altivec. 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 no longer sell PowerPC devices, and some more recently-manufactured PowerPC CPUs like the Freescale e5500 omit Altivec. 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 Macs are a relic of the past in any case). Bug: ioquake#181 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701561 Tested-by: casey-ac <https://github.com/casey-ac>
Baseline PowerPC CPUs are not guaranteed to have Altivec instructions available, even if they are 64-bit: the Freescale PowerPC e5500 is an example of a semi-recent 64-bit PowerPC without Altivec. Many older 32-bit PowerPCs, such as the Motorola G3, also don't have Altivec. 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 no longer sell PowerPC devices, and some more recently-manufactured PowerPC CPUs like the Freescale e5500 omit Altivec. 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 Macs are a relic of the past in any case). Bug: ioquake#181 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701561 Tested-by: casey-ac <https://github.com/casey-ac>
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 no longer sell PowerPC devices, 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 in 1999. 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 Macs are a relic of the past in any case). Bug: ioquake#181 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701561 Tested-by: casey-ac <https://github.com/casey-ac>
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 Macs haven't been sold for a long time anyway). Bug: ioquake#181 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701561 Tested-by: casey-ac <https://github.com/casey-ac>
|
@casey-ac, would you mind testing the equivalent OpenArena change for me? I see from your screenshot that you are (or were) using Ubuntu 16.04 - I can send you .dsc source packages that should compile fine on Ubuntu. Please email |
|
What's exactly wrong with altivec? I run ioquake3 (not from git) on gentoo on a ps3 sometimes and it doesn't have any issues like described here. |
It's an optional CPU extension that not all PowerPC CPUs have, similar to MMX, SSE, SSSE etc. on x86. If ioquake3 is built with Altivec instructions, it will only work on PowerPC CPUs that support Altivec. Unlike x86 extensions, Altivec isn't ubiquitous even on newer CPUs: new CPUs are still being produced that don't support it.
The PPE, the PS3's main CPU, is one of the examples of a PowerPC that does support Altivec (it's compatible with the PowerPC 970 family, aka Apple G5). Apple G3 and Freescale e5500 are examples of PowerPC CPUs that don't support Altivec. |
|
@smcv Understandable. What code is affected by the removal of AltiVec? There are ways to determine AltiVec support in Linux much like you would with |
Potentially any floating-point code emitted by the compiler. ioquake3 already conditionalizes explicit uses of vector instructions on A generic ioquake3 binary that can run on non-Altivec machines can't use I suspect there is a fairly low limit to how much restructuring the ioquake3 maintainers are going to want to do to get the benefit of Altivec (is it measurable?) on Apple machines last sold in 2007, and the minority of PS3s that are the original generation of hardware and haven't received the 2010 firmware change that prevents them from booting Linux :-) |
|
I know we're probably beating a dead horse here, but...can we move all our altivec-specific code to a file we compile with -maltivec and not use -maltivec on any other source files? That should let us keep the Altivec optimizations that we care about and select them at runtime and also make sure the same binary will run on non-Altivec hardware. I'm pretty confident that we don't need all the floating point math in the game to use the Altivec unit, since this game ran on blueberry iMacs originally. (But maybe have an option for that, instead of the other way around.) |
I think that can work. If you think that's worth the effort, and there's going to be someone available to test it on non-Altivec-capable hardware, I can prepare a patch that does that. @casey-ac tested #337, perhaps they could test a new patch? I'd want to be sure that it had a decent chance of getting merged before doing that, though.
Sorry, I'm not sure I parsed what you want correctly. There are three reasonable things to do on PowerPC:
Which one do you want to be the default and which others do you want to have available? For Debian The patch I proposed in #337 results in the first of those options by default, or the third if you ask for it. |
|
I moved all the Altivec code to its own source files over here: #367 But I don't personally want to bother with the Makefile, if someone else wants to handle that.
(Apply my patch, then) use It's safe to comple snd_altivec.c and tr_altivec.c everywhere, they'll just #ifdef down to nothing. The macOS pieces of the Makefile can just use Does that sound okay? |
|
Can ioquake3 run on ppc without changes right now? Since it now depends on SDL 205 or greater without flipping the error in main. |
On Linux, with Altivec-capable CPUs (because of this issue) and a system copy of SDL2, I don't see why not. On macOS with the bundled copy of SDL2, perhaps not, but there is no vendor-supported macOS version that still works on PPC anyway... |
|
But I just think it would be weird to put in a hack to disable that version check just for that. No chance of newer sdl2 for ppcmac at least? |
|
Last we checked (not recently), SDL2 could be built for PowerPC Mac OS X with a few minor patches; so leaving it in the Makefile for ioquake3 doesn't hurt anything if someone gets bold enough to try it. (The general problem SDL runs into there isn't CPU compatibility, but OS and compiler version; we're starting to use APIs that don't exist in OS X 10.5, and syntactic sugar that doesn't exist in their PowerPC tools.) PowerPC Linux (and OpenBSD, embedded things, etc) are more reasonable targets at this point, as far as ioquake3 is concerned, and the altivec changes we're discussing here will be of good use to them. |
|
Regarding Ensiform's comments; The ioq3 universal app bundle built from git master still works on macOS 10.5 PowerPC using SDL 2.0.1 included in the ioq3 repo. The PowerPC build is also run by macOS 10.5 x86 and x86_64 due to SDL 2.0.5 dropping support for macOS 10.5. (The minimum macOS version by arch is listed in the app bundle Info.Plist.) ioq3 only requires SDL 2.0.5 at run-time if compiled against 2.0.5 or newer. This allows macOS 10.5 PowerPC and old GNU/Linux distros (such as Ubuntu Trusty on Travis-CI) to still be able to compile and run ioq3. |
|
I believe that the merge of #368 resolves this issue. Let me know if this is still giving you problems on various PowerPC setups and we can reevaluate, though! |

please remove altivec optimization in makefile linux ppc because on powerpc cpu without altivec it made crashing with coredump after building.
Tested on P5020 freescale 2ghz
The text was updated successfully, but these errors were encountered: