]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
win32*.sh: move debug symbols to separate files 39224/head
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 3 Feb 2021 08:59:24 +0000 (08:59 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 3 Feb 2021 12:07:41 +0000 (12:07 +0000)
This patch simplifies releasing Windows binaries along with debug
symbols.

By default, we're going to provide minimum debug information (-g1).
The symbols are extracted from the binaries and placed in separate
files in the ".debug" folder, which is used by gdb implicitly.

This is more convenient than having separate versions of the binaries,
with or without debug symbols.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
README.windows.rst
mingw_conf.sh
win32_build.sh

index 5f77d9f218a2de572bb86f8067a5b9cb613266b2..48cb5b7c3515ed05a8c7e92b6b6ee1b4319fe02a 100644 (file)
@@ -24,48 +24,47 @@ account different package managers, package names or paths (e.g. mingw paths).
 
 The script accepts the following flags:
 
-=============  ===============================  ===============================
-Flag           Description                      Default value
-=============  ===============================  ===============================
-OS             Host OS distribution, for mingw  ubuntu (also valid: suse)
-               and other OS specific settings.
-CEPH_DIR       The Ceph source code directory.  The same as the script.
-BUILD_DIR      The directory where the          $CEPH_DIR/build
-               generated artifacts will be
-               placed.
-DEPS_DIR       The directory where the Ceph     $CEPH_DIR/build.deps
-               dependencies will be built.
-NUM_WORKERS    The number of workers to use     The number of vcpus
-               when building Ceph.              available
-CLEAN_BUILD    Clean the build directory.
-SKIP_BUILD     Run cmake without actually
-               performing the build.
-SKIP_TESTS     Skip building Ceph tests.
-BUILD_ZIP      Build a zip archive containing
-               the generated binaries.
-ZIP_DEST       Where to put a zip containing    $BUILD_DIR/ceph.zip
-               the generated binaries.
-STRIP_ZIPPED   If set, the zip will contain
-               stripped binaries.
-ENABLE_SHARED  Dynamically link Ceph libs.      False
-=============  ===============================  ===============================
-
-In order to build debug binaries as well as an archive containing stripped
-binaries that may be easily moved around, one may use the following:
+=================  ===============================  ===============================
+Flag               Description                      Default value
+=================  ===============================  ===============================
+OS                 Host OS distribution, for mingw  ubuntu (also valid: suse)
+                   and other OS specific settings.
+CEPH_DIR           The Ceph source code directory.  The same as the script.
+BUILD_DIR          The directory where the          $CEPH_DIR/build
+                   generated artifacts will be
+                   placed.
+DEPS_DIR           The directory where the Ceph     $CEPH_DIR/build.deps
+                   dependencies will be built.
+NUM_WORKERS        The number of workers to use     The number of vcpus
+                   when building Ceph.              available
+CLEAN_BUILD        Clean the build directory.
+SKIP_BUILD         Run cmake without actually
+                   performing the build.
+SKIP_TESTS         Skip building Ceph tests.
+SKIP_ZIP           If unset, we'll build a zip
+                   archive containing the
+                   generated binaries.
+ZIP_DEST           Where to put a zip containing    $BUILD_DIR/ceph.zip
+                   the generated binaries.
+EMBEDDED_DBG_SYM   By default, the generated
+                   archive will contain a .debug
+                   subfolder, having the debug
+                   symbols. If this flag is set,
+                   the debug symbols will remain
+                   embedded in the executables.
+ENABLE_SHARED      Dynamically link Ceph libs.      False
+=================  ===============================  ===============================
+
+The following command will build the binaries and add them to a zip archive
+along with all the required DLLs. By default, the debug symbols are extracted
+from the binaries and placed in the ".debug" folder of the archive.
 
 .. code:: bash
 
-    BUILD_ZIP=1 STRIP_ZIPPED=1 SKIP_TESTS=1 ./win32_build.sh
+    SKIP_TESTS=1 ./win32_build.sh
 
 In order to disable a flag, such as ``CLEAN_BUILD``, leave it undefined.
 
-Debug binaries can be quite large, the following parameters may be passed to
-``win32_build.sh`` to reduce the amount of debug information:
-
-.. code:: bash
-
-    CFLAGS="-g1" CXXFLAGS="-g1" CMAKE_BUILD_TYPE="Release"
-
 ``win32_build.sh`` will fetch dependencies using ``win32_deps_build.sh``. If
 all dependencies are successfully prepared, this potentially time consuming
 step will be skipped by subsequent builds. Be aware that you may have to do
index 4d66a075775780daf7930a96371468494778bb36..3af7de09967fe3b2db550193eb96d66edec759b5 100644 (file)
@@ -16,6 +16,7 @@ MINGW_CPP="${MINGW_BASE}-c++"
 MINGW_DLLTOOL="${MINGW_BASE}-dlltool"
 MINGW_WINDRES="${MINGW_BASE}-windres"
 MINGW_STRIP="${MINGW_BASE}-strip"
+MINGW_OBJCOPY="${MINGW_BASE}-objcopy"
 # -Distribution specific mingw settings-
 case "$OS" in
     ubuntu)
