Re: [DynInst_API:] Improving dyninst rpm packaging


Date: Fri, 15 Jun 2012 11:10:01 -0400
From: William Cohen <wcohen@xxxxxxxxxx>
Subject: Re: [DynInst_API:] Improving dyninst rpm packaging
On 06/14/2012 03:05 PM, William Cohen wrote:

> Hi Matt,
> 
> I did some looking around and found that other packages using shared libaries force the so name with something like
>  "-Wl,-soname,your_soname" when the .so file is linked/built.  If this option isn't include in the linking of the .so file then the name used is what ever the file (or symbolic link) name is. So the question is how to best get this option into the make files.
> 
> Maybe in the various make.module.tmpl files:
> 
> LDFLAGS		+= -shared $(G_PTHREAD_LD) -Wl,-soname,$(TARGET).$(RELEASE_NUM)
> 
> Something like the attached patch. It might not be complete and might not work on other architectures or OSs, but I was able to build an rpm on x86_64 successfully and install the resulting RPMs.
> 
> There is an f17 scratch build of the same SRPM at:
> 
> http://koji.fedoraproject.org/koji/taskinfo?taskID=4163339
> 
> 
> -Will

Hi Matt,

I found that I didn't have the soname correct for the 32-bit version of dyninstAPI_RT. The attached patch that addresses that.

Also made a scratch builds of the rpm available at:

http://koji.fedoraproject.org/koji/taskinfo?taskID=4167561

-Will
diff --git a/common/make.module.tmpl dyninst/common/make.module.tmpl
index bbb653f..1a5504d 100644
--- a/common/make.module.tmpl
+++ dyninst/common/make.module.tmpl
@@ -42,7 +42,7 @@ endif
 LDFLAGS     += $(LIBDIR)
 ifndef USES_NATIVE_CC
 LD		= $(GXX)
-LDFLAGS		+= -shared $(G_PTHREAD_LD)
+LDFLAGS		+= -shared $(G_PTHREAD_LD) -Wl,-soname,$(TARGET).$(RELEASE_NUM)
 CFLAGS		+= 
 CXXFLAGS	+=  $(G_PTHREAD)
 else
diff --git a/dynC_API/make.module.tmpl dyninst/dynC_API/make.module.tmpl
index 4877486..a016ece 100644
--- a/dynC_API/make.module.tmpl
+++ dyninst/dynC_API/make.module.tmpl
@@ -22,7 +22,7 @@ LDFLAGS += -L../../common/$(PLATFORM) -L../../symtabAPI/$(PLATFORM) -L../../dyni
 LDFLAGS     += $(LIBDIR)
 ifndef USES_NATIVE_CC
 LD		= $(GXX)
-LDFLAGS		+= -shared $(G_PTHREAD_LD)
+LDFLAGS		+= -shared $(G_PTHREAD_LD) -Wl,-soname,$(TARGET).$(RELEASE_NUM)
 CFLAGS		+= -fPIC
 CXXFLAGS	+= -fPIC $(G_PTHREAD)
 else
diff --git a/dyninstAPI/make.module.tmpl dyninst/dyninstAPI/make.module.tmpl
index fabb448..378fea7 100644
--- a/dyninstAPI/make.module.tmpl
+++ dyninst/dyninstAPI/make.module.tmpl
@@ -54,7 +54,7 @@ LDFLAGS     += -L../../stackwalk/$(PLATFORM)
 
 ifndef USES_NATIVE_CC
 LD		= $(GXX)
-LDFLAGS		+= -shared $(G_PTHREAD_LD) 
+LDFLAGS		+= -shared $(G_PTHREAD_LD) -Wl,-soname,$(TARGET).$(RELEASE_NUM)
 CFLAGS		+= -fPIC
 CXXFLAGS	+= -fPIC $(G_PTHREAD)
 else
diff --git a/dyninstAPI_RT/i386-unknown-linux2.4/Makefile dyninst/dyninstAPI_RT/i386-unknown-linux2.4/Makefile
index aa39e22..4f4619a 100644
--- a/dyninstAPI_RT/i386-unknown-linux2.4/Makefile
+++ dyninst/dyninstAPI_RT/i386-unknown-linux2.4/Makefile
@@ -18,7 +18,7 @@ endif
 
 # Now make any necessary architecture specific changes to variables:
 LD		= $(GCC)
-LDFLAGS         += -shared
+LDFLAGS         += -shared -Wl,-soname,$(TARGET).$(RELEASE_NUM)
 CFLAGS		+= -O2
 
 # if we want to produce a shared object...
diff --git a/dyninstAPI_RT/x86_64-unknown-linux2.4/Makefile dyninst/dyninstAPI_RT/x86_64-unknown-linux2.4/Makefile
index 3f72429..12eec29 100644
--- a/dyninstAPI_RT/x86_64-unknown-linux2.4/Makefile
+++ dyninst/dyninstAPI_RT/x86_64-unknown-linux2.4/Makefile
@@ -17,7 +17,7 @@ endif
 
 # Now make any necessary architecture specific changes to variables:
 LD		= $(GCC)
-LDFLAGS         += -shared
+LDFLAGS         += -shared -Wl,-soname,$(TARGET).$(RELEASE_NUM)
 LDFLAGS		+= -m64
 CFLAGS		+= -Wall -m64 -DMUTATEE64
 
