Closed Bug 1464522 Opened 6 years ago Closed 6 years ago

Track number of static constructors on Windows, OSX and Android builds

Categories

(Firefox Build System :: General, enhancement)

3 Branch
enhancement
Not set
normal

Tracking

(firefox62 fixed)

RESOLVED FIXED
mozilla62
Tracking Status
firefox62 --- fixed

People

(Reporter: glandium, Assigned: glandium)

References

Details

(Keywords: in-triage)

Attachments

(1 file)

We're currently tracking the number of static constructors on Linux builds, but it turns out that MSVC has a wildly different behavior wrt static initializers, and we should track that too. Which turns out to be relatively straightforward:

$ grep -c '^FUNC.*`dynamic initializer for ' xul.pdb/B9F407BEBA0B470E8C3900E8228AF26D1/xul.sym 
1258

In fact, we could also use the same technique on Linux too (grepping the symbols file, the keyword is just different), instead of looking at the output of objdump or readelf. That might even also work for OSX builds.
So, for some reason, OSX builds have the same symbols as Linux for static initializers, but they don't appear in the breakpad symbols file. "<name omitted>" appears instead, but there are 20k symbols that end up that way, instead of the 96 static initializers I can find with nm.

toolkit/crashreporter/google-breakpad/src/common/dwarf_cu_to_module.cc puts the "<name omitted>" string when the dwarf info doesn't have a function name. Now the question is why does those functions have no name in the dwarf info, when they clearly have an associated symbol in the symbol table.
Filed bug 1464537.
Depends on: 1464537
Keywords: in-triage
Assignee: nobody → mh+mozilla
Summary: Track number of static constructors on Windows builds → Track number of static constructors on Windows, OSX and Android builds
Awesome. I've had to track down static initializers a few times and this method should make it much easier to get the list of initializers.
Comment on attachment 8981281 [details]
Bug 1464522 - Count static initializers from the crash reporter symbol files.

https://reviewboard.mozilla.org/r/247384/#review253592

Yay.

::: python/mozbuild/mozbuild/action/dumpsymbols.py:63
(Diff revision 1)
> +    if count_ctors:
> +        args.append('--count-ctors')
>      print('Running: %s' % ' '.join(args))
>      out_files = subprocess.check_output(args)

So we are running a Python action to run another Python process?  Oof.

::: taskcluster/ci/build/linux.yml
(Diff revision 1)
>          using: mozharness
>          actions: [get-secrets build check-test update]
>          config:
>              - builds/releng_base_firefox.py
>              - builds/releng_base_linux_64_builds.py
> -            - builds/releng_sub_linux_configs/enable_count_ctors.py

\o/

::: toolkit/crashreporter/tools/symbolstore.py:589
(Diff revision 1)
> +                            if '_GLOBAL__sub_' in line:
> +                                ctors += 1
> +                            elif "`dynamic initializer for '" in line:

Perhaps comment here that the first style is Unix-ish, and the second one is Windows?

::: toolkit/library/Makefile.in:15
(Diff revision 1)
>  
>  .PHONY: gtestxul
>  gtestxul:
>  	$(MAKE) -C $(DEPTH) toolkit/library/gtest/target LINK_GTEST_DURING_COMPILE=1
> +
> +DUMP_SYMBOLS_FLAGS = --count-ctors

WDYT about making this `ifdef MOZ_AUTOMATION`, since only automation cares about static constructors?  Or do we think that exposing this to users will make it easier for them to count static constructors locally without pushing to try?
Attachment #8981281 - Flags: review+
Comment on attachment 8981281 [details]
Bug 1464522 - Count static initializers from the crash reporter symbol files.

r=me
Attachment #8981281 - Flags: review?(core-build-config-reviews) → review+
(In reply to Nathan Froyd [:froydnj] from comment #5)
> WDYT about making this `ifdef MOZ_AUTOMATION`, since only automation cares
> about static constructors?  Or do we think that exposing this to users will
> make it easier for them to count static constructors locally without pushing
> to try?

The part that runs the command is in a ifdef MOZ_AUTOMATION block.
Attachment #8981281 - Flags: review+
Pushed by mh@glandium.org:
https://hg.mozilla.org/integration/autoland/rev/19a088d99507
Count static initializers from the crash reporter symbol files. r=froydnj
https://hg.mozilla.org/mozilla-central/rev/19a088d99507
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
Depends on: 1465659
Blocks: 1465690
Keywords: in-triage
Version: Version 3 → 3 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: