www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Profiling with LDC

reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
I'm trying to figure out how to do a traditional instrumented profile
with LDC.  All docs that I've managed to find so far say to use
-fprofile-instr-generate, but when I try that, I get a ton of linker
errors complaining of undefined reference to the symbol:

	__llvm_profile_instrument_target

What gives?  I'm guessing I need to specify some additional LLVM
libraries for this?

I'm using the official Debian ldc package, btw.  Is there possibly a
missing dependency on some llvm libraries?


T

-- 
If the comments and the code disagree, it's likely that *both* are wrong. --
Christopher
Apr 25 2018
next sibling parent reply Johan Engelen <j j.nl> writes:
On Wednesday, 25 April 2018 at 17:31:06 UTC, H. S. Teoh wrote:
 I'm trying to figure out how to do a traditional instrumented 
 profile with LDC.  All docs that I've managed to find so far 
 say to use -fprofile-instr-generate, but when I try that, I get 
 a ton of linker errors complaining of undefined reference to 
 the symbol:

 	__llvm_profile_instrument_target

 What gives?  I'm guessing I need to specify some additional 
 LLVM libraries for this?
How are you linking? Do you let LDC link and is `-fprofile-instr-generate` passed during linking aswell? The profiling runtime must be linked in. On Unixes, the file is "libldc_rt.profile-x86_64.a". - Johan
Apr 25 2018
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Wed, Apr 25, 2018 at 06:33:56PM +0000, Johan Engelen via Digitalmars-d wrote:
 On Wednesday, 25 April 2018 at 17:31:06 UTC, H. S. Teoh wrote:
 I'm trying to figure out how to do a traditional instrumented
 profile with LDC.  All docs that I've managed to find so far say to
 use -fprofile-instr-generate, but when I try that, I get a ton of
 linker errors complaining of undefined reference to the symbol:
 
 	__llvm_profile_instrument_target
 
 What gives?  I'm guessing I need to specify some additional LLVM
 libraries for this?
How are you linking? Do you let LDC link and is `-fprofile-instr-generate` passed during linking aswell?
I'm compiling and linking with LDC as a single command.
 The profiling runtime must be linked in. On Unixes, the file is
 "libldc_rt.profile-x86_64.a".
[...] This library appears to be missing from my system. I'm guessing that's the cause of the problem. Which package is it found in? I currently have these ldc-related packages installed: ldc libphobos2-ldc-dev libphobos2-ldc-shared-dev libphobos2-ldc-shared78:amd64 Maybe I'm missing a package or two? T -- Век живи - век учись. А дураком помрёшь.
Apr 25 2018
parent Johan Engelen <j j.nl> writes:
On Wednesday, 25 April 2018 at 19:05:53 UTC, H. S. Teoh wrote:
 On Wed, Apr 25, 2018 at 06:33:56PM +0000, Johan Engelen via 
 Digitalmars-d wrote:

 The profiling runtime must be linked in. On Unixes, the file 
 is "libldc_rt.profile-x86_64.a".
[...] This library appears to be missing from my system. I'm guessing that's the cause of the problem. Which package is it found in? I currently have these ldc-related packages installed: ldc libphobos2-ldc-dev libphobos2-ldc-shared-dev libphobos2-ldc-shared78:amd64 Maybe I'm missing a package or two?
On Unixes, packagers have to manually set our CMake option `LDC_INSTALL_LLVM_RUNTIME_LIBS=ON`. Probably, the Debain package is built without it. (It should be in `ldc`). Try the LDC release package from Github? -Johan
Apr 25 2018
prev sibling parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On Wednesday, 25 April 2018 at 17:31:06 UTC, H. S. Teoh wrote:
 I'm trying to figure out how to do a traditional instrumented 
 profile with LDC.  All docs that I've managed to find so far 
 say to use -fprofile-instr-generate, but when I try that, I get 
 a ton of linker errors complaining of undefined reference to 
 the symbol:

 	__llvm_profile_instrument_target

 What gives?  I'm guessing I need to specify some additional 
 LLVM libraries for this?
I’d suggest perf if you are on Linux. It also tracks kernel-land calls if you have permissions. Just compile with debug symbols and run: perf record -g ./app ... perf report Works for both DMD and LDC. It is sampling, so might not be accurate for short lived stuff.
 I'm using the official Debian ldc package, btw.  Is there 
 possibly a missing dependency on some llvm libraries?


 T
Apr 25 2018