Clion Cmake Ninja build on Linux consuming all of the RAM and crashing PC because of that - cmake

I have quite an weird issue on Linux machine where trying to build c++ project using CLion, Cmake and Ninja Generator would result in PC freezing due to all of RAM being used up. This usually happens ether when reloading CMake project or building the project itself.
Is there a way to limit how much RAM will be consumed? Currently all my 32GB + 16GB swam get eaten, I tried adding -j4 to CMake build options, but that did not help.
EDIT: The PC did ran out of RAM for a different issue, but I still would like to limit how much ram can build and reloading take, so I'll leave my question

Related

why ninja build and msbuild are unable to utilize more than roughly 50%?

I have a Lenovo Z51-70 laptop (Windows10). it had 8GB RAM by default and SSHD. When I used to compile large projects 20K c++ files Task Manager always showed 90-100% CPU utilization. A week back I upgraded SSHD to SSD and 8GB RAM to 16GB RAM for gaining speed in the compilation. But build time hasn't improved (it is almost same) but Task Manager always shows roughly 50% CPU utilization. Why it is not able to utilize anyway near 90-100%? and why same build on SSHD & 8GB RAM always used to consume roughly 90-100% CPU utilization? It is not specific to a particular build system, i have tried MSBUILD, NINJA. All build system show same CPU utilization. I have tried to compile different projects for excluding any reason which may be the project-specific.
Any thoughts?

How do I profile an Objective-C program without Xcode?

I want to create a Release-build of some Objective-C program with Xcode, install it on a very slow machine, generate profiling output, and analyze that output on my machine. I need to do this in order to chase down a specific bug, which only happens on the slow machine.
Machine 1: has Xcode installed. Can compile the program. Is relatively fast. macOS 10.12
Machine 2: doesn't have Xcode installed. Doesn't have Xcode Instruments installed. Will run the program. Should generate profiling output. If I install Xcode on that machine, it will probably slow down to a level that it becomes completely unusable. Is relatively slow. macOS 10.12
The Xcode command "Build for profiling" sounds promising. But.. if I run that "profile build", what has changed? Does it generate profiling output? If yes, where will it be stored? How can I analyze these files?
Any thoughts, or pointers to Apple documentation? I only found the "Instruments User Guide". It tells me how to use Instruments to profile an application.
This is not an iPhone-question. If you are an iPhone-developer and have never worked with macOS-applications, please don't answer ;)

valgrind compilation for ppc says cannot execute binary file

Trying to run valgrind on my application.
I have copied the valgrind executable file (based on ppc compiler) into a machine based on intel compiler(i686).
I am stuck after this .
I have tried googling for the same but did not come across any standard document.
Can anybody please help? Just a nudge in the right direction ....
Yes, one of my processes running on PPC machine crashed. Wanted to check for memory leaks in that process. But the available valgrind is for x86 machine.

cmake on Solaris 10 Sparc: Configured not to use shared libraries?

I'm trying to port some software over to Solaris 10 Sparc, using GCC 3.4.6, and the software's build system uses cmake. When I run the command cmake CMakeLists.txt, I get a lot of output like this:
ADD_LIBRARY for library <library_name> is used with the SHARED
option, but the target platform supports only STATIC libraries.
Building it STATIC instead. This may lead to problems.
Obviously Solaris 10 Sparc supports shared libraries, and I have built this software on x86 Solaris 10 before.
Anyone run into this or can provide direction? I'm about to dive into the cmake source to figure out if it has issues with Sparc Solaris.
Thanks.
After fighting with this a couple hours, and making little headway, I decided to install cmake-2.8.6 from OpenCSW using pkgutil, and this issue cleared up.
Also asked this question in #cmake#irc.freenode.net before I fixed it, looks to be an issue with cmake 2.6.4 on Sparc Solaris 10.

Building an NPAPI browser plugin on Linux x86 and x86_64, how do I ensure that it loads the correct version of its dependent libraries?

I'm attempting to build a Linux browser plugin using Firebreath that runs on 32bit and 64bit Linux.
In my X11/projectDef.cmake I have
target_link_libraries(${PROJECT_NAME}
${PLUGIN_INTERNAL_DEPS}
"${CMAKE_CURRENT_SOURCE_DIR}/lib/libOIS-1.4.0_32.so"
)
Currently I'm just manually changing that line switching 32 to 64 when I want to do a different build, so that's probably wrong. But my issue is that even when I build with the 32bit library and it compiles successfully, I get the following error when trying to load the plugin in Firefox:
$ firefox
LoadPlugin: failed to initialize shared library /home/daniel/.mozilla/plugins/npBoomstickJavaScriptJoystickSupport.so [libOIS-1.4.0.so: wrong ELF class: ELFCLASS64]
How do I set up my cmake to automatically include the correct library depending on the architecture? Is there a way to build both x86 and x86_64 simultaneously on the same machine? How do I get the plugin to load correctly or is there a way to further debug this problem?
As far as I know the only way to do a build for 32 bit on a 64 bit machine is to use cross compiling: http://www.vtk.org/Wiki/CMake_Cross_Compiling
I've never actually tried this, but inside CMake you can probably use the CMAKE_SIZEOF_VOID_P which will be 4 in 32 bit mode, 8 in 64 bit. You could add an if to your cmake script to set the correct binaries depending on the size of that.