I’ve linked a prebuilt object that defines `__cyg_profile_func_enter` and 
`__cyg_profile_func_exit` using LDFLAGS, and that got rid of the initial linker 
errors. Huzzah!

However, now I’m facing other more concerning linker errors: 
https://gist.github.com/victorporof/55490f49c7b13b4bcfae10ca4f0c169c

Here’s what I did:

1. Built this simple trace.cpp: 
https://gist.github.com/victorporof/e9809e33c4dc67ef388672791c4c80cd
- Used `clang++ trace.cpp -mmacosx-version-min=10.9 -c -o trace.o`
- I’m building this without `-finstrument-functions`, obviously.

2. Added the following to my mozconfig:
CFLAGS="-finstrument-functions"
CXXFLAGS="-finstrument-functions"
LDFLAGS="-L[path/to/object] -ltrace.o”

3. `./mach build`
Linker errors galore!

Anything I’m doing wrong?
Victor

> On 10. Nov 2018, at 15:50, David Major <dma...@mozilla.com> wrote:
> 
> I think you'll have a tough time trying to build any binaries that are
> by nature incomplete without an LD_PRELOAD. You'll have better luck if
> you either properly link your __cyg_profile implementations during the
> build, or link against stubs that you then override with LD_PRELOAD.
> 
> Our Windows PGO builds currently use the -finstrument... family in
> order to log function call order. You could probably adapt this by
> removing the WINNT and MOZ_PGO conditions from
> https://searchfox.org/mozilla-central/rev/a3894a4dcfb5d42f2e6eee6cb9faf7141879ef1a/python/mozbuild/mozbuild/frontend/emitter.py#1120
> and 
> https://searchfox.org/mozilla-central/rev/a3894a4dcfb5d42f2e6eee6cb9faf7141879ef1a/mozglue/build/moz.build#41
> .
> 
> The limitation of that implementation is that its only instruments
> libxul. This was our way of getting the most bang per buck and
> sidestepping having to deal with all the miscellaneous binaries with
> idiosyncratic build requirements.
> 
> Also, if you wait a couple days, I'm sure someone who actually knows
> what they're doing will chime in with a better solution than mine. :)
> 
> On Sat, Nov 10, 2018 at 8:57 AM Victor Porof <vpo...@mozilla.com> wrote:
>> 
>> Hey folks,
>> 
>> I’m trying to build Firefox Desktop with `-finstrument-functions`. End goal 
>> is doing some exploratory tracing as part of upcoming browser-architecture 
>> efforts.
>> 
>> What’s the appropriate way of doing this?
>> 
>> I tried doing the most naive thing of just passing that flag through CFLAGS 
>> and CXXFLAGS with the intention of later linking something like 
>> liblttng-ust-cyg-profile via LD_PRELOAD that defines 
>> `__cyg_profile_func_enter` and `__cyg_profile_func_exit`. However, `mach 
>> build` then results in 
>> https://gist.github.com/victorporof/ef17b57b19aa9fdb5a9a3a30eecde2ea (of 
>> course).
>> 
>> Any hints?
>> Victor
>> 
>> _______________________________________________
>> dev-builds mailing list
>> dev-builds@lists.mozilla.org
>> https://lists.mozilla.org/listinfo/dev-builds

_______________________________________________
dev-builds mailing list
dev-builds@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-builds

Reply via email to