From: Steven Munroe Date: Tue, 19 May 2009 17:14:53 +0000 (-0400) Subject: Fix opensuse powerpc build X-Git-Tag: v0.1~218 X-Git-Url: https://git.lttng.org/?p=urcu.git;a=commitdiff_plain;h=bcf80111ad144058db3ff6cfde668291c814214f Fix opensuse powerpc build I gave this code a spin on a G5 (PPC970) OpenSuse 10.3 system and encountered same issues that should fix fot tyou next update. The liburcu make system sis not set up for biarch (32-/64-bit) builds on PPC. SLES10/OpenSUSE-10.3 is a default 32-bit, 64-bit capable system. To build a 64-bit you need to insert -m64 for all compiles and link operations. Also for 64-bit make install should move liburcu.so to /usr/lib64 not /usr/lib. This is required to FSB complience. Is worked around this by copying Makefile to Makefile64 and made the required changes there. For SLES11 we changed to to a 64-bit default and 32-bit capable system. In either case you need to be able to build both 32-/64-bit liburcu.so on same systems and need to insure that make install is appropriate. Also I found that __SIZEOF_LONG__ was not defined and resulted in a sigill on PPC64. I suspect this is XLC specific and you need solution that works for GCC builds as well. I have attached a patch that implement these change for your review. With this patch I can build liburcu and run the tests successfully. Finally when I build 32-bit (default for OpenSUSE 10) I get a unhandled SIGUSER1. I ran out of weekend before I could figure that out. Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile64 b/Makefile64 new file mode 100644 index 0000000..7c343a3 --- /dev/null +++ b/Makefile64 @@ -0,0 +1,79 @@ + +#CFLAGS=-m64 -Wall -O2 -g -I. +CFLAGS=-m64 -O2 -g -I. +LDFLAGS=-lpthread + +#debug +#CFLAGS=-Wall -g +#CFLAGS+=-DDEBUG_FULL_MB + +#Changing the signal number used by the library. SIGUSR1 by default. +#CFLAGS+=-DSIGURCU=SIGUSR2 + +SRC_DEP=`echo $^ | sed 's/[^ ]*.h//g'` + +all: arch-api test_urcu test_urcu_dynamic_link test_urcu_timing \ + test_rwlock_timing test_urcu_yield urcu-asm.S \ + urcu-asm.o urcutorture urcutorture-yield liburcu.so + +arch-api: api.h arch.h + # Run either make pthreads-x86 or make pthreads-ppc prior to build + # the RCU library. Architecture auto-detectection not implemented + # in the build system yet. + +pthreads-x86: clean + cp api_x86.h api.h + cp arch_x86.h arch.h + cp arch_atomic_x86.h arch_atomic.h + +pthreads-ppc: clean + cp api_ppc.h api.h + cp arch_ppc.h arch.h + cp arch_atomic_ppc.h arch_atomic.h + +test_urcu: urcu.o test_urcu.c urcu.h + $(CC) ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP) + +test_urcu_dynamic_link: urcu.o test_urcu.c urcu.h + $(CC) ${CFLAGS} -DDYNAMIC_LINK_TEST $(LDFLAGS) -o $@ $(SRC_DEP) + +test_urcu_yield: urcu-yield.o test_urcu.c urcu.h + $(CC) -DDEBUG_YIELD ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP) + +test_urcu_timing: urcu.o test_urcu_timing.c urcu.h + $(CC) ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP) + +test_rwlock_timing: urcu.o test_rwlock_timing.c urcu.h + $(CC) ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP) + +urcu.o: urcu.c urcu.h + $(CC) -fPIC ${CFLAGS} $(LDFLAGS) -c -o $@ $(SRC_DEP) + +liburcu.so: urcu.o + $(CC) -m64 -fPIC -shared -o $@ $< + +urcu-yield.o: urcu.c urcu.h + $(CC) -DDEBUG_YIELD ${CFLAGS} $(LDFLAGS) -c -o $@ $(SRC_DEP) + +urcu-asm.S: urcu-asm.c urcu.h + $(CC) ${CFLAGS} -S -o $@ $(SRC_DEP) + +urcu-asm.o: urcu-asm.c urcu.h + $(CC) ${CFLAGS} -c -o $@ $(SRC_DEP) + +urcutorture: urcutorture.c urcu.o urcu.h rcutorture.h + $(CC) ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP) + +urcutorture-yield: urcutorture.c urcu-yield.o urcu.h rcutorture.h + $(CC) -DDEBUG_YIELD ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP) + +.PHONY: clean install arch-api + +install: liburcu.so + cp -f liburcu.so /usr/lib64/ + cp -f arch.h arch_atomic.h compiler.h urcu.h urcu-static.h /usr/include/ + +clean: + rm -f *.o test_urcu test_urcu_timing test_rwlock_timing urcu-asm.S \ + test_urcu_yield urcutorture urcutorture-yield liburcu.so \ + test_urcu_dynamic_link api.h arch.h arch_atomic.h diff --git a/arch_atomic_ppc.h b/arch_atomic_ppc.h index 587fb8b..d666230 100644 --- a/arch_atomic_ppc.h +++ b/arch_atomic_ppc.h @@ -20,6 +20,14 @@ * Boehm-Demers-Weiser conservative garbage collector. */ +#ifndef __SIZEOF_LONG__ +#ifdef __powerpc64__ +#define __SIZEOF_LONG__ 8 +#else +#define __SIZEOF_LONG__ 4 +#endif +#endif + #ifndef BITS_PER_LONG #define BITS_PER_LONG (__SIZEOF_LONG__ * 8) #endif @@ -67,7 +75,7 @@ unsigned long atomic_exchange_64(volatile unsigned long *addr, "stdcx. %2,0,%1\n" /* else store conditional */ "bne- 1b\n" /* retry if lost reservation */ "isync\n" - : "=&r"(result), + : "=&r"(result) : "r"(addr), "r"(val) : "memory", "cc");