Uploaded image for project: 'Qbs ("Cubes")'
  1. Qbs ("Cubes")
  2. QBS-1862

gcc: Use -gsplit-dwarf option to generate separate debug information

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • 3.2.0
    • Toolchains: GCC
    • None
    • Android, Linux/Other display system

      Seems, since GCC 4.7 we can use this `-gsplit-dwarf` option to generate a separate debug information in a form of *.dwo files, see e.g. https://gcc.gnu.org/wiki/DebugFission

      Right now we do it trough an `objcopy`:

      function separateDebugInfoCommands(product, outputs, primaryOutput) {
          var commands = [];
      
          var debugInfo = outputs.debuginfo_app || outputs.debuginfo_dll
                  || outputs.debuginfo_loadablemodule;
      
          if (debugInfo && !product.qbs.toolchain.includes("emscripten")) {
              var objcopy = product.cpp.objcopyPath;
      
              var cmd = new Command(objcopy, ["--only-keep-debug", primaryOutput.filePath,
                                          debugInfo[0].filePath]);
              cmd.silent = true;
              commands.push(cmd);
      
              cmd = new Command(objcopy, ["--strip-debug", primaryOutput.filePath]);
              cmd.silent = true;
              commands.push(cmd);
      
              cmd = new Command(objcopy, ["--add-gnu-debuglink=" + debugInfo[0].filePath,
                                          primaryOutput.filePath]);
              cmd.silent = true;
              commands.push(cmd);
          }
      
          return commands;
      }
      

      So, at least, we can keep this approach only for a GCC with the version less than 4.7... But for all other GCC we can use `-gsplit-dwarf`, AFAIK.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            kandeler Christian Kandeler
            kuzulis Denis Shienkov
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes