Set default cmake build_type to 'Release' for llvm#5261
Set default cmake build_type to 'Release' for llvm#5261scheibelp merged 2 commits intospack:developfrom
Conversation
| # https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html | ||
| variant('build_type', default='RelWithDebInfo', | ||
| description='The build type to build', | ||
| description='Cmake build type', |
| description="Build all supported targets, default targets " | ||
| "<current arch>,NVPTX,AMDGPU,CppBackend") | ||
| variant('build_type', default='Release', | ||
| description='Cmake build type', |
FYI (should you be interested in the code) I added that back in #2623 together with the support for inheriting directives. |
alalazo
left a comment
There was a problem hiding this comment.
Honestly I would go with Release by default - currently we remove the sources we built from after a successful installation
|
@scheibelp thanks for the quick fix! It seems the
@tgamblin explained this to me in #3966 Most tools you do want There may be other packages that should be defaulting to |
@svenevs I may agree with that (even though debugging a release build is a lysergic experience due to compiler optimizations). The fact is that we normally delete the source files after a build, or eventually we relocate them. I don't know how nicely that plays with the debug info in the binary objects. |
Noting first that my word is far from law on this, my experience as a C++ developer is this:
I think what you're getting confused about is the compilation process. Say I have two files A and B that are ultimately getting linked into This is in many ways an embarrassing oversimplification, but the idea is that the final library that gets created still contains the debugging symbols, because when A and B were compiled we asked for them (via Edit: or you're completely on the money, and my explanation only applies to static libraries ( |
Not true. You can step into the library call and see machine code. Not sure how much that will be useful though. Anyhow you can still set breakpoints on functions exported in header files. The fact is: as far as I know debugging symbols introduce references back to the original source files to map the current instruction to a line you coded. Try to play with: // hello.h
void hello();
// hello.c
#include "hello.h"
#include <stdio.h>
#include <stdlib.h>
void hello(char * continuation) {
char * greeting = "Hello";
printf("%s %s\n", greeting, continuation);
}
// main.c
#include "hello.h"
int main() {
char * final = "world!";
hello(final);
return 0;
}and compile the thing like: $ gcc -c -Wall -Werror -fPIC -O2 hello.c
$ gcc -shared -o libhello.so hello.o
$ gcc -L$PWD -Wl,-rpath=$PWD -Wall -Werror -O2 -o test main.c -lhelloIf you run (gdb) break main
Breakpoint 1 at 0x4005c0
(gdb) break hello
Breakpoint 2 at 0x4005a0
(gdb) run
Starting program: /home/mculpo/tmp/debug/test
Breakpoint 1, 0x00000000004005c0 in main ()
(gdb) continue
Continuing.
Breakpoint 2, 0x00007ffff7bd86f0 in hello () from /home/mculpo/tmp/debug/libhello.so
(gdb) bt full
#0 0x00007ffff7bd86f0 in hello () from /home/mculpo/tmp/debug/libhello.so
No symbol table info available.
#1 0x00000000004005d0 in main ()
No symbol table info available.
(gdb) continue
Continuing.
Hello world!
[Inferior 1 (process 4866) exited normally]Now if you compile with debugging info: $ gcc -g -c -Wall -Werror -fPIC -O2 hello.c
$ gcc -shared -o libhello.so hello.o
$ gcc -g -L$PWD -Wl,-rpath=$PWD -Wall -Werror -O2 -o test main.c -lhelloand then you rename or delete Reading symbols from ./test...done.
(gdb) break main
Breakpoint 1 at 0x4005c0: file main.c, line 3.
(gdb) break hello
Breakpoint 2 at 0x4005a0
(gdb) run
Starting program: /home/mculpo/tmp/debug/test
Breakpoint 1, main () at main.c:3
3 int main() {
(gdb) continue
Continuing.
Breakpoint 2, hello (continuation=continuation@entry=0x400754 "world!") at hello.c:8
8 hello.c: No such file or directory.
(gdb) bt full
#0 hello (continuation=continuation@entry=0x400754 "world!") at hello.c:8
greeting = 0x7ffff7bd8719 "Hello"
#1 0x00000000004005d0 in main () at main.c:5
final = 0x400754 "world!"
(gdb) continue
Continuing.
Hello world!
[Inferior 1 (process 4914) exited normally]The missing source file causes the So my point is: should we generally pay for more space due to debug symbols if the state of things we are creating is that of the second example? |
|
Thanks for the reviews! And thanks to @alalazo for making this easy! |
|
@alalazo I stand both corrected and disgraced, humbled by your strictly superior understanding and prowess. As it turns out the reason why I had this belief is because the only times I've actually gone through and debugged stuff like this is using git submodules, for which the source files were indeed still around! This has all been quite illuminating. |
Even if we delete source after successful installation, Unless I mistaken something... |
|
@pramodk True, but did you consider:
? |
|
Anyhow, maybe it's better not to pollute this thread (sorry @scheibelp) and continue the discussion on Slack?` |
I think a github issue might be better, since you have more formatting options. I'll add one and refer to this and #5258 |
Fixes #5258
I wasn't aware of this, but it appears that Package subclasses can override the variants of their parents. The llvm Cmake package was using the default Cmake build_type
RelWithDebInfowhich was significantly increasing the size of the package. This redefines thebuild_typevariant for llvm and sets the default value toRelease.Another option would be to set the default
build_typeto Release for all Cmake packages. I opted to set this specifically for llvm because it seemed particularly important that llvm control its default build type.