How to improve LLDB debugging startup time in Linux - linux

I have a mid size cross-platform application that I can start debugging in 2 to 3 seconds from click "Start Debugging" to hitting a breakpoint at the top of the main() method. This is when built with MSVC2019 toolset in Visual Studio.
The same application is also compiled under Ubuntu 20.04 and MacOS using clang-10 and debugged with LLDB. However, either in VSCode or Qt Creator it takes about 15 seconds from click "Start debugging" to hitting the same breakpoint. It looks like the majority of the time is spent loading symbols from the shared objects. On MacOS, despite being developed with a MacBook and not having a powerful desktop CPU, it loads in about 6 seconds, i.e. faster.
Compiler args being used:
clang -x c++ -std=c++17 -O0 -g -fPIC -fmessage-length=0 -fstrict-aliasing -stdlib=libc++ -isystem "/usr/lib/llvm-10/include/c++/v1/" -isystem "/usr/include" -MMD -MF $out.d -o $out -c $in
Linker args being used:
clang -O0 -fPIC -fmessage-length=0 -fstrict-aliasing -stdlib=libc++ -g -fvisibility=hidden -pedantic-errors -fobjc-arc -z noexecstack -z relro -z now -lc++ -lc++abi -lm -lrt -shared -Wl,-rpath,'$$ORIGIN',-z,origin -o $out #$out.rsp
My question is, is there a well known combination of clang compiler/linker flags or lldb settings that can be tweaked to improve debugger startup time when developing on Linux?
I've tried settings set target.preload-symbols false on lldb init commands, but it didn't help much.

Related

gcc 7.1 parameters not reconized after compile

I built GCC 7.1 successfully and installed it, however when I tried to compile with options like -quiet, -imultiarch x86_64-linux-gnu and/or -auxbase dummy it does not recognize them. do I have to add these on compile somehow? These options are recognized by the compiler when installed though packages.
These flags are recognized by the internal compiler executable, cc1, but not by gcc, which is the compiler driver (the driver is the high level compiler executable which orchestrates the build process, and is responsible for running as and ld, among other things).
For example, gcc foo.c -o foo.o -v results with this cc1 command line on Ubuntu 16.04:
/usr/lib/gcc/x86_64-linux-gnu/5/cc1 -quiet -v -imultiarch x86_64-linux-gnu foo.c -quiet -dumpbase foo.c -mtune=generic -march=x86-64 -auxbase foo -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccds3WIY.s
Note -quiet, -imultiarch and auxbase in the above.

Unable to compile C program on Mac, but able to compile on Linux

