On Monday, 21 January 2019 at 14:36:15 UTC, Márcio Martins wrote:
On Thursday, 17 January 2019 at 00:11:10 UTC, Johan Engelen
wrote:
OK, got it :-) LLVM 7 changed things a little, so it's broken
with LDC 1.13 [*].
For now, you can use LDC 1.12 (LLVM 6). You also have to add
`-L-lstdc++` as compiler flag. So with LDC 1.12, Linux, and
this commandline things work for me:
```
ldc2 -fxray-instrument -fxray-instruction-threshold=1
xraytest.d -L-lstdc++
XRAY_OPTIONS="patch_premain=true xray_mode=xray-basic
verbosity=1" xraytest
```
Happy testing,
Johan
[*] XRay was split into several libraries, and we only
copy+link with one of them. You can make things work by
downloading the libs and linking with them.
Great! Does it mean it will be fixed in next LDC release? :)
Yes: https://github.com/ldc-developers/ldc/pull/2965
I also played a bit with -finstrument-functions and it works
fine for tools like uftrace... However, if you define your own
__cyg_profile_func_* functions, it won't work (or be useful),
because there is no way to disable instrumenting on these
__cyg_profile_func_* functions, so you can imagine what
happens. I tried @llvmAttr("no_instrument_function"),
supposedly the GCC compatible way to disable instrumentation on
these, but it doesn't make a difference.
You need: pragma(LDC_profile_instr, false), e.g.:
```
pragma(LDC_profile_instr, false)
void fun () { ... }
``
There are few LLVM settings that will make this useful:
- https://reviews.llvm.org/D40276
- https://reviews.llvm.org/D39331 (which enables instrumenting
after inlining, which is more useful in my use case)
- https://reviews.llvm.org/D37622 (is has not been merged yet,
but necessary, to be able to conveniently call library
functions from within the hooks)
These are not too hard to implement in LDC. Whoever is interested
in working on it, here are some pointers in addition to the LLVM
links:
https://github.com/ldc-developers/ldc/issues/2466
https://github.com/ldc-developers/ldc/pull/1845/files
-Johan