Add support for PDB debug symbol packages.

Partially based on patch by Tom Ritter.
This commit is contained in:
Jacek Caban 2020-11-26 21:05:02 +01:00
parent 93bb726bbc
commit 439c36fb0e
6 changed files with 87 additions and 45 deletions

View File

@ -159,6 +159,9 @@ endif # FORCE_SHARED_LIB
endif # LIBRARY
ifeq ($(OS_ARCH),WINNT)
LINK_PDBFILE ?= $(basename $(@F)).pdb
ifndef GNU_CC
#
@ -180,7 +183,6 @@ endif
COMPILE_CFLAGS += $(COMPILE_PDB_FLAG)
COMPILE_CXXFLAGS += $(COMPILE_PDB_FLAG)
LINK_PDBFILE ?= $(basename $(@F)).pdb
ifdef MOZ_DEBUG
CODFILE=$(basename $(@F)).cod
endif
@ -207,6 +209,11 @@ MOZ_PROGRAM_LDFLAGS += -Wl,-rpath -Wl,@executable_path/Frameworks
endif
endif
ifeq ($(MOZ_PDB),1)
MOZ_PROGRAM_LDFLAGS += -Wl,-pdb,$(dir $@)/$(LINK_PDBFILE)
MKSHLIB += -Wl,-pdb,$(dir $@)/$(LINK_PDBFILE)
endif
ifeq ($(SOLARIS_SUNPRO_CXX),1)
ifeq (86,$(findstring 86,$(OS_TEST)))
OS_LDFLAGS += -M $(MOZILLA_DIR)/config/solaris_ia32.map

View File

@ -1104,6 +1104,15 @@ if test -n "$MOZ_TSAN"; then
fi
AC_SUBST(MOZ_TSAN)
dnl ========================================================
dnl pdb
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(pdb,
[ --enable-pdb Use PDB for debug symbols.],
MOZ_PDB=1,
MOZ_PDB= )
AC_SUBST(MOZ_PDB)
# The LLVM symbolizer is used by all sanitizers
AC_SUBST(LLVM_SYMBOLIZER)
@ -1526,6 +1535,11 @@ ia64*-hpux*)
CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
fi
if test -n "$MOZ_PDB"; then
CFLAGS="$CFLAGS -g -gcodeview"
CXXFLAGS="$CXXFLAGS -g -gcodeview"
fi
WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
WIN32_GUI_EXE_LDFLAGS=-mwindows

View File

@ -1611,6 +1611,14 @@ if test -n "$MOZ_JPROF"; then
AC_DEFINE(MOZ_JPROF)
fi
dnl ========================================================
dnl pdb
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(pdb,
[ --enable-pdb Use PDB for debug symbols.],
MOZ_PDB=1,
MOZ_PDB= )
dnl ========================================================
dnl SPS Profiler
dnl ========================================================
@ -2070,6 +2078,11 @@ ia64*-hpux*)
LDFLAGS="$LDFLAGS -Wl,-Xlink=-filealign:0x1000"
fi
if test -n "$MOZ_PDB"; then
CFLAGS="$CFLAGS -g -gcodeview"
CXXFLAGS="$CXXFLAGS -g -gcodeview"
fi
# We use mix of both POSIX and Win32 printf format across the tree, so format
# warnings are useless on mingw.
MOZ_C_SUPPORTS_WARNING(-Wno-, format, ac_c_has_wno_format)
@ -8450,6 +8463,7 @@ AC_SUBST(MOZ_FEEDS)
AC_SUBST(NS_PRINTING)
AC_SUBST(MOZ_HELP_VIEWER)
AC_SUBST(TOOLCHAIN_PREFIX)
AC_SUBST(MOZ_PDB)
AC_SUBST(JAVA)
AC_SUBST(JAVAC)

View File

@ -58,7 +58,9 @@ else
get_first_and_last = $(TOOLCHAIN_PREFIX)nm -g $1 | grep _NSModule$$ | grep -vw refptr | sort | sed -n 's/^.* _*\([^ ]*\)$$/\1/;1p;$$p'
endif
ifeq ($(MOZ_PDB),)
LOCAL_CHECKS = test "$$($(get_first_and_last) | xargs echo)" != "start_kPStaticModules_NSModule end_kPStaticModules_NSModule" && echo "NSModules are not ordered appropriately" && exit 1 || exit 0
endif
ifeq (Linux,$(OS_ARCH))
LOCAL_CHECKS += ; test "$$($(TOOLCHAIN_PREFIX)readelf -l $1 | awk '$1 == "LOAD" { t += 1 } END { print t }')" -le 1 && echo "Only one PT_LOAD segment" && exit 1 || exit 0

View File

@ -23,6 +23,7 @@ from mozpack.copier import (
Jarrer,
)
from mozpack.errors import errors
from mozpack.files import ExecutableFile
from mozpack.unify import UnifiedBuildFinder
import mozpack.path as mozpath
import buildconfig