I facing some trouble compiling my programming assignment on my local machine. The program is distribute to us with makefiles and compilation commands that are known to work on the school's Scientific Linux servers. My local machine is Mac OS X El Capitan.
When I compile my program running make on my Mac, I get the following error that prevents compilation from proceeding:
myid-MacBook-Pro:mp6 myid$ make
gcc -g -lm -std=c99 -Wall -Werror -c lodepng.c
clang: error: -lm: 'linker' input unused
make: *** [lodepng.o] Error 1
But when I push that very same code as work in progress to the Linux servers and compile there, everything works fine. The linux servers use gcc and not clang:
[netid#linux-a2 mp6]$ make
gcc -g -lm -std=c99 -Wall -Werror -c functions.c
gcc -g -lm -std=c99 -Wall -Werror main.o lodepng.o imageData.o functions.o -o mp6 -lm
gcc -g -lm -std=c99 -Wall -Werror -c test.c
gcc -g -lm -std=c99 -Wall -Werror test.o lodepng.o imageData.o functions.o solution.o -o test -lm
In the makefile, these are the variable definitions:
CC=gcc
CFLAGS=-g -lm -std=c99 -Wall -Werror
and the target definition for loadpng.o
lodepng.o: lodepng.c
$(CC) $(CFLAGS) -c lodepng.c
I would appreciate any help on understanding this error and overcoming it.
Thank you very much.
Also, on this note, I thought I would say that I've noticed a subtle difference between Clang and GCC. It seems to me that even warnings generated by Clang would prevent the compilation to proceed so the warnings behaves like errors. But for GCC, if it generates warnings, it still compiles the object file. Please correct me if I'm mistaken.
Right now you're getting a compilation error on your Mac because you're trying to pass linker commands (i.e. -lm) into a compilation(i.e. -c). Do not give link flags when you compile (-c flag) your source files.
In the other compilation snippet you provided, the unused linker command seems to pass by unnoticed which isn't a good thing.
For your last question, the flag -Werror should force all compilation warnings to become errors -- which is exactly what you are describing.

Cross Compile ncurses application for ARM linux

I want to cross compile an application from my workstation (x86, linux) for an ARM application processor. First I build for my system:
gcc -static -g -Wall -c main.c -o main.o
gcc -g -Wall main.o -o myApplication -lncurses
this build like I want and also work. If I want to build this for arm
arm-linux-gnueabi-gcc -static -g -Wall -c main.c -o main.o
arm-linux-gnueabi-gcc -g -Wall main.o -o myApplication -lncurses
But this will not compile.
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find -lncurses
collect2: Error
So: how to cross-compile a ncurses Application in this way?
One easy way to do it would be to download a binary release of ELLCC. It comes with a pre-built libraries, including ncurses. The download page is here. If you grab e.g. http://ellcc.org/releases/ellcc-x86_64-linux-eng-0.1.27.tgz (The version number will change over time), you can untar it. For the ARM, your build lines would look like:
~/ellcc/bin/ecc -target arm-linux-engeabihf -g -Wall -c main.c -o main.o
~/ellcc/bin/ecc -target arm-linux-engeabihf -g -Wall main.o -o myApplication -lncurses
It creates a static binary, so you don't have to worry about shared library versions.

Source-built clang-3.7 on Linux not finding Block_copy

I built and installed llvm/clang-3.7 from source on my Ubuntu Linux system (I'm building from source because my development environment at work does not have apt-get available). The gcc version is 4.8.2. I followed the clang build instructions at http://clang.llvm.org/get_started.html, and everything worked fine (mkdir build; cd build; cmake -G "Unix Makefiles" ../llvm; make; make install). However, I'm now finding that a program to test Block_copy fails to compile. The program is auto-generated by autoconf when I try to build gnustep-base. The part that fails is:
int
main ()
{
return _Block_copy ();
;
return 0;
}
My compile command is:
clang -o conftest -m64 -march=opteron -mno-3dnow -ggdb -O2 -Wall -I/home/build/GNUstep/Local/Library/Headers -I/home/build/GNUstep/Local/Library/Headers -I/home/build/GNUstep/System/Library/Headers -fgnu-runtime -x objective-c -m64 -L/home/build/GNUstep/Local/Library/Libraries -L/home/build/GNUstep/Local/Library/Libraries -L/home/build/GNUstep/System/Library/Libraries conftest.c -lrt -ldl -lpthread -rdynamic -m64 -fgnu-runtime -L/home/build/GNUstep/Library/Libraries -L/home/build/GNUstep/Local/Library/Libraries -L/home/build/GNUstep/System/Library/Libraries -lobjc -lm
Do I need to build clang with a special option to enable blocks, or should I be linking with another library?
Do I need to build clang with a special option to enable blocks
No. But you may need -fblocks option using the clang binary.
-fblocks
Enable the "Blocks" language feature.
should I be linking with another library?
AFAIK, Yes.
_Block_copy is a part of BlocksRuntime.
BlocksRuntime Block.h
BlocksRuntime runtime.c
Have you compiled compiler-rt? It includes BlocksRuntime. The document explains how to build compiler-rt.

CommandT installation problems on windows

After completing all installation steps for the CommandT plugin, I get the error command-t.vim could not load the C extension when starting it. The ComamndT troubleshooting section gives this advice:
If a problem occurs the first thing you should do is inspect the output of:
ruby extconf.rb
make
During the installation, and:
vim --version
And compare the compilation and linker flags that were passed to the
extension and to Vim itself when they were built. If the Ruby-related
flags or architecture flags are different then it is likely that something
has changed in your Ruby environment and the extension may not work until
you eliminate the discrepancy.
And it does indeed seem that there is discrepancy for me.
Output from make suggests cygwin's gcc is using ruby 1.8:
gcc -I. -I/usr/lib/ruby/1.8/i386-cygwin -I/usr/lib/ruby/1.8/i386-cygwin -I. -DHA
VE_RUBY_H -g -O2 -std=c99 -Wall -Wextra -Wno-unused-parameter -c ext.c
gcc -I. -I/usr/lib/ruby/1.8/i386-cygwin -I/usr/lib/ruby/1.8/i386-cygwin -I. -DHA
VE_RUBY_H -g -O2 -std=c99 -Wall -Wextra -Wno-unused-parameter -c match.c
gcc -I. -I/usr/lib/ruby/1.8/i386-cygwin -I/usr/lib/ruby/1.8/i386-cygwin -I. -DHA
VE_RUBY_H -g -O2 -std=c99 -Wall -Wextra -Wno-unused-parameter -c matcher.c
gcc -shared -s -o ext.so ext.o match.o matcher.o -L. -L/usr/lib -L. -Wl,--enabl
e-auto-image-base,--enable-auto-import,--export-all -lruby -ldl -lcrypt
Output from vim's :version contains this output:
-DDYNAMIC_RUBY_VER=191 -DDYNAMIC_RUBY_DLL=\"msvcrt-ruby191.dll\"
The troubleshooting guide suggests using a combination of Vim 7.2, Ruby 1.8.7-p299, and DevKit 3.4.5r3-20091110. However this is not a good solution for me for a number of reasons:
I'm using Vim 7.3 and would like to continue doing so.
Ruby 1.9.3 is installed on my system, and I need it in my PATH for other projects.
So is there any way to get this working, while keeping the latest version of ruby and the latest version of vim?
UPDATE
Having followed AndrewMarshall's advice, I installed Ruby191 and DevKit-4.5.0-20100819-1536-sfx.exe according to this tutorial and ran ruby extconf.rb through that version. The make cmd executed successfully with this output:
gcc -I. -IC:/Ruby191/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby191/include/ruby-1
.9.1/ruby/backward -I/C/Ruby191/include/ruby-1.9.1 -I. -DHAVE_RUBY_H -O2 -g -
Wall -Wno-parentheses -std=c99 -Wall -Wextra -Wno-unused-parameter -o ext.o -c
ext.c
gcc -I. -IC:/Ruby191/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby191/include/ruby-1
.9.1/ruby/backward -I/C/Ruby191/include/ruby-1.9.1 -I. -DHAVE_RUBY_H -O2 -g -
Wall -Wno-parentheses -std=c99 -Wall -Wextra -Wno-unused-parameter -o match.o
-c match.c
gcc -I. -IC:/Ruby191/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby191/include/ruby-1
.9.1/ruby/backward -I/C/Ruby191/include/ruby-1.9.1 -I. -DHAVE_RUBY_H -O2 -g -
Wall -Wno-parentheses -std=c99 -Wall -Wextra -Wno-unused-parameter -o matcher.
o -c matcher.c
gcc -shared -s -o ext.so ext.o match.o matcher.o -L. -LC:/Ruby191/lib -L. -Wl,-
-enable-auto-image-base,--enable-auto-import -lmsvcrt-ruby191 -lshell32 -lws2
_32
and running :CommandT in vim works now, but as soon as I start typing to search for a file, and then hit enter to select and open it, I get this:
not a real answer but you may wanna try ctrlp instead.
written in vimscript (no dependency, no compiling)
as fast as CommandT (subjective to me)
has probably more features than CommandT (does CommandT have most recent file?)
there is also the good old FuzzyFinder which I haven't tried. seems like it hasn't got updated for about 2 years but it may still be working.
I successfully installed newest command-t on vim 8.0 on windows 10. And I find this question when I'm working on it so I'm gonna post my solution although it's a little late.
Ruby version for vim 8.0 is Ruby 2.2. So download and install Ruby 2.2 and Ruby Devkit (remember to execute ruby dk.rb init and ruby dk.rb install for devkit ).
Then I follow the command-t instruction to execute ruby extconf.conf, but it failed -- it output You have to install development tools first. even though I did install it:
I googled this issue find RubyInstaller wiki says that I should execute this command by add -rdevkit and I did it. It succeed when I execute ruby -rdevkit extconf.rb but failed when make. So I googled again and find another way to compile it:
rake make -rdevkit
And it worked. Here is my screenshot:

Resources