jeremy-rifkin / cpptrace

Simple, portable, and self-contained stacktrace library for C++11 and newer
MIT License
621 stars 64 forks source link

Add 'POSITION_INDEPENDENT_CODE ON' (also known as '-fPIE'). #99

Closed kouchy closed 6 months ago

kouchy commented 6 months ago

First thx for these very useful lib!

I encountered some issues when linking with libcpptrace. Typically, here is the error I got:

/usr/bin/ld: lib/cpptrace/lib/libcpptrace.a(cpptrace.cpp.o): relocation R_X86_64_32S against symbol `_ZTVNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEE@@GLIBCXX_3.4.21' can not be used when making a PIE object; recompile with -fPIE

I just added the POSITION_INDEPENDENT_CODE ON flag on the targets, and now it works like a charm :-).

jeremy-rifkin commented 6 months ago

Hey thanks for the PR! I think looks good to me but let me double check the implications later today. It might be desirable to have an option for whether or not to use PIC.

kouchy commented 6 months ago

Fair enough, sounds wise :-).

jeremy-rifkin commented 6 months ago

Alright, I think I'm happy to have POSITION_INDEPENDENT_CODE by default but it'd be good to have an option to disable that. If you'd like to do that I'd welcome it, or otherwise I'm happy to merge and take care of that after :)

kouchy commented 6 months ago

I updated my PR :-)

jeremy-rifkin commented 6 months ago

Awesome thank you so much!