We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 148

Summary: Altivec configure test doesn't work as intended on G3 with Tiger
Product: SDL Reporter: Emil Styrke <emil>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: emil
Version: 1.2.9   
Hardware: PowerPC   
OS: Mac OS X 10.4 (PPC)   

Description Emil Styrke 2006-02-22 08:17:24 UTC
I'm trying to compile SDL on an iBook G3, i.e. without altivec support. Nevertheless it's possible to compile programs that uses altivec instructions - but they crash with "invalid cpu-subtype" when run. The fix is simple, just apply the following to configure.in (I haven't verified that it works on a system with altivec, since I don't own one):

--- configure.in~       2005-08-28 08:31:18.000000000 +0200
+++ configure.in        2006-02-22 13:58:25.000000000 +0100
@@ -1841,11 +1841,11 @@
     have_gcc_altivec=no
     save_CFLAGS="${CFLAGS}"
     CFLAGS="${CFLAGS} -DGCC_ALTIVEC -DUSE_ALTIVEC_BLITTERS -faltivec"
-    AC_TRY_COMPILE([
+    AC_TRY_RUN([
     vector unsigned int vzero() {
         return vec_splat_u32(0);
     }
-    ],[
+    int main() { return 0; }
     ],[
     have_gcc_altivec=yes
     ])
Comment 1 Ryan C. Gordon 2006-02-23 07:27:37 UTC
The goal of these tests is to see if the compiler can build the Altivec support, not whether the system can use the instruction set. That's determined at runtime, and Altivec instructions are avoided based on that determination (which lets you, for example, build on a G3, but still use those binaries on a G4 at full speed).

Now, if it's crashing because it hit some Altivec code that it should have avoided on a G3, that's a bug we need to fix, and it sounds like this is happening to you. Can we get a backtrace from one of the crashes?

Thanks,
--ryan.
Comment 2 Emil Styrke 2006-02-25 08:04:11 UTC
I see. From what I can see from the backtrace it's crashing even earlier, but here it is: 

(gdb) r
Starting program: /Users/emil/source/tsbk10/trunk/src/tsbk10 
dyld: incompatible cpu-subtype

Program received signal SIGTRAP, Trace/breakpoint trap.
0x8fe063a8 in __dyld__ZN4dyld5_mainEPK11mach_headeriPPKcS5_S5_ ()
(gdb) bt
#0  0x8fe063a8 in __dyld__ZN4dyld5_mainEPK11mach_headeriPPKcS5_S5_ ()
#1  0x00000000 in _mh_dylib_header ()
Cannot access memory at address 0x0
(gdb) 

The program is linked with this command line:
g++ -dynamiclib -o libnth.dylib ./core/data/manager.o ./core/data/node.o ./core/geometry/line.o ./core/geometry/plane.o ./core/geometry/point.o ./core/geometry/transformation.o ./core/geometry/vector.o ./core/graphics/color.o ./core/graphics/image.o ./core/lighting/light.o ./core/math/matrix.o ./core/physics/body.o ./core/physics/joint.o ./core/physics/object.o ./core/physics/volume.o ./core/scene/overlay.o ./core/scene/pawn.o ./core/skeletons/bone.o ./core/skeletons/motion.o ./core/skeletons/skeleton.o ./core/solids/cuboid.o ./core/solids/ellipsoid.o ./core/solids/solid.o ./core/visuals/mesh.o ./core/world/actor.o ./core/world/entity.o ./engine/application.o ./engine/factory.o ./files/cob_file.o ./files/obj_file.o ./files/tga_file.o ./files/xml_file.o ./logging/log.o ./plugins/input/keyboard.o ./plugins/input/mouse.o ./plugins/rendering/canvas.o ./plugins/rendering/context.o ./plugins/rendering/image_renderer.o ./plugins/rendering/lighter.o ./plugins/rendering/mesh_renderer.o ./plugins/rendering/primitive_renderer.o ./plugins/rendering/shader.o ./plugins/rendering/text_renderer.o ./plugins/rendering/texturer.o ./plugins/script/interpreter.o ./plugins/simulation/collider.o ./plugins/simulation/simulator.o ./plugins/sound/player.o ./plugins/time/timer.o ./plugins/ui/console.o ./plugins/ui/window.o ./system/ode/ode_collider.o ./system/ode/ode_simulator.o ./system/opengl/opengl_context.o ./system/opengl/opengl_image_renderer.o ./system/opengl/opengl_lighter.o ./system/opengl/opengl_mesh_renderer.o ./system/opengl/opengl_primitive_renderer.o ./system/opengl/opengl_text_renderer.o ./system/opengl/opengl_texturer.o ./system/sdl/sdl_canvas.o ./system/sdl/sdl_console.o ./system/sdl/sdl_keyboard.o ./system/sdl/sdl_mouse.o ./system/sdl/sdl_timer.o ./system/sdl/sdl_window.o ./testing/test.o -L/usr/local/lib -L/usr/local/lib -lSDLmain -lSDL -framework Cocoa -framework OpenGL -fPIC
Comment 3 Emil Styrke 2006-02-25 08:08:18 UTC
Argh, that comment got sent away too early, still getting used to the keybindings here.

(In reply to comment #2)
> The program is linked with this command line:

It's supposed to say

g++ -o tsbk10 main.o application.o camera.o particle_system.o -L../nth/source/nth -lnth -L/usr/local/lib -lSDLmain -lSDL -framework Cocoa -framework OpenGL

The one in the prevoius comment is for the library I'm using, libnth. I should also add that I'm using the source build of libSDL and compiling from the command line, not using Xcode or similar.
Comment 4 Ryan C. Gordon 2006-02-26 20:33:46 UTC
Can you try the latest in CVS? And please make sure to re-run ./autogen.sh to rebuild the configure script! I think we needed to add -force_cpusubtype_ALL to SDL compile flags, but I don't have a G3 to verify.

--ryan.

Comment 5 Sam Lantinga 2006-02-26 22:03:19 UTC
For what it's worth, I build on a G3, and have no problems, even before Ryan's change in CVS.

Comment 6 Ryan C. Gordon 2006-02-26 22:52:04 UTC
> For what it's worth, I build on a G3, and have no problems, even before Ryan's
> change in CVS.

But you aren't building on the latest devtools, and I think that's where the issue arises.

--ryan.


Comment 7 Emil Styrke 2006-02-27 11:48:50 UTC
Yes, latest CVS works fine. However, I didn't try the CVS version before the patch, only the 1.2.9 release version.
Comment 8 Ryan C. Gordon 2006-02-27 15:27:12 UTC
We'll call that FIXED going forward, then.

I think the latest devtools broke this, honestly, which is why 1.2.9 worked for us before, but not you recently.

--ryan.