@@ -64,7 +64,7 @@ VOUCHER_32   = V_$(XTARGET_32)
 OBJS_32      = $(patsubst %.c, %_m32.o, $(filter %.c,$(notdir $(SRCS))))
 ASM_OBJS_32  = $(patsubst %.S, %_m32.o, $(filter %.S,$(notdir $(ASM_SRCS_32))))
 CFLAGS_32    = $(subst -DMUTATEE64,-DMUTATEE_32,$(CFLAGS))
-LDFLAGS_32   = $(LDFLAGS)
+LDFLAGS_32   = $(subst $(TARGET),$(TARGET_32_SO),$(subst -m64,-m32,$(LDFLAGS)))
 LIBS_32      = -L/usr/lib $(LIBS)
 
 
@@ -81,7 +81,7 @@ $(VOUCHER_32):
 $(TARGET_32_SO): $(OBJS_32) $(ASM_OBJS_32)
 	$(HIDE_COMP)$(RM) $(TARGET_32_SO)
 	$(HIDE_COMP)$(MAKE) $(VOUCHER_32)
-	$(HIDE_COMP)$(LD) $(subst -m64,-m32,$(LDFLAGS_32)) -o $(TARGET_32_SO) $(VOUCHER_32).o $(OBJS_32) $(ASM_OBJS_32) $(LIBS_32)
+	$(HIDE_COMP)$(LD) $(LDFLAGS_32) -o $(TARGET_32_SO) $(VOUCHER_32).o $(OBJS_32) $(ASM_OBJS_32) $(LIBS_32)
 RTspace.o: ../src/RTspace.S
 	@echo "Compiling RTspace"
 	$(HIDE_COMP)$(CC) $(CFLAGS) -c $< -o $@
diff --git a/instructionAPI/make.module.tmpl dyninst/instructionAPI/make.module.tmpl
index 34d4bdc..f8fe036 100644
--- a/instructionAPI/make.module.tmpl
+++ dyninst/instructionAPI/make.module.tmpl
@@ -21,7 +21,7 @@ LDFLAGS += -lcommon
 LDFLAGS     += -L../../common/$(PLATFORM)
 ifndef USES_NATIVE_CC
 LD		= $(GXX)
-LDFLAGS		+= -shared $(G_PTHREAD_LD)
+LDFLAGS		+= -shared $(G_PTHREAD_LD) -Wl,-soname,$(TARGET).$(RELEASE_NUM)
 CFLAGS		+= -fPIC -g
 CXXFLAGS	+= -fPIC $(G_PTHREAD) -felide-constructors -g
 else
diff --git a/parseAPI/make.module.tmpl dyninst/parseAPI/make.module.tmpl
index ee27ef6..59bb98d 100644
--- a/parseAPI/make.module.tmpl
+++ dyninst/parseAPI/make.module.tmpl
@@ -19,7 +19,7 @@ LDFLAGS += -L../../common/$(PLATFORM) -L../../symtabAPI/$(PLATFORM) -lcommon -ls
 LDFLAGS     += $(LIBDIR)
 ifndef USES_NATIVE_CC
 LD		= $(GXX)
-LDFLAGS		+= -shared $(G_PTHREAD_LD)
+LDFLAGS		+= -shared $(G_PTHREAD_LD) -Wl,-soname,$(TARGET).$(RELEASE_NUM)
 CFLAGS		+= -fPIC
 CXXFLAGS	+= -fPIC $(G_PTHREAD)
 else
diff --git a/proccontrol/make.module.tmpl dyninst/proccontrol/make.module.tmpl
index 10522ac..d0cc6ed 100644
--- a/proccontrol/make.module.tmpl
+++ dyninst/proccontrol/make.module.tmpl
@@ -39,7 +39,7 @@ LDFLAGS += -L../../common/$(PLATFORM)
 
 ifndef USES_NATIVE_CC
 LD		= $(GXX)
-LDFLAGS		+= -shared
+LDFLAGS		+= -shared -Wl,-soname,$(TARGET).$(RELEASE_NUM)
 CFLAGS		+= 
 CXXFLAGS	+= 
 else
diff --git a/stackwalk/make.module.tmpl dyninst/stackwalk/make.module.tmpl
index 16e7c07..f68eab7 100644
--- a/stackwalk/make.module.tmpl
+++ dyninst/stackwalk/make.module.tmpl
@@ -31,7 +31,7 @@ endif
 LDFLAGS += -L$(TO_CORE)/common/$(PLATFORM) -L$(LIBRARY_DEST)
 ifndef USES_NATIVE_CC
 LD		= $(GXX)
-LDFLAGS		+= -shared
+LDFLAGS		+= -shared -Wl,-soname,$(TARGET).$(RELEASE_NUM)
 CFLAGS		+= 
 CXXFLAGS	+= 
 else
diff --git a/symtabAPI/make.module.tmpl dyninst/symtabAPI/make.module.tmpl
index e922497..3c24e17 100644
--- a/symtabAPI/make.module.tmpl
+++ dyninst/symtabAPI/make.module.tmpl
@@ -57,7 +57,7 @@ endif
 
 ifndef USES_NATIVE_CC
 LD		= $(GXX)
-LDFLAGS		+= -shared $(G_PTHREAD_LD)
+LDFLAGS		+= -shared $(G_PTHREAD_LD) -Wl,-soname,$(TARGET).$(RELEASE_NUM)
 CFLAGS		+= 
 CXXFLAGS	+= $(G_PTHREAD)
 else
[← Prev in Thread] Current Thread [Next in Thread→]