Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Ticket #112 (closed enhancement: fixed)

Opened 7 years ago

Last modified 7 years ago

Enhance build

Reported by: bioinfornatics Assigned to: Mike Wey
Priority: major Milestone:
Component: Structure and Packaging Version: TRUNK
Keywords: Cc:

Description

since -lib flag for dmd / ldc need 1 obj you shoule merge all obj together for this use ld the patch create a right shared lib and use -shared flag already in ldc

diff -up gtkd/GNUmakefile.fix gtkd/GNUmakefile
--- gtkd/GNUmakefile.fix	2011-12-07 23:59:32.206838068 +0100
+++ gtkd/GNUmakefile	2011-12-08 03:12:07.094553473 +0100
@@ -68,32 +68,32 @@ endef
 
 #######################################################################
 
-LIBNAME_GTKD = libgtkd.a
-SONAME_GTKD = libgtkd.so
+LIBNAME_GTKD = libgtkd-$(DC).a
+SONAME_GTKD = libgtkd-$(DC).so
 SOURCES_GTKD = $(subst src/build/gtkD.d,,$(wildcard src/*/*.d))
 OBJECTS_GTKD = $(patsubst %.d,%.o,$(SOURCES_GTKD))
 PICOBJECTS_GTKD = $(patsubst %.o,%.pic.o,$(OBJECTS_GTKD))
 
-LIBNAME_GTKDGL = libgtkdgl.a
-SONAME_GTKDGL = libgtkdgl.so
+LIBNAME_GTKDGL = libgtkdgl-$(DC).a
+SONAME_GTKDGL = libgtkdgl-$(DC).so
 SOURCES_GTKDGL = $(wildcard srcgl/*/*.d)
 OBJECTS_GTKDGL = $(patsubst %.d,%.o,$(SOURCES_GTKDGL))
 PICOBJECTS_GTKDGL = $(patsubst %.o,%.pic.o,$(OBJECTS_GTKDGL))
 
-LIBNAME_GTKDSV = libgtkdsv.a
-SONAME_GTKDSV = libgtkdsv.so
+LIBNAME_GTKDSV = libgtkdsv-$(DC).a
+SONAME_GTKDSV = libgtkdsv-$(DC).so
 SOURCES_GTKDSV = $(wildcard srcsv/*/*.d)
 OBJECTS_GTKDSV = $(patsubst %.d,%.o,$(SOURCES_GTKDSV))
 PICOBJECTS_GTKDSV = $(patsubst %.o,%.pic.o,$(OBJECTS_GTKDSV))
 
-LIBNAME_GTKDGDA = libgtkdgda.a
-SONAME_GTKDGDA = libgtkdgda.so
+LIBNAME_GTKDGDA = libgtkdgda-$(DC).a
+SONAME_GTKDGDA = libgtkdgda-$(DC).so
 SOURCES_GTKDGDA = $(wildcard srcgda/*/*.d)
 OBJECTS_GTKDGDA = $(patsubst %.d,%.o,$(SOURCES_GTKDGDA))
 PICOBJECTS_GTKDGDA = $(patsubst %.o,%.pic.o,$(OBJECTS_GTKDGDA))
 
-LIBNAME_GSTREAMERD = libgstreamerd.a
-SONAME_GSTREAMERD = libgstreamerd.so
+LIBNAME_GSTREAMERD = libgstreamerd-$(DC).a
+SONAME_GSTREAMERD = libgstreamerd-$(DC).so
 SOURCES_GSTREAMERD = $(wildcard srcgstreamer/*/*.d)
 OBJECTS_GSTREAMERD = $(patsubst %.d,%.o,$(SOURCES_GSTREAMERD))
 PICOBJECTS_GSTREAMERD = $(patsubst %.o,%.pic.o,$(OBJECTS_GSTREAMERD))
@@ -163,24 +163,34 @@ $(LIBNAME_GSTREAMERD): $(LIBNAME_GTKD) $
 # $(DC) $(LINKERFLAG)-shared $^ $(output)
 
 $(SONAME_GTKD): IMPORTS=-Isrc
-$(SONAME_GTKD): $(PICOBJECTS_GTKD)
-	$(CC) -shared $^ -o $@
+gtkd_merged.o : $(PICOBJECTS_GTKD)
+	ld -r $^ -o $@
+$(SONAME_GTKD): gtkd_merged.o
+	$(DC) $(IMPORTS)  $< $(output) -shared
 
 $(SONAME_GTKDGL): IMPORTS=-Isrc -Isrcgl
-$(SONAME_GTKDGL): $(PICOBJECTS_GTKDGL)
-	$(CC) -shared $^ -o $@
+gtkd_gl_merged.o : $(PICOBJECTS_GTKDGL)
+	ld -r $^ -o $@
+$(SONAME_GTKDGL): gtkd_gl_merged.o
+	$(DC) $(IMPORTS) $^ $(output) -shared
 
 $(SONAME_GTKDSV): IMPORTS=-Isrc -Isrcsv
-$(SONAME_GTKDSV): $(PICOBJECTS_GTKDSV)
-	$(CC) -shared $^ -o $@
+gtkd_dsv_merged.o : $(PICOBJECTS_GTKDSV)
+	ld -r $^ -o $@
+$(SONAME_GTKDSV): gtkd_dsv_merged.o
+	$(DC) $(IMPORTS)  $^ $(output) -shared
 
 $(SONAME_GTKDGDA): IMPORTS=-Isrc -Isrcgda
-$(SONAME_GTKDGDA): $(PICOBJECTS_GTKDGDA)
-	$(CC) -shared $^ -o $@
+gtkd_gda_merged.o : $(PICOBJECTS_GTKDGDA)
+	ld -r $^ -o $@
+$(SONAME_GTKDGDA): gtkd_gda_merged.o
+	$(DC) $(IMPORTS) $^ $(output) -shared
 
 $(SONAME_GTKDGSTREAMERD): IMPORTS=-Isrc -Isrcgstreamer
-$(SONAME_GTKDGSTREAMERD): $(PICOBJECTS_GTKDGSTREAMERD)
-	$(CC) -shared $^ -o $@
+gtkd_streamerd_merged.o : $(PICOBJECTS_GTKDGSTREAMERD)
+	ld -r $^ -o $@
+$(SONAME_GTKDGSTREAMERD): gtkd_streamerd_merged.o
+	$(DC) $(IMPORTS) $^ $(output) -shared
 
 #######################################################################

Change History

12/08/11 23:00:58 changed by bioinfornatics

  • type changed from defect to enhancement.

12/11/11 22:35:16 changed by Mike Wey

  • component changed from Addon - gda to Structure and Packaging.

The makefile you posted in the announce newsgroup doesn't use this two step linking setup for the shared libraries.

What is the benefit of linking like this?

(follow-up: ↓ 5 ) 12/13/11 03:21:55 changed by bioinfornatics

linking with gcc see to not works all the time and produce a corrupted .so instead to use -shared ldc flag maybe embed this one into var for match to -dylib if dmd

12/13/11 03:24:30 changed by bioinfornatics

in more you can add to you system gtk build with ldc dmd gdc in same path like each one has a suffix

It will be cool to create a pkg-config file like i have shown in makefile template

thanks

(in reply to: ↑ 3 ) 12/18/11 22:23:04 changed by Mike Wey

Replying to bioinfornatics:

linking with gcc see to not works all the time and produce a corrupted .so instead to use -shared ldc flag maybe embed this one into var for match to -dylib if dmd

While using gcc directly works when phobos/druntime are build as static libraries, going trough ldc requires phobos/druntime to be build as shared libraries.

And the only this ldc does which the call to gcc doesn't is providing the libraries gtkd depends on on the commandline, so this information can be included in the shared lib. But since these are the same libraries that are linked in when building the application this shouldn't really matter.

Can you provide a use case where calling gcc directly results in a broken shared lib?

01/21/12 18:04:55 changed by bioinfornatics

-dylib is deprecated since 2.058 all compiler use -shared. this will help us to have a makefile for doing a shared lib. The main problem it gcc can't do a dynalmic link against a dynamic lib written in D. ldc use already shared lib for runtime and phobos and dmd will do same with 2.058. So it will be great to use the patch in forum or this one. This one in more allow to have gtkd build with ldc dmd gdc on same machine like each have a -$(DC) suffix for the lib.

What did you think ?

01/30/12 22:19:15 changed by Mike Wey

  • status changed from new to closed.
  • resolution set to fixed.

I haven't included the compiler suffix yet, but svn r923 uses the -shared flag and uses ld -r.