GCC: how to pause/continue compilation? - gcc

Is there an option to stop compilation and save state to a file and then load the file and continue compilation?
I know that GCC has -fdump-gimple-tree option, which makes GCC dump an internal representation "GIMPLE" to a file, but I cannot find an option to load the file back in.

I see a few options:
try to update your patch for 4.3.1 to 4.5.0 (do not try to merge the patched 4.3.1 code branch with the 4.5.0 code branch, that would be mayhem)
try to get your patch to 4.3.1 to be included in the 4.5 release. If it fixes a bug, that should be possible (just file a _detailed_ report on the GCC bugzilla)
try to modify your code so that it does not depend on that 4.3.1 patch or on the plugin infrastructure
Or... all of the above.
Trying to get your code halfway compiled partially by one version, then finished by another sounds completely hopeless.

I don't know about stopping GCC compilation, but you can cache already compiled file so GCC won't have to compile them again. See CCache.
So if you stop brutally the compilation at some time, say with Ctrl-C, when you start again, all files that were already compiled will be retrieved from the cache.

Related

How can I continue an interrupted compilation after an error occurred?

After an error occurred because of a missing flag or incorrectly set environment variable, is it possible to continue compiling once the mistake has been fixed?
I regularly use CMake and make to compile toolkits that take quite a while to compile and, also regularly, I accidentally set variables incorrectly in the process. Just now for example, I was attempting to include OpenInventor headers which on my machine are located in the directory /Users/user/software/prod/coin/include/Inventor.
I mistakenly passed
-DINVENTOR_INCLUDE_DIR=/Users/user/software/prod/coin/include/Inventor
rather than the correct
-DINVENTOR_INCLUDE_DIR=/Users/user/software/prod/coin/include
This only became an issue after 30 minutes when about 95% of the compilation was completed. Because I knew that reconfiguring using CMake would force a recompilation from scratch, I tried to add -I/Users/user/software/prod/coin/include to CMAKE_CXX_FLAGS in CMakeCache.txt but to no avail–it still recompiled from scratch. Since only a single source file actually includes the headers in question, it would be desirable if I could start compiling from the point where it exited with an error once the relevant path has been corrected. How can I do this and, as an aside, why does it force the compiler to start from scratch?
I'm using CMake version 3.11.1 and clang (Apple LLVM version 9.1.0) on macOS 10.13
CMake does not need to recompile everything just because it regenerates its makefiles. It will still perform normal make avoidance operations. However CMake does track the compiler options used to build each target, so if you make a change in the compiler options for all the targets then they'll all need to be rebuilt.
If this compiler option is only needed for one target, you can add it to just that target an no others, with something like this:
set_property(SOURCE my_source.c APPEND PROPERTY
COMPILE_FLAGS -I/foo/bar)
then it should only rebuild that one source file.
CMake looks for files' "last modified" times to decide which files need recompilation. But if you change the input to CMake itself, then it needs to regenerate the Makefiles and therefore recompile everything. But still, one hack may be possible...
CMake stores information about the include directories and the libraries to be linked in various text files in the build directory. So one hack (not recommended, but works) can be to modify these text files.
In the particular example that you mentioned, the hack would be to search and replace all occurrences of /Users/user/software/prod/coin/include/Inventor with /Users/user/software/prod/coin/include in all the files of the build directory.
(As an aside, if you don't already know, you can use make -j <n> to build using multiple threads which can considerably decrease the build times.)

mrpt The Eigen/Array header does no longer exist in Eigen3

trying to compile mrpt 1.3.2 under Windows and MinGW32.
The CMake configuration has the EIGEN_USE_EMBEDDED_VERSION checked, and my make command is [mingw32-make -f makefile CXXFLAGS="-std=gnu++11" SHARED=1 UNICODE=1 BUILD=release]
The build explodes compiling bayes/CParticleFilter.cpp, and yields the error message "The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core."
What am I doing wrong (besides building under Windows ;) )?
It is already fixed in the master branch of MRPT in GitHub, please give it a try or wait for the next stable release.

Library not found OpenCV

