[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Artsdsp and 32bit applications



In my quest to run doom3 with working sound on my pure64 box I need to use artsdsp. Artsdsp is a simple shell script which sets a few enviroment variables, and LD_PRELOAD accordingly, however if I'm running a 32bit application it always tries to load /usr/lib/libartsdsp.so.0 regardless. (I've added all of my chroot lib directories to /etc/ld.so.conf so I don't have to have to chroot to the 32bit enviroment to run most 32bit applications).

What I've done now is write a little patch for artsdsp which makes it attempt to work out where 32bit and 64bit versions of libartsdsp.so live, and then look at the application we're going to be running and see which one it should use with it.

I've tested this with doom3 on the 32bit side, and confirmed that it all works by running 32 and 64 bit versions of glxgears with it. Anyway, long story short I thought someone else on this list might be vaugely interested in this, or in telling me that theres a much much simpler way to solve this problem (yes, I did think of setting LD_PRELOAD manualy everytime I want to run a 32bit app, but where's the fun in that?). Also I wondered if anyone thought there was much point in submitting this patch to bts?

Anyway, I can now play doom 3 in linux on pure64 with sound (no more annoying SNDCTL_DSP_SPEED errors), so I'm happy :-)

Alan
--- artsdsp.old	2004-10-23 22:48:43.525872896 +0100
+++ artsdsp	2004-10-23 22:01:36.427657152 +0100
@@ -75,6 +75,50 @@
     esac
 done
 
+
+# AMD64 32/64bit application compatiblitiy Alan Woodland <ajw2@aber.ac.uk>
+
+#ok firstly we want to work out where our 64 and 32bit artsdsp.so.* libraries are...
+
+ARTS64LIB=""
+ARTS32LIB=""
+
+#so we look everwhere we expect to find libraries
+for libdir in "/usr/lib" "/lib" `cat /etc/ld.so.conf` 
+do
+	#now in each of those directories we look for libartsdsp.*
+	for artslib in `ls $libdir/libartsdsp.so.* 2>/dev/null`
+	do
+		if [ `file -L $artslib | egrep -o "(32|64)-bit" | grep -o "[36][24]"` == "64" ]
+		then
+			ARTS64LIB=$libdir
+		fi
+		
+		if [ `file -L $artslib | egrep -o "(32|64)-bit" | grep -o "[36][24]"` == "32" ]
+		then
+			ARTS32LIB=$libdir
+		fi		
+		
+	done
+done
+
+#work out which libdir to use now
+
+libdir=$ARTS32LIB #default to 32bit lib if we found one
+appbits=`file -L $1 | egrep -o "(32|64)-bit" | grep -o "[36][24]"`
+if [ $appbits == "64" ]
+then
+		libdir=$ARTS64LIB
+fi
+
+if [ ! -d $libdir ]
+then
+	echo "Warning: no libdir selected, resorting to defaults"
+	prefix=/usr
+	exec_prefix=${prefix}
+	libdir=${exec_prefix}/lib
+fi
+
 # echo options if verbose specified
 if test "$verbose" = 1; then
     ARTSDSP_VERBOSE=1
@@ -87,21 +131,25 @@
     else
         echo "threaded:      yes"
     fi
+	 echo "64bit libdir:  $ARTS64LIB"
+	 echo "32bit libdir:  $ARTS32LIB"
+	 echo "Selected dir:  $libdir"
 fi
 
 # setup artsdsp preload to hijack calls made to /dev/dsp
-prefix=/usr
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-
 if test "$single_thread" = 1; then
   LD_PRELOAD=${libdir}/libartsdsp_st.so.0
 else
   LD_PRELOAD=${libdir}/libartsdsp.so.0:${libdir}/libartsc.so.0
 fi
-if test -f /lib/libdl.so.2; then
-  LD_PRELOAD=$LD_PRELOAD:/lib/libdl.so.2
-fi
+
+#if [ `file -L /lib/libdl.so.2 | egrep -o "(32|64)-bit" | grep -o "[36][24]"` == $appbits ] 
+#then
+#	if test -f /lib/libdl.so.2; then
+#	  LD_PRELOAD=$LD_PRELOAD:/lib/libdl.so.2
+#	fi
+#fi
+
 export LD_PRELOAD
 
 # invoke the program with the args given

Reply to: