Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/share/mk/bsd.lib.mk,v rcsdiff: /ftp/cvs/cvsroot/src/share/mk/bsd.lib.mk,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.334 retrieving revision 1.367 diff -u -p -r1.334 -r1.367 --- src/share/mk/bsd.lib.mk 2013/04/11 01:27:47 1.334 +++ src/share/mk/bsd.lib.mk 2016/03/12 23:08:58 1.367 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.lib.mk,v 1.334 2013/04/11 01:27:47 christos Exp $ +# $NetBSD: bsd.lib.mk,v 1.367 2016/03/12 23:08:58 mrg Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .include @@ -42,22 +42,12 @@ realinstall: checkver libinstall # XXX: This is needed for programs that link with .a libraries # Perhaps a more correct solution is to always generate _pic.a # files or always have a shared library. -.if defined(MKPIE) && (${MKPIE} != "no") +# XXX: This breaks profiling (__mcount relocation is wrong) +.if defined(MKPIE) && (${MKPIE} != "no") && !defined(NOPIE) CFLAGS+= ${PIE_CFLAGS} AFLAGS+= ${PIE_AFLAGS} .endif -.if (defined(MKDEBUG) && (${MKDEBUG} != "no")) || \ - (defined(CFLAGS) && !empty(CFLAGS:M*-g*)) -# We only add -g to the shared library objects -# because we don't currently split .a archives. -CSHLIBFLAGS+= -g -.if ${LIBISPRIVATE} == "yes" -CFLAGS+= -g -.endif -.endif - - ##### Libraries that this may depend upon. .if defined(LIBDPLIBS) && ${MKPIC} != "no" # { .for _lib _dir in ${LIBDPLIBS} @@ -75,7 +65,7 @@ DPADD+= ${LIBDO.${_lib}}/lib${_lib}.so .endif # } ##### Build and install rules -MKDEP_SUFFIXES?= .o .po .pico .go .ln +MKDEP_SUFFIXES?= .o .po .pico .go .ln .d .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) # { SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major @@ -140,7 +130,7 @@ SHLIB_FULLVERSION=${SHLIB_MAJOR} # Set PICFLAGS to cc flags for producing position-independent code, -# if not already set. Includes -DPIC, if required. +# if not already set. # Data-driven table using make variables to control how shared libraries # are built for different platforms and object formats. @@ -154,48 +144,11 @@ SHLIB_FULLVERSION=${SHLIB_MAJOR} # with ELF, also set shared-lib version for ld.so. # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors -# FPICFLAGS: flags for ${FC} to compile .[fF] files to .pico objects. -# CPPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS} -# CPICFLAGS: flags for ${CC} to compile .[cC] files to pic objects. -# CSHLIBFLAGS: flags for ${CC} to compile .[cC] files to .pico objects. -# (usually includes ${CPICFLAGS}) -# CAPICFLAGS: flags for ${CC} to compiling .[Ss] files -# (usually just ${CPPPICFLAGS} ${CPICFLAGS}) -# APICFLAGS: flags for ${AS} to assemble .[sS] to .pico objects. - -.if ${MACHINE_ARCH} == "alpha" # { - -FPICFLAGS ?= -fPIC -CPICFLAGS ?= -fPIC -DPIC -CPPPICFLAGS?= -DPIC -CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} -APICFLAGS ?= - -.elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") # } { - -# If you use -fPIC you need to define BIGPIC to turn on 32-bit -# relocations in asm code -FPICFLAGS ?= -fPIC -CPICFLAGS ?= -fPIC -DPIC -CPPPICFLAGS?= -DPIC -DBIGPIC -CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} -APICFLAGS ?= -KPIC - -.else # } { - -# Platform-independent flags for NetBSD shared libraries -SHLIB_SOVERSION=${SHLIB_FULLVERSION} -SHLIB_SHFLAGS= -FPICFLAGS ?= -fPIC -CPICFLAGS?= -fPIC -DPIC -CPPPICFLAGS?= -DPIC -CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} -APICFLAGS?= -k -.endif # } +PICFLAGS ?= -fPIC .if ${MKPICLIB} != "no" -CSHLIBFLAGS+= ${CPICFLAGS} +CSHLIBFLAGS+= ${PICFLAGS} .endif .if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS) @@ -204,10 +157,26 @@ MKSHLIBOBJS= yes MKSHLIBOBJS= no .endif +.if (${MKDEBUG:Uno} != "no" && !defined(NODEBUG)) || \ + (defined(CFLAGS) && !empty(CFLAGS:M*-g*)) +# We only add -g to the shared library objects +# because we don't currently split .a archives. +CSHLIBFLAGS+= -g +.if ${LIBISPRIVATE} == "yes" +CFLAGS+= -g +.endif +.endif + # Platform-independent linker flags for ELF shared libraries SHLIB_SOVERSION= ${SHLIB_MAJOR} SHLIB_SHFLAGS= -Wl,-soname,${_LIB}.so.${SHLIB_SOVERSION} +.if !defined(SHLIB_WARNTEXTREL) || ${SHLIB_WARNTEXTREL} != "no" SHLIB_SHFLAGS+= -Wl,--warn-shared-textrel +.endif +.if !defined(SHLIB_MKMAP) || ${SHLIB_MKMAP} != "no" +SHLIB_SHFLAGS+= -Wl,-Map=${_LIB}.so.${SHLIB_SOVERSION}.map +.endif +CLEANFILES+= ${_LIB}.so.${SHLIB_SOVERSION}.map SHLIB_LDSTARTFILE?= ${_GCC_CRTI} ${_GCC_CRTBEGINS} SHLIB_LDENDFILE?= ${_GCC_CRTENDS} ${_GCC_CRTN} @@ -219,6 +188,9 @@ FFLAGS+= ${FOPTS} .if defined(CTFCONVERT) .if defined(CFLAGS) && !empty(CFLAGS:M*-g*) CTFFLAGS+= -g +.if defined(HAVE_GCC) +#CFLAGS+= -gdwarf-2 +.endif .endif .endif @@ -318,7 +290,7 @@ LIBSTRIPSHLIBOBJS= yes .f.pico: ${_MKTARGET_COMPILE} - ${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET} + ${COMPILE.f} ${PICFLAGS} ${.IMPSRC} -o ${.TARGET} .if defined(LIBSTRIPFOBJS) ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} .endif @@ -411,14 +383,14 @@ LIBSTRIPSHLIBOBJS= yes .s.pico: ${_MKTARGET_COMPILE} - ${COMPILE.s} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} + ${COMPILE.s} ${PICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} .if defined(LIBSTRIPAOBJS) ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} .endif .S.pico: ${_MKTARGET_COMPILE} - ${COMPILE.S} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} + ${COMPILE.S} ${PICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} .if defined(LIBSTRIPAOBJS) ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} .endif @@ -435,7 +407,8 @@ _LIB.ln:=llib-l${LIB}.ln _LIB.so:=${_LIB}.so _LIB.so.major:=${_LIB}.so.${SHLIB_MAJOR} _LIB.so.full:=${_LIB}.so.${SHLIB_FULLVERSION} -.if ${MKDEBUG} != "no" +_LIB.so.link:=${_LIB}.so.${SHLIB_FULLVERSION}.link +.if ${MKDEBUG:Uno} != "no" && !defined(NODEBUG) _LIB.so.debug:=${_LIB.so.full}.debug .endif .endif @@ -473,7 +446,7 @@ ${_LIB}_combine.o: ${COMBINESRCS} ${_MKTARGET_COMPILE} ${COMPILE.c} -MD --combine ${.ALLSRC} -o ${.TARGET} .if defined(LIBSTRIPOBJS) - ${OBJCOPY} -x ${.TARGET} + ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET} .endif CLEANFILES+= ${_LIB}_combine.d @@ -552,7 +525,7 @@ _YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YH realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} ${_LIB.so.debug} -MKARZERO?=no +MKARZERO?= ${MKREPRO:Uno} .if ${MKARZERO} == "yes" _ARFL=crsD @@ -623,7 +596,7 @@ DPLIBC ?= ${DESTDIR}${LIBC_SO} .endif .else LDLIBC ?= -nodefaultlibs -.if ${LIB} == "c" +.if ${HAVE_LIBGCC} == "yes" && ${LIB} == "c" LDADD+= -lgcc .endif .endif @@ -631,6 +604,11 @@ LDADD+= -lgcc .if ${LIBISCXX} != "no" LIBCC:= ${CXX} +. if ${MKLIBCXX} == "yes" +LIBDPLIBS+= c++ ${.CURDIR}/../../../../../external/bsd/libc++/lib +. else +LIBDPLIBS+= stdc++ ${.CURDIR}/../../../../../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libstdc++-v3 +. endif .else LIBCC:= ${CC} .endif @@ -638,8 +616,25 @@ LIBCC:= ${CC} _LDADD.${_LIB}= ${LDADD} ${LDADD.${_LIB}} _LDFLAGS.${_LIB}= ${LDFLAGS} ${LDFLAGS.${_LIB}} -${_LIB.so.full}: ${SOLIB} ${DPADD} ${DPLIBC} \ - ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE} +_MAINLIBDEPS= ${SOLIB} ${DPADD} ${DPLIBC} \ + ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE} + +.if defined(_LIB.so.debug) +${_LIB.so.debug}: ${_LIB.so.link} + ${_MKTARGET_CREATE} + ( ${OBJCOPY} --only-keep-debug \ + ${_LIB.so.link} ${_LIB.so.debug} \ + ) || (rm -f ${.TARGET}; false) +${_LIB.so.full}: ${_LIB.so.link} ${_LIB.so.debug} + ${_MKTARGET_CREATE} + ( ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ + --add-gnu-debuglink=${_LIB.so.debug} \ + ${_LIB.so.link} ${_LIB.so.full} \ + ) || (rm -f ${.TARGET}; false) +${_LIB.so.link}: ${_MAINLIBDEPS} +.else # aka no MKDEBUG +${_LIB.so.full}: ${_MAINLIBDEPS} +.endif ${_MKTARGET_BUILD} rm -f ${.TARGET} ${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} \ @@ -649,6 +644,8 @@ ${_LIB.so.full}: ${SOLIB} ${DPADD} ${DPL # We don't use INSTALL_SYMLINK here because this is just # happening inside the build directory/objdir. XXX Why does # this spend so much effort on libraries that aren't live??? XXX +# XXX Also creates dead symlinks until the .full rule runs +# above and creates the main link .if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \ "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}" ${HOST_LN} -sf ${_LIB.so.full} ${_LIB.so.major}.tmp @@ -660,15 +657,6 @@ ${_LIB.so.full}: ${SOLIB} ${DPADD} ${DPL ${OBJCOPY} -R .ident ${.TARGET} .endif -.if defined(_LIB.so.debug) -${_LIB.so.debug}: ${_LIB.so.full} - ${_MKTARGET_CREATE} - ( ${OBJCOPY} --only-keep-debug ${_LIB.so.full} ${_LIB.so.debug} \ - && ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ - --add-gnu-debuglink=${_LIB.so.debug} ${_LIB.so.full} \ - ) || (rm -f ${.TARGET}; false) -.endif - .if !empty(LOBJS) # { LLIBS?= -lc ${_LIB.ln}: ${LOBJS}