0

I'm running Ubuntu 20.04. I would like to build an emacs binary for general usage (no debug symbols) and another emacs binary (when something goes wrong). The build is pretty straight-forward, but I don't know how to have both debug and non-debug binaries exist at the same time.

Is it enough to ./autogen.sh && ./configure -ggdb3 -O0 && make - and then copy the resulting src/emacs debuggable binary to a temporary directory.

Followed by ./autogen.sh && ./configure && make && make install which will create (in my case) a /usr/local/bin/emacs-28.0.50

Finally, can I simply copy the binary I configured with debug flags to /usr/local/bin/emacs-28.0.50-debug and call that file when needed?

Or - do I have to included other emacs-related files when I debug emacs?

3
  • 1
    How about setting the prefix flag differently for each install? --prefix=/my/dir/one and --prefix=/my/dir/two When debugging, cd to the src directory before launching Emacs under gdb so that the .gdbinit loads and use the path to the executable in the desired directory. I do not know, however, whether this will work given your stated use case. A cleaner method would be to just have two separate base directories with each having a separate repository to build from; e.g., repository-one-dir and repository-two-dir. With computers having tons of space, there's no need to skimp. – lawlist Jan 28 at 6:26
  • I appreciate the comment, and I can certainly do that. I was wondering if other files in the emacs source tree are modified when you build the binary with debug symbols. If I don't get any clarifications, I'll certainly take your advice. – o__b Jan 28 at 6:30
  • This can be determined with a simple diff of the directory trees using the respository-one-dir and repository-two-dir approach ... I like ztree-diff ... If you find differences, then you can diff/compare individual files to see what has changed. – lawlist Jan 28 at 6:35
0

Why not just leave the debug symbols in place? They don't use up any extra memory, or slow the program down.

I suspect that what you really want is an optimized and an unoptimized build, both with symbols. It is frequently the case that optimizations can make a program more difficult to debug, often by rearranging the order of operations or making it more difficult to discover the values of variables. If that's the case, then you could install the optimized build as normal and then just leave the unoptimized build in the source directory. When you need it you can just run it from there.

Another option is to install the Ubuntu Emacs packages as usual, and keep an unoptimized copy you've built yourself. Keep in mind that for every Ubuntu package there are corresponding source and debug symbol packages that you can also install. Installing them will enable you to have the exact source code and debug symbols for the Emacs you have installed via the deb package as well as for the version you've built yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.