I'm on mac 10.7.5, using xcode 4.6.2 and working with the OpenCV 2.4.3 library. I went through the process of making the build directory with the cmake files in terminal and did the download.
I added the .dylib files in Xcode and changed the header path, changed C++ Library to libstdc++, but when I compiled I got this error :
ld: library not found for -lopencv_calib3d.2.4.3
clang: error: linker command failed with exit code 1
I have libopencv_calib3d.2.4.3.dylib added in the project so I have no idea what else it needs.Any ideas?
If your "make back-end" is Cmake you should stick to using it. Local config changes in Xcode can "secretly" be overwritten when the cmake is rerun (which for example happens after you make changes to it) creating weird build errors and forcing you to remember all the manual changes you made.
Your problem seems to be that the generated project doesn't seem to know where to look for opencv.
Assuming you installed opencv using macports you should add a line saying
link_directories(/opt/local/lib)
to your CMakeLists.txt. (if you installed it using brew, or compiled it manually just replace /opt/local/lib for /usr/local/lib or the path to your compiled libraries)
Also make sure to link against opencv_calib3d instead of opencv_calib3d.2.4.3 (unless you have a very particular reason for bypassing this, but that usually means that something else is weird in the setup :) )
Final pointer that you might already know of: As you are already using Cmake you should add the libraries to link against using TARGET_LINK_LIBRARIES(...) in Cmake rather than manually adding them in Xcode (referring to my previous argument).

MQX 4.0.1 program Not Compiled with GCC

I am using TWR-K20D72M and I opened a Sample program which is given in the MQX 4.0.1 Demo examples. When I choose Build tool option as Freescale
the program compiles OK but When I choose Build tool option as GCC It gives me error.The Error is below
error
Description
mingw32-make: *** No rule to make target `C:/Freescale/Freescale_MQX_4_0/lib/twrk20d72m.cw10gcc/debug/bsp/intflash.ld', needed by `explicit-dependencies'.
I read somewhere that The GCC can only work with MQX 4.0.1 and above so I am using MQX 4.0.1 .
Can some suggest me the reason for this error.How I can I remove this error.......
Thanks
You are missing the linker script file for your project intflash.ld.
Normally this file is located on
{mqx_install_dir}\mqx\source\bsp\{your_bsp_name}\gcc_cw
and is copied to
{mqx_install_dir}\lib\{your_bsp_name}.cw10gcc\debug\bsp
and
{mqx_install_dir}\lib\{your_bsp_name}.cw10gcc\release\bsp
after the build process by the scripts for your bsp, located on
{mqx_install_dir}\mqx\build\bat.
Take a look inside your bsp script and verify that intflash.ld is being copied correctly.
My guess is that you compiled your MQX application before compiling the BSP and PSP. With the release of CodeWarrior 4.6, the solution has gotten a bit easier through the use of .wsd files.
If you look at the FSL_MQX_getting_started.pdf, section 2.4 describes how to find a .wsd file which needs to be dragged into your CodeWarrior Project Explorer. Once this is done new projects will be added to your workspace. Compile the bsp_... and psp_... and any other libs that you require (usb, ethernet etc) which will generate binaries and the intflash.ld file in the correct location.
http://cache.freescale.com/files/soft_dev_tools/doc/support_info/FSL_MQX_Getting_Started.pdf

Can't upgrade gcc on Mac

So this is after having dropped $30 for Mac OS 10.7 and having downloaded XCode 4.3.2. After installing the command line tools, the installed version of gcc is still 4.2.4. I need 4.7. I've installed it and set the g++ link in /usr/bin to it. But when I try to compile any program via QtCreator, I get
unrecognized command line option -Xarch_x86_64
I found this discussed in a 3-year-old bug report here, but I really couldn't follow all the different shell commands etc. and my attempt to install liblastfm failed with the same error. The comment here,
The problem is that the GCC/G++ that is normally used to compile stuff
on Macs is actually just a wrapper.
And this wrapper has Mac-Only arguments like -Xarch_x86_64, which then
get converted into the correct args.
Seems like it might be hitting the nail on the head. Aaargh! Surely there has to be some way to get around this?
I created a custom makespec - in QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs, I copied the macx-g++ folder to macx-g++47. I then removed the "include(../common/g++macx.conf)" from that and included it's contents, except for the part that generates the error (i.e. the -X... thing).
I also finished with
QMAKE_CC = gcc-mp-4.7
QMAKE_CXX = g++-mp-4.7
QMAKE_LINK = $$QMAKE_CXX
QMAKE_LINK_SHLIB = $$QMAKE_CXX
QMAKE_LINK_C = $$QMAKE_CC
QMAKE_LINK_C_SHLIB = $$QMAKE_CC
...which is similar to the spec for macx-g++42.
Now, if I add '-spec macx-g++47' to the qmake args, it works.
A lot of effort for something simple...would love to know a better way.
There are several sources for newer gcc versions for OSX. Here is a small selection:
http://hpc.sourceforge.net/ (currently gcc 4.8, previous versions might also be available)
http://gcc.gnu.org/wiki/GFortranBinaries (has gcc 4.7.0 binary installer)
I assume that you did install the command line tools from within Xcode. Apple/Xcode is not always up to date with gcc, stability is more important here than bleeding edge.

Resources