Some developer's questions

Andrea Venturoli ml at
Mon May 30 07:39:47 UTC 2016


I've been moving some of my boxes from 9.3 to 10.3: I'll have to upgrade 
them all by end of the year, since 9.3 will be unsupported by then.
I'm a developer and I'm trying to understand how to cope with the shift 
from GCC to LLVM/CLang.

The compiler itself is fine: I even tend to say I like it (possibly also 
because our GCC was quite obsolete).
However, I still have some issues and I'd appreciate any suggestion or 
statement about the following.


If I understand correctly, LLVM has its own debugger, LLDB, but I find 
no such thing in our OS.
Is it the official position that we should use GDB and that it's fully 
While I'd like the answer to be positive (mainly because I would not 
need to learn a new synthax), there are some issues:

_ since a long time I find base's GDB practically useless (due to 
crashes, missing features, etc...); this didn't change with 10.3, due to 
us still hanging to an obsolete version (I know the political reasons 
and I don't want to start a discussion or flame on this);

_ so I've been installing 7.11 from ports, which works a bit better, but 
with the switch to clang we lost some functionality: e.g. "p v.size()" 
does not work anymore on C++ containers; is there a way to get this back?

_ as I said, there is no LLDB in base, but it can be installed with 
devel/lldb37, devel/lldb38, or any devel/llvmXX. Is this (which one?) 
the way I shoudl go?

_ Any change to get some Emacs integration then?

_ Anything else/any other hint?


I need to know which part of my code is wasting CPU, but, even more, I 
need to know which lines are executed and which one are not even touched 
by a set of input data.

Up to 9.3, I used to compile with "-pg --coverage" and link with "-pg 
-lgcov", but that does not work anymore on 10.3, giving:
> /usr/bin/ld: undefined reference to symbol `__pthread_cxa_finalize@@FBSDprivate_1.0' (try adding -lthr)
> //lib/ could not read symbols: Bad value

Adding "-lthr" doesn't solve, however, since I'll get tons of
> undefined reference to `llvm_gcda_start_file'
> undefined reference to `llvm_gcda_emit_function'
> undefined reference to `llvm_gcda_emit_arcs'

AFAICT we have no such things in our base libraries.
Am I wrong?

So I read I might be using an old way of profiling and that I should add 
"-fprofile-instr-generate" instead.
This, however, leads to:
> c++: error: unknown argument: '-fprofile-instr-generate'

I tried "-fprofile-generate", but then I get:
> c++: warning: argument unused during compilation: '-fprofile-generate'

So I'm stuck: how should I do profiling?
Do I need to switch to a newer compiler from ports?

  bye & Thanks

More information about the freebsd-questions mailing list