[PATCH] Add WITH_DEBUG_FILES knob to enable separate debug files
Alfred Perlstein
bright at mu.org
Sun Dec 23 04:13:15 UTC 2012
On 12/22/12 6:14 PM, Jan Beich wrote:
> Ed Maste <emaste at freebsd.org> writes:
>
>> When this knob is set standalone debug files for shared objects are
>> built and installed in /usr/lib/debug/<so pathname>.debug. GDB
>> searches this path for debug data.
> [...]
> What about ports? They are not allowed to install outside of PREFIX.
>
> $ cd multimedia/cuse4bsd-kmod
> $ make install PREFIX=/tmp/aaa PKG_DBDIR=/tmp/pkg WITH_DEBUG=
> [...]
> install -C -o root -g wheel -m 444 libcuse4bsd.a /tmp/aaa/lib
> install -s -o root -g wheel -m 444 libcuse4bsd.so.1 /tmp/aaa/lib
> install -o root -g wheel -m 444 libcuse4bsd.so.1.debug /usr/lib/debug/tmp/aaa/lib
> install: /usr/lib/debug/tmp/aaa/lib: No such file or directory
> *** [_libinstall] Error code 71
I have a patch for this. I am building world to see what happens, if
you want to try it, or comment on it, please let me know.
Changes are:
base DEBUGDIR on LIBDIR for ports
create intermediate directories for debug objs.
-Alfred
-------------- next part --------------
diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist
index 336d055..7b428d5 100644
--- a/etc/mtree/BSD.usr.dist
+++ b/etc/mtree/BSD.usr.dist
@@ -18,6 +18,22 @@
aout
..
..
+ debug
+ boot
+ ..
+ lib
+ geom
+ ..
+ ..
+ usr
+ lib
+ engines
+ ..
+ ..
+ lib32
+ ..
+ ..
+ ..
dtrace
..
engines
diff --git a/gnu/usr.bin/gdb/arch/amd64/config.h b/gnu/usr.bin/gdb/arch/amd64/config.h
index ac81c54..ae3e104 100644
--- a/gnu/usr.bin/gdb/arch/amd64/config.h
+++ b/gnu/usr.bin/gdb/arch/amd64/config.h
@@ -440,7 +440,7 @@
#define PACKAGE "gdb"
/* Global directory for separate debug files. */
-#define DEBUGDIR "/usr/local/lib/debug"
+#define DEBUGDIR "/usr/lib/debug"
/* Define to BFD's default architecture. */
#define DEFAULT_BFD_ARCH bfd_i386_arch
diff --git a/gnu/usr.bin/gdb/arch/arm/config.h b/gnu/usr.bin/gdb/arch/arm/config.h
index e1b128c..26b1891 100644
--- a/gnu/usr.bin/gdb/arch/arm/config.h
+++ b/gnu/usr.bin/gdb/arch/arm/config.h
@@ -452,7 +452,7 @@
#define PACKAGE "gdb"
/* Global directory for separate debug files. */
-#define DEBUGDIR "/usr/local/lib/debug"
+#define DEBUGDIR "/usr/lib/debug"
/* Define to BFD's default architecture. */
#define DEFAULT_BFD_ARCH bfd_arm_arch
diff --git a/gnu/usr.bin/gdb/arch/i386/config.h b/gnu/usr.bin/gdb/arch/i386/config.h
index f21da4c..30e75c3 100644
--- a/gnu/usr.bin/gdb/arch/i386/config.h
+++ b/gnu/usr.bin/gdb/arch/i386/config.h
@@ -440,7 +440,7 @@
#define PACKAGE "gdb"
/* Global directory for separate debug files. */
-#define DEBUGDIR "/usr/local/lib/debug"
+#define DEBUGDIR "/usr/lib/debug"
/* Define to BFD's default architecture. */
#define DEFAULT_BFD_ARCH bfd_i386_arch
diff --git a/gnu/usr.bin/gdb/arch/ia64/config.h b/gnu/usr.bin/gdb/arch/ia64/config.h
index 5faa96b..f8c84ab 100644
--- a/gnu/usr.bin/gdb/arch/ia64/config.h
+++ b/gnu/usr.bin/gdb/arch/ia64/config.h
@@ -440,7 +440,7 @@
#define PACKAGE "gdb"
/* Global directory for separate debug files. */
-#define DEBUGDIR "/usr/local/lib/debug"
+#define DEBUGDIR "/usr/lib/debug"
/* Define to BFD's default architecture. */
#define DEFAULT_BFD_ARCH bfd_ia64_arch
diff --git a/gnu/usr.bin/gdb/arch/mips/config.h b/gnu/usr.bin/gdb/arch/mips/config.h
index 41a6731..01a7869 100644
--- a/gnu/usr.bin/gdb/arch/mips/config.h
+++ b/gnu/usr.bin/gdb/arch/mips/config.h
@@ -440,7 +440,7 @@
#define PACKAGE "gdb"
/* Global directory for separate debug files. */
-#define DEBUGDIR "/usr/local/lib/debug"
+#define DEBUGDIR "/usr/lib/debug"
/* Define to BFD's default architecture. */
#define DEFAULT_BFD_ARCH bfd_mips_arch
diff --git a/gnu/usr.bin/gdb/arch/powerpc/config.h b/gnu/usr.bin/gdb/arch/powerpc/config.h
index f169fad..49472e7 100644
--- a/gnu/usr.bin/gdb/arch/powerpc/config.h
+++ b/gnu/usr.bin/gdb/arch/powerpc/config.h
@@ -440,7 +440,7 @@
#define PACKAGE "gdb"
/* Global directory for separate debug files. */
-#define DEBUGDIR "/usr/local/lib/debug"
+#define DEBUGDIR "/usr/lib/debug"
/* Define to BFD's default architecture. */
#define DEFAULT_BFD_ARCH bfd_rs6000_arch
diff --git a/gnu/usr.bin/gdb/arch/powerpc64/config.h b/gnu/usr.bin/gdb/arch/powerpc64/config.h
index d8b9b6d..c904d1d 100644
--- a/gnu/usr.bin/gdb/arch/powerpc64/config.h
+++ b/gnu/usr.bin/gdb/arch/powerpc64/config.h
@@ -440,7 +440,7 @@
#define PACKAGE "gdb"
/* Global directory for separate debug files. */
-#define DEBUGDIR "/usr/local/lib/debug"
+#define DEBUGDIR "/usr/lib/debug"
/* Define to BFD's default architecture. */
#define DEFAULT_BFD_ARCH bfd_rs6000_arch
diff --git a/gnu/usr.bin/gdb/arch/sparc64/config.h b/gnu/usr.bin/gdb/arch/sparc64/config.h
index 5527a79..ff87c28 100644
--- a/gnu/usr.bin/gdb/arch/sparc64/config.h
+++ b/gnu/usr.bin/gdb/arch/sparc64/config.h
@@ -440,7 +440,7 @@
#define PACKAGE "gdb"
/* Global directory for separate debug files. */
-#define DEBUGDIR "/usr/local/lib/debug"
+#define DEBUGDIR "/usr/lib/debug"
/* Define to BFD's default architecture. */
#define DEFAULT_BFD_ARCH bfd_sparc_arch
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index aa3567b..c42b6ed 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -43,6 +43,10 @@ CTFFLAGS+= -g
STRIP?= -s
.endif
+.if defined(MK_DEBUG_FILES) && empty(${DEBUG_FLAGS:M-g})
+CFLAGS+= -g
+.endif
+
.include <bsd.libnames.mk>
# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
@@ -173,8 +177,8 @@ SOLINKOPTS+= -Wl,--fatal-warnings -Wl,--warn-shared-textrel
.if target(beforelinking)
${SHLIB_NAME}: beforelinking
.endif
-.if defined(DEBUG_FLAGS)
-${SHLIB_NAME}.debug: ${SOBJS}
+.if defined(MK_DEBUG_FILES)
+${SHLIB_NAME}.full: ${SOBJS}
.else
${SHLIB_NAME}: ${SOBJS}
.endif
@@ -196,13 +200,13 @@ ${SHLIB_NAME}: ${SOBJS}
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
.endif
-.if defined(DEBUG_FLAGS)
-${SHLIB_NAME}: ${SHLIB_NAME}.debug ${SHLIB_NAME}.symbols
- ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.symbols \
- ${SHLIB_NAME}.debug ${.TARGET}
+.if defined(MK_DEBUG_FILES)
+${SHLIB_NAME}: ${SHLIB_NAME}.full ${SHLIB_NAME}.debug
+ ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.debug \
+ ${SHLIB_NAME}.full ${.TARGET}
-${SHLIB_NAME}.symbols: ${SHLIB_NAME}.debug
- ${OBJCOPY} --only-keep-debug ${SHLIB_NAME}.debug ${.TARGET}
+${SHLIB_NAME}.debug: ${SHLIB_NAME}.full
+ ${OBJCOPY} --only-keep-debug ${SHLIB_NAME}.full ${.TARGET}
.endif
.endif
@@ -280,10 +284,13 @@ _libinstall:
${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
-.if defined(DEBUG_FLAGS)
+.if defined(MK_DEBUG_FILES)
+ ${INSTALL} -d -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} \
+ ${DESTDIR}${DEBUGDIR}${SHLIBDIR}
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} \
- ${SHLIB_NAME}.symbols ${DESTDIR}${SHLIBDIR}
+ ${SHLIB_NAME}.debug ${DESTDIR}${DEBUGDIR}${SHLIBDIR}
.endif
.if defined(SHLIB_LINK)
# ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building
diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk
index 78af8fb..1b3c37e 100644
--- a/share/mk/bsd.own.mk
+++ b/share/mk/bsd.own.mk
@@ -43,6 +43,9 @@
# LIBMODE Library mode. [${NOBINMODE}]
#
#
+# DEBUGDIR Base path for standalone debug files. [/usr/lib/debug]
+#
+#
# KMODDIR Base path for loadable kernel modules
# (see kld(4)). [/boot/kernel]
#
@@ -147,6 +150,8 @@ LIBOWN?= ${BINOWN}
LIBGRP?= ${BINGRP}
LIBMODE?= ${NOBINMODE}
+DEBUGDIR?= ${LIBDIR}/debug
+
# Share files
SHAREDIR?= /usr/share
@@ -427,6 +432,7 @@ __DEFAULT_NO_OPTIONS = \
BSD_GREP \
CLANG_EXTRAS \
CTF \
+ DEBUG_FILES \
HESIOD \
ICONV \
IDEA \
More information about the freebsd-hackers
mailing list