Subject: proposal of CSHLIBFLAGS in bsd.lib.mk
To: None <tech-userlevel@netbsd.org>
From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
List: tech-userlevel
Date: 12/03/2001 11:42:33
----Next_Part(Mon_Dec__3_11:42:33_2001_070)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
hi.
working on locale support,
I need cflags that affect only shared libs.
since our dlopen always fails on static binaries,
we're #ifdef'ing out dynamic loading stuff in libc
in order to avoid unnecessary code bloat.
currently we're using CPICFLAGS for this purpose.
(see src/lib/libc/Makefile)
however, since all libs are pic on mips and vax,
CPICFLAGS isn't proper.
I attach patches for review.
(patches includes a fix for crash dump at dlopen on mips,
due to no -DPIC, which is reported on citrus ML.)
thanks.
---
YAMAMOTO Takashi<yamt@mwd.biglobe.ne.jp>
----Next_Part(Mon_Dec__3_11:42:33_2001_070)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="bsd.lib.mk.diff"
Index: bsd.lib.mk
===================================================================
RCS file: /cvs/cvsroot/sharesrc/share/mk/bsd.lib.mk,v
retrieving revision 1.194
diff -u -p -r1.194 bsd.lib.mk
--- bsd.lib.mk 2001/11/28 04:38:29 1.194
+++ bsd.lib.mk 2001/12/03 01:06:30
@@ -87,8 +87,10 @@ SHLIB_FULLVERSION=${SHLIB_MAJOR}
# SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
# FPICFLAGS: flags for ${FC} to compile .[fF] files to .so objects.
# CPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS}
-# CPICFLAGS: flags for ${CC} to compile .[cC] files to .so objects.
-# CAPICFLAGS flags for {$CC} to compiling .[Ss] files
+# CPICFLAGS: flags for ${CC} to compile .[cC] files to pic objects.
+# CSHLIBFLAGS: flags for ${CC} to compile .[cC] files to .so objects.
+# (usually includes ${CPICFLAGS})
+# CAPICFLAGS: flags for ${CC} to compiling .[Ss] files
# (usually just ${CPPPICFLAGS} ${CPICFLAGS})
# APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects.
@@ -138,6 +140,16 @@ APICFLAGS?= -k
MKPICLIB?= yes
+.if ${MKPICLIB} != "no"
+CSHLIBFLAGS+= ${CPICFLAGS}
+.endif
+
+.if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
+MKSHLIBOBJS= yes
+.else
+MKSHLIBOBJS= no
+.endif
+
# Platform-independent linker flags for ELF shared libraries
.if ${OBJECT_FMT} == "ELF"
SHLIB_SOVERSION= ${SHLIB_MAJOR}
@@ -171,10 +183,10 @@ FFLAGS+= ${FOPTS}
.c.so:
.if defined(COPTS) && !empty(COPTS:M*-g*)
- ${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
+ ${COMPILE.c} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
.else
- @echo ${COMPILE.c:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
- @${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
+ @echo ${COMPILE.c:Q} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
+ @${COMPILE.c} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.o
@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
@rm -f ${.TARGET}.o
.endif
@@ -204,10 +216,10 @@ FFLAGS+= ${FOPTS}
.cc.so .C.so:
.if defined(COPTS) && !empty(COPTS:M*-g*)
- ${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
+ ${COMPILE.cc} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
.else
@echo ${COMPILE.cc:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
- @${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
+ @${COMPILE.cc} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.o
@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
@rm -f ${.TARGET}.o
.endif
@@ -267,10 +279,10 @@ FFLAGS+= ${FOPTS}
.m.so:
.if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*)
- ${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
+ ${COMPILE.m} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
.else
@echo ${COMPILE.m:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
- @${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
+ @${COMPILE.m} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.o
@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
@rm -f ${.TARGET}.o
.endif
@@ -309,7 +321,15 @@ POBJS+=${OBJS:.o=.po}
.if ${MKPIC} != "no"
.if ${MKPICLIB} == "no"
+.if ${MKSHLIBOBJS} != "no"
+# make _pic.a, which isn't really pic,
+# since it's needed for making shared lib.
+# but don't install it.
+SOLIB=lib${LIB}_pic.a
+SOBJS+=${OBJS:.o=.so}
+.else
SOLIB=lib${LIB}.a
+.endif
.else
SOLIB=lib${LIB}_pic.a
_LIBS+=${SOLIB}
----Next_Part(Mon_Dec__3_11:42:33_2001_070)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="libc.Makefile.diff"
Index: Makefile
===================================================================
RCS file: /cvs/cvsroot/basesrc/lib/libc/Makefile,v
retrieving revision 1.99
diff -u -p -r1.99 Makefile
--- Makefile 2001/09/02 13:13:41 1.99
+++ Makefile 2001/12/03 01:08:17
@@ -132,9 +132,10 @@ FILES= ${.OBJDIR}/tags
FILESNAME= libc.tags
FILESDIR= /var/db
-.include <bsd.lib.mk>
# workaround for lib/libc/locale: build singlebyte setlocale() for libc.a,
# multibyte for libc.so. the quirk should be removed when we support
# dlopen() from within statically linked binaries.
-CPICFLAGS+= -DDLRUNE
+CSHLIBFLAGS+= -DLRUNE
+
+.include <bsd.lib.mk>
----Next_Part(Mon_Dec__3_11:42:33_2001_070)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="dlfcn_elf.c.diff"
Index: dlfcn_elf.c
===================================================================
RCS file: /cvs/cvsroot/basesrc/lib/libc/dlfcn/dlfcn_elf.c,v
retrieving revision 1.2
diff -u -p -r1.2 dlfcn_elf.c
--- dlfcn_elf.c 2000/07/06 02:48:41 1.2
+++ dlfcn_elf.c 2001/12/03 02:34:56
@@ -30,7 +30,6 @@
__RCSID("$NetBSD: dlfcn_elf.c,v 1.2 2000/07/06 02:48:41 christos Exp $");
#endif /* LIBC_SCCS and not lint */
-#if defined(PIC) || defined(lint)
#include "namespace.h"
#define ELFSIZE ARCH_ELFSIZE
@@ -50,4 +49,3 @@ __weak_alias(dladdr,__dladdr)
#endif
#include <dlfcn_stubs.c>
-#endif /* PIC */
----Next_Part(Mon_Dec__3_11:42:33_2001_070)----