support DWARF2 debugging on Mac OS X, needed for debugging on 10.5. Patch by Stan Shebs. b=363590 r=bsmedberg
authorjoshmoz@gmail.com
Fri, 29 Jun 2007 22:20:00 -0700
changeset 2963 f47e4090747a5b3ce5b2dc15d22e13c0d9caa1a7
parent 2962 e9b7ba84728e6373f0b77875f4baf3314364256d
child 2964 d7088c1fdd68202d71fbfa26a97a2b9fbcb9c0fe
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs363590
milestone1.9a6pre
support DWARF2 debugging on Mac OS X, needed for debugging on 10.5. Patch by Stan Shebs. b=363590 r=bsmedberg
config/rules.mk
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1092,16 +1092,21 @@ endif # OS/2
 	rm -f $@
 	$(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
 	$(HOST_RANLIB) $@
 
 ifdef NO_LD_ARCHIVE_FLAGS
 SUB_SHLOBJS = $(SUB_LOBJS)
 endif
 
+# On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
+# so instead of deleting .o files after repacking them into a dylib, we make
+# symlinks back to the originals. The symlinks are a no-op for stabs debugging,
+# so no need to conditionalize on OS version or debugging format.
+
 $(SHARED_LIBRARY): $(OBJS) $(LOBJS) $(DEF_FILE) $(RESFILE) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) $(DSO_LDOPTS_DEPS) Makefile Makefile.in
 ifndef INCREMENTAL_LINKER
 	rm -f $@
 endif
 ifneq ($(MOZ_OS2_TOOLS),VACPP)
 ifeq ($(OS_ARCH),OpenVMS)
 	@if test ! -f $(VMS_SYMVEC_FILE); then \
 	  if test -f $(VMS_SYMVEC_FILE_MODULE); then \
@@ -1128,17 +1133,32 @@ ifdef MSMANIFEST_TOOL
 ifdef EMBED_MANIFEST_AT
 	@if test -f $@.manifest; then \
 		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
 		rm -f $@.manifest; \
 	fi
 endif   # embed manifest
 endif	# MSVC with manifest tool
 endif	# WINNT && !GCC
-	@rm -f foodummyfilefoo $(SUB_SHLOBJS) $(DELETE_AFTER_LINK)
+ifeq ($(OS_ARCH),Darwin)
+	@for lib in $(SHARED_LIBRARY_LIBS); do \
+		libdir=`echo $$lib|sed -e 's,/[^/]*\.a,,'`; \
+		ofiles=`$(AR_LIST) $${lib}`; \
+		for ofile in $$ofiles; do \
+			if [ -f $$libdir/$$ofile ]; then \
+				rm -f $$ofile; \
+				ln -s $$libdir/$$ofile $$ofile; \
+			fi; \
+		done; \
+	done
+	@touch $(SHARED_LIBRARY)
+else # non-Darwin
+	@rm -f $(SUB_SHLOBJS)
+endif # Darwin
+	@rm -f foodummyfilefoo $(DELETE_AFTER_LINK)
 else # os2 vacpp
 	$(MKSHLIB) -O:$@ -DLL -INC:_dllentry $(LDFLAGS) $(OBJS) $(LOBJS) $(EXTRA_DSO_LDOPTS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE)
 endif # !os2 vacpp
 	chmod +x $@
 ifndef NO_COMPONENT_LINK_MAP
 ifndef MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS
 ifndef MOZ_DEBUG
 ifeq ($(OS_ARCH)_$(IS_COMPONENT),Darwin_1)