index 99e7c6b7997f20c11d9c52e37fe2f6db296583c4..33248c7f8f048a6cb781cc132f837faf5ccf18b1 100755 (executable)
@@ -22,13 +22,16 @@ SKIP_TESTS=${SKIP_TESTS:-}
 SKIP_BINDIR_CLEAN=${SKIP_BINDIR_CLEAN:-}
 NUM_WORKERS=${NUM_WORKERS:-$num_vcpus}
 DEV_BUILD=${DEV_BUILD:-}
-BUILD_ZIP=${BUILD_ZIP:-}
-# By default, we'll build release binaries with debug symbols attached.
-# If BUILD_ZIP and STRIP_ZIPPED are enabled, we'll strip the binaries
-# that we're going to archive.
+# Unless SKIP_ZIP is set, we're preparing an archive that contains the Ceph
+# binaries, debug symbols as well as the required DLLs.
+SKIP_ZIP=${SKIP_ZIP:-}
+# By default, we'll move the debug symbols to separate files located in the
+# ".debug" directory. If "EMBEDDED_DBG_SYM" is set, the debug symbols will
+# remain embedded in the binaries.
+#
 # Unfortunately we cannot use pdb symbols when cross compiling. cv2pdb
 # well as llvm rely on mspdb*.dll in order to support this proprietary format.
-STRIP_ZIPPED=${STRIP_ZIPPED:-}
+EMBEDDED_DBG_SYM=${EMBEDDED_DBG_SYM:-}
 # Allow for OS specific customizations through the OS flag.
 # Valid options are currently "ubuntu" and "suse".
 
@@ -54,13 +57,23 @@ ALLOCATOR=${ALLOCATOR:-libc}
 # Debug builds don't work with MINGW for the time being, failing with
 # can't close <file>: File too big
 # -Wa,-mbig-obj does not help.
-CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-RelWithDebInfo}
+CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-}
+if [[ -z $CMAKE_BUILD_TYPE ]]; then
+  # By default, we're building release binaries with minimal debug information.
+  export CFLAGS="$CFLAGS -g1"
+  export CXXFLAGS="$CXXFLAGS -g1"
+  CMAKE_BUILD_TYPE=Release
+fi
+
 # Some tests can't use shared libraries yet due to unspecified dependencies.
 # We'll do a static build by default for now.
 ENABLE_SHARED=${ENABLE_SHARED:-OFF}
 
 binDir="$BUILD_DIR/bin"
 strippedBinDir="$BUILD_DIR/bin_stripped"
+# GDB will look for this directory by default.
+dbgDirname=".debug"
+dbgSymbolDir="$strippedBinDir/${dbgDirname}"
 depsSrcDir="$DEPS_DIR/src"
 depsToolsetDir="$DEPS_DIR/mingw"
 
@@ -193,15 +206,24 @@ if [[ -z $SKIP_DLL_COPY ]]; then
     cp ${required_dlls[@]} $binDir
 fi
 
-if [[ -n $BUILD_ZIP ]]; then
+if [[ -z $SKIP_ZIP ]]; then
     # Use a temp directory, in order to create a clean zip file
     ZIP_TMPDIR=$(mktemp -d win_binaries.XXXXX)
-    if [[ -n $STRIP_ZIPPED ]]; then
-        echo "Stripping debug symbols from binaries."
+    if [[ -z $EMBEDDED_DBG_SYM ]]; then
+        echo "Extracting debug symbols from binaries."
         rm -rf $strippedBinDir; mkdir $strippedBinDir
+        rm -rf $dbgSymbolDir; mkdir $dbgSymbolDir
         # Strip files individually, to save time and space
         for file in $binDir/*.exe $binDir/*.dll; do
-            $MINGW_STRIP -o $strippedBinDir/$(basename $file) $file
+            dbgFilename=$(basename $file).debug
+            dbgFile="$dbgSymbolDir/$dbgFilename"
+            strippedFile="$strippedBinDir/$(basename $file)"
+
+            echo "Copying debug symbols: $dbgFile"
+            $MINGW_OBJCOPY --only-keep-debug $file $dbgFile
+            $MINGW_STRIP --strip-debug --strip-unneeded -o $strippedFile $file
+            $MINGW_OBJCOPY --remove-section .gnu_debuglink $strippedFile
+            $MINGW_OBJCOPY --add-gnu-debuglink=$dbgFile $strippedFile
         done
         # Copy any remaining files to the stripped directory
         for file in $binDir/*; do