View File

@ -4,7 +4,7 @@ set -e
case x"$1" in
x-h|x--help|xhelp)
echo "Usage: wine/make_package [-dbg] [-win32] [-win64] [--no-build] [--force-build] [--package-only] [--msi-package] [--tar-package] [--no-package] [--disable-strip] [--unstripped]"
echo "Usage: wine/make_package [-dbg] [-win32] [-win64] [-pdb] [--no-build] [--force-build] [--package-only] [--msi-package] [--tar-package] [--no-package] [--disable-strip] [--unstripped]"
exit 0
;;
esac
@ -21,6 +21,7 @@ target_arch=x86
pkg_type=msi
do_strip=yes
no_xulinstaller=no
pdb=no
while [ "$1" != "" ]
do
@ -40,6 +41,10 @@ do
target_abi=win64
target_arch=x86_64
;;
-pdb)
do_strip=no
pdb=yes
;;
--no-build)
no_build=yes
;;
@ -129,6 +134,11 @@ then
echo "ac_add_options --disable-optimize" >>$config_file
fi
if [ "$pdb" = "yes" ]
then
echo "ac_add_options --enable-pdb" >>$config_file
fi
if [ "$do_strip" = "no" ]
then
echo "ac_add_options --disable-install-strip" >>$config_file
@ -332,52 +342,46 @@ tar|all)
echo Package done:
echo $(pwd)/$package_basename.tar.xz
if [ "$debug" = "-dbg" ] && [ "$OS" = "Windows_NT" ]
if [ "$pdb" != "no" ]
then
echo "make_package: Creating .tar.xz PDB package..."
pdb_list="$(mktemp)"
echo "make_package: Creating PDB archive"
# We need to recreate the same file system structure under C:\ for the pdb's to work:
# $build_dir has relative paths, we need an exact path:
cd $build_dir
build_path="$(pwd)"
build_sub_path=${build_path/\/c/${build_path}\/dist\/drive_c\/}
rm -rf $build_path/dist/drive_c/
mkdir -p $build_sub_path
for x in `find $build_path/dist/$wine_gecko_dir/ -iname \*.dll` ; do y=`basename $x .dll` ; find . -iname $y.pdb >> ${pdb_list} ; done
for x in `find $build_path/dist/$wine_gecko_dir/ -iname \*.exe` ; do y=`basename $x .exe` ; find . -iname $y.pdb >> ${pdb_list} ; done
tar -cf - `cat $pdb_list` | tar xf - -C $build_sub_path
tar -cJf $build_path/dist/${package_basename}-pdb.tar.xz -C $build_path/dist/drive_c/ $dist_basename
rm -rf $pdb_list $build_path/dist/drive_c
echo PDB package done:
echo $build_path/dist/${package_basename}-pdb.tar.xz
fi
;;
esac
case $pkg_type in
unstripped|all)
echo "make_package: Creating unstripped archive..."
cd "$build_dir/dist"
cp -r $wine_gecko_dir $wine_gecko_dir-unstripped
# This is hackish, but this allows us to prepare both stripped
# and unstripped packages from the same build.
if [ "$do_strip" = "yes" ]
then
cd $wine_gecko_dir-unstripped
for f in *.dll; do
cp ../bin/$f $f
done
# FIXME: ideally we'd get that from build system
cd ..
for x in `find dist/$wine_gecko_dir/ -name \*.dll` ; do y=`basename $x .dll` ; find $(ls |grep -v dist) -name $y.pdb -exec cp {} dist/$wine_gecko_dir/ \; ; done
for x in `find dist/$wine_gecko_dir/ -name \*.exe` ; do y=`basename $x .exe` ; find $(ls |grep -v dist) -name $y.pdb -exec cp {} dist/$wine_gecko_dir/ \; ; done
cd dist
tar -cJf $package_basename-pdb.tar.xz $wine_gecko_dir
echo PDB package done:
echo $(pwd)/$package_basename-pdb.tar.xz
fi
tar -cJf $package_basename-unstripped.tar.xz $wine_gecko_dir-unstripped
echo Package done:
echo $(pwd)/$package_basename-unstripped.tar.xz
;;
esac
if [ "$pdb" = "no" ]
then
case $pkg_type in
unstripped|all)
echo "make_package: Creating unstripped archive..."
cd "$build_dir/dist"
cp -r $wine_gecko_dir $wine_gecko_dir-unstripped
# This is hackish, but this allows us to prepare both stripped
# and unstripped packages from the same build.
if [ "$do_strip" = "yes" ]
then
cd $wine_gecko_dir-unstripped
for f in *.dll; do
cp ../bin/$f $f
done
cd ..
fi
tar -cJf $package_basename-unstripped.tar.xz $wine_gecko_dir-unstripped
echo Package done:
echo $(pwd)/$package_basename-unstripped.tar.xz
;;
esac
fi