How to enable debug info for clang

1,097 views
Skip to first unread message

Ashik Salim

unread,
Jan 23, 2018, 6:22:38 AM1/23/18
to discuss-webrtc
Hi,

I'm building webrtc on windows which as I understand, uses clang by default now. Compilation is successful and I get an output webrtc.lib file, but no pdb files are generated. Is there some specific flag I have to set to enable pdb generation?

Thanks,
Ashik

Alexandre GOUAILLARD

unread,
Jan 23, 2018, 9:19:37 PM1/23/18
to discuss...@googlegroups.com
AFAIK, the "official" build system is still MSVC 2017 for webrtc on windows (see below). Clang is planed to become the default on windows for future revision but not in place except for some experimental builds.

Note that you still need MSVC installed. Note you need to pass "is_clang=true" to the "gn gen" command.
More info here:

illustration of results there:

chromium windows clang 64 bits release build bots:

Official documentation (webrtc.org):


Windows

Follow the Chromium’s build instructions for Windows.

WebRTC requires Visual Studio 2017 to be used.


https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#setting-up-windows

Setting up Windows

Visual Studio

As of September, 2017 (R503915) Chromium requires Visual Studio 2017 update 3.2 with the 15063 (Creators Update) Windows SDK or later to build. Visual Studio Community Edition should work if its license is appropriate for you. You must install the “Desktop development with C++” component and the “MFC and ATL support” sub-component. This can be done from the command line by passing these arguments to the Visual Studio installer that you download:

--add Microsoft.VisualStudio.Workload.NativeDesktop
    --add Microsoft.VisualStudio.Component.VC.ATLMFC --includeRecommended

You must have the Windows 10 SDK installed, version 10.0.15063 or later. The 10.0.15063 SDK initially had errors but the 10.0.15063.468 version works well. Most of this will be installed by Visual Studio.


--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/c59d5ede-46c4-4cbb-9d69-e013c720cbf0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alex. Gouaillard, PhD, PhD, MBA
------------------------------------------------------------------------------------
President - CoSMo Software Consulting, Singapore
------------------------------------------------------------------------------------

Ashik Salim

unread,
Jan 23, 2018, 10:13:21 PM1/23/18
to discuss-webrtc
master branch of webrtc has switched to clang a few months ago following along the footsteps of chromium: https://groups.google.com/a/chromium.org/forum/#!msg/chromium-dev/Y3OEIKkdlu0/TCcT1SvwAwAJ. Maybe the publicly released ones uses MSVC? Anyway it still needs VS 2017 installed, which I have. My only issue is in getting the pdb files.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.

Alexandre GOUAILLARD

unread,
Jan 24, 2018, 1:30:04 AM1/24/18
to discuss...@googlegroups.com
chrome has, and webrtc support it, but the webrtc standalone is still officially not supporting it (i.e. they will usually not answer questions about it, as written on the official webpage).

if you want clang to generate microsoft-proprietary pdf file for debug, you need to pass the /Z, /Zi flags to the compiler. Unfortunately, clang support for pdb is not complete, and even though the compiler itself is pretty close to completion, the support for PDB by the linker is far from complete. It is actually mentionned in the e-mail by nico weber in the link you provided.

More information about PDB support status can be found in clang documentation, under the "ABI features" section, and most specifically the "Debug info" subsection:

More information on how chrome/webrtc uses those flags can be found in the following files:
build/config/win/BUILD.gn
""
# Building with Clang on Windows is a work in progress and very
# experimental. See crbug.com/82385.
""

and

build/config/compiler/BUILD.gn
""

# Symbols ----------------------------------------------------------------------


# The BUILDCONFIG file sets the "default_symbols" config on targets by

# default. It will be equivalent to one the three specific symbol levels.

#

# You can override the symbol level on a per-target basis by removing the

# default config and then adding the named one you want:

#

#   configs -= [ "//build/config/compiler:default_symbols" ]

#   configs += [ "//build/config/compiler:symbols" ]


# Full symbols.

config("symbols") {

  if (is_win) {

    if (use_goma) {

      # Note that this requires is_win_fastlink, enforced elsewhere.

      cflags = [ "/Z7" ]  # Debug information in the .obj files.

    } else {

      cflags = [ "/Zi" ]  # Produce PDB file, no edit and continue.

    }


    if (is_win_fastlink) {

      # Tell VS 2015+ to create a PDB that references debug

      # information in .obj and .lib files instead of copying

      # it all. This flag is incompatible with /PROFILE

      ldflags = [ "/DEBUG:FASTLINK" ]

    } else {

      ldflags = [ "/DEBUG" ]

    }


    if (is_clang) {

      # /DEBUG:FASTLINK requires every object file to have standalone debug

      # information.

      if (is_win_fastlink) {

        cflags += [ "-fstandalone-debug" ]

      } else {

        cflags += [ "-fno-standalone-debug" ]

      }

    }

""

Hope this helps.

happy hacking.

Dr. Alex.

To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/762062f3-34f7-4388-a487-05a338a7f2ab%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ashik Salim

unread,
Jan 24, 2018, 1:51:22 AM1/24/18
to discuss-webrtc
Oh damn. I was hoping clang is official since the upstream enables clang by default now. In the crbug you mentioned the commit which enables clang by default is mentioned: https://bugs.chromium.org/p/chromium/issues/detail?id=82385#c831. That commit comes after the announcement by LLVM sometime in August that they support pdb now: http://blog.llvm.org/2017/08/llvm-on-windows-now-supports-pdb-debug.html.

Anyway I see that the official page has no info about clang, so I guess I'll have to wait :/

Alexandre GOUAILLARD

unread,
Jan 24, 2018, 2:15:31 AM1/24/18
to discuss...@googlegroups.com
"We’ve tested simple debugging scenarios with our PDBs, but we still consider this alpha in terms of debug info quality"

that seems aligned with what chrome team writes about it, and surely explained why it's not turned on. They mentionned it makes soma more stable, and I believe break pad, crashpad, and all the post-mortem crash debugging chrome infrastructure depends on it though, so you can expect it to be available relatively soon after it becomes stable.


To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/28049f4f-d281-4d26-b758-cd16a61ef1c4%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages