0

I want to be able to debug my driver more efficiently by being able to step thru source code without all the hopping around. Is there a way to specify that just a certain driver would get the -O0 optimization? And the rest can get whatever is the normal Linux Kernel Op, e.g. -O3?

3
  • A down-vote with no explanation? What's wrong with this question?
    – Joe C
    May 30, 2014 at 17:26
  • Yeah. Seems like a reasonable question to me. I don't have a good answer: I don't think there's any easy way to do what you want. As a short-term hack, I'd probably run "make -n" to capture the particular commands needed to build your driver into a shell script. Then build your driver manually, after which you run make on the kernel as a whole to finish it off. (There is a lot to be said for compiling the entire kernel with CONFIG_FRAME_POINTER though in order to get sane backtraces.) May 30, 2014 at 21:38
  • Yes, it may be possible but it is not straightfwd and also you might see random crashes if compile without default optimization. Because some part of kernel code depends on compiler optimization. As mentioned by Gil Hamilton, you have to tweak build scripts and makefile to compile it with -O0. To my knowledge module should work with -O0 optimization as long as your code does not use gcc specific constraints directly in your code or in-directly (inline functions from kernel header files)
    – Sasi V
    May 30, 2014 at 22:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.