Hello, I am trying to debug some C code that is run only through a R package. I debug with lldb but I always get a message telling that the package "was compiled with optimization - stepping may behave oddly; variables may not be available.? And in fact, I cannot evaluate all variables and understand what is wrong. I have created a Makevars file in ~/.R/ that contains C=clang -O0 -g but it does not seem to change much. What should I do to make sure I can evaluate all variables in lldb? I am on a Mac and I wrote C=clang because I read that it produced much better error messages but I am happy to use gcc as well if this can be a solution. Many thanks Guillaume
[R-pkg-devel] Compiler optimization flags with R package
4 messages · Guillaume Chapron, Dirk Eddelbuettel
On 17 June 2017 at 21:32, Guillaume Chapron wrote:
| I am trying to debug some C code that is run only through a R package. I debug with lldb but I always get a message telling that the package "was compiled with optimization - stepping may behave oddly; variables may not be available.? And in fact, I cannot evaluate all variables and understand what is wrong. I have created a Makevars file in ~/.R/ that contains C=clang -O0 -g but it does not seem to change much. What should I do to make sure I can evaluate all variables in lldb? I am on a Mac and I wrote C=clang because I read that it produced much better error messages but I am happy to use gcc as well if this can be a solution.
Edit the file Makeconf in e.g.
R> file.path(Sys.getenv("R_HOME"), "etc", "Makeconf")
[1] "/usr/lib/R/etc/Makeconf"
R>
It has those settings hardwired from when R itself was compiled for you. You
probably want to keep a copy of the original file to be able to revert.
Dirk
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
Thanks! In that file, I see: CC = clang CFLAGS = -Wall -mtune=core2 -g -O2 $(LTO) will having -O0 instead give me all the variables or is there a flag for better debugging (I guess -g does it a little already)? Thanks again
On 17 Jun 2017, at 21:57, Dirk Eddelbuettel <edd at debian.org> wrote:
On 17 June 2017 at 21:32, Guillaume Chapron wrote:
| I am trying to debug some C code that is run only through a R package. I debug with lldb but I always get a message telling that the package "was compiled with optimization - stepping may behave oddly; variables may not be available.? And in fact, I cannot evaluate all variables and understand what is wrong. I have created a Makevars file in ~/.R/ that contains C=clang -O0 -g but it does not seem to change much. What should I do to make sure I can evaluate all variables in lldb? I am on a Mac and I wrote C=clang because I read that it produced much better error messages but I am happy to use gcc as well if this can be a solution.
Edit the file Makeconf in e.g.
R> file.path(Sys.getenv("R_HOME"), "etc", "Makeconf")
[1] "/usr/lib/R/etc/Makeconf"
R>
It has those settings hardwired from when R itself was compiled for you. You
probably want to keep a copy of the original file to be able to revert.
Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
On 18 June 2017 at 09:22, Guillaume Chapron wrote:
| Thanks! | | In that file, I see: | | CC = clang | CFLAGS = -Wall -mtune=core2 -g -O2 $(LTO) | | will having -O0 instead give me all the variables or is there a flag for better debugging (I guess -g does it a little already)? Right, -g is what you need. I used to not alter -O flags for simplicity but because code _could_ be reorganized for optimization it is not a bad idea to use -O0 as well. But the key is -g (just how there is -pg for profiling). Dirk
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org