Buildroot does not re-build modified files - build

i am using external tree building for a linux kernel driver developement. I created a Config.in and a kernel_driver.mk, and everything seemed to work fine, while I still had compilation errors.
I iterated over and over "make driver-dirclean / make driver".
However, i have the impression (and now I verified this fact) that, once i could successfully build correctly once, then BR would NOT rebuild the files aagain, even if i introduce purposely errors in those files !!!
also the output shows:
CC [M] /home/adva/work/sfpnid-drv/buildroot/output/build/hal-1.0.0/kernel/helper.o
LD [M] /home/adva/work/sfpnid-drv/buildroot/output/build/hal-1.0.0/kernel/spidev.o
Building modules, stage 2.
MODPOST 1 modules
CC [M] /home/adva/work/sfpnid-drv/buildroot/output/build/hal-1.0.0/kernel/spidev.mod.o
LD [M] /home/adva/work/sfpnid-drv/buildroot/output/build/hal-1.0.0/kernel/spidev.ko
the compilation never fails where it should !
Is there a cache issue somehow ? rsync effect ?
Thanks,
Jacques

finally i traced down the source of the problem.
As I am using an off-tree build, I had a "make clean" issue. I realise that the dependencies are solved in the BR/output/build/.. environement, while my files are edited off tree.
So what happens is, once it has built successfully 1 time, then the .o are present in BR. The dependencies are satisfied, the "make -rebuild would just re-link the old .o.
I need to do a "make -dirclean" so the new files (with errors) are rsynced.
This is at least the way i understood it.
So for me, this is kinda solved. The fact is, BR is really an integration tool, and less a developement environement. So this behavior is understandable.
Jacques

Related

How to solidify the order in which Bazel builds objects

I'm using Google Bazel to build a program. When I make a large change that affects multiple files, and rebuild, Bazel chooses one file at random to display the error message for. This causes a lot of editor churn, and I constantly lose my context. I fix one compilation error in one file, then rebuild, but I cannot see whether or not the fix worked because Bazel decides to fail on some other file.
Specifically if I have a target
cc_binary(name='foo',
srcs=['bar.cc', 'qux.cc'])
and I run $ bazel build :foo then I will get error messages for bar.cc. If I run again without making any changes, then I will get (maybe) error messages.for qux.cc. I don't know what governs the randomness. Perhaps it is not meant to be known by mere mortals such as my lowly self?
Is there a way to solidify the order in which Bazel builds files, so that I don't have to jump "physically" and mentally between files? Reorienting mental context takes time, and when fixing dumb typos, that time is totally wasted.
What I would love is something like make whereby you can say $ make foo.o. Then I can fix foo.cc, and only after it builds then move on to bar.cc. Does Alphabet Google support such an advanced method?
Try using --keep_going
That will tell bazel not to stop at the first error it finds, and instead try to build everything it can.

Modifying the contents of a .cpp file

UPDATE: I am now able to compile the .cpp file with make
(I can see the compilation output). However, the changes does not seem to take affect.
After i run make, i restart the computer, but still no changes.
As you probably understand, I have very limited experience with c++.
I am currently working on a project (OpenBTS) and have found an error in one of the .cpp files after the project has been built and installed.
My question is, how can I modify the contents (f.eks change the string of a JSON data reference) of a .cpp file and build it so I can see the changes afterwards?
I have currently tried the following:
1.
make 'filename.cpp'
make: Nothing to be done for 'filename.cpp'
2.
make 'filename'
g++ 'filename.cpp' -o 'filename'
In file included from 'filename.cpp:29:0:
'filname.h':26:21: fatal error: Timeval.h: No such file or directory
#include <Timeval.h>
compilation terminated.
3. Run make from root directory:
Nothing to be done for 'all.'
4. Run make clean and make from root. This rebuilds the project but the
changes are still not in effect (I can see that the JSON String is not
changed at the webserver).
5. Run ./build.sh script. Still no changes.
Regarding the 2. method, as the project was built and compiled successfully, how come when i try that with a single file, the compiler can't find the header files? The only thing i changed was a string from "ARFCN" to "ARFCNtest".
Since there are about 50 header files that depends on each other, changing the include from <> to "" and copy every single file into the same directory seems like a waste and unnecessary action?
The changes didn't take effect because the compilation failed. See the error message you quoted in the question. Fix that and rebuild.
Incidentally, restarting your computer shouldn't be necessary. Even the make clean shouldn't be necessary if the Makefile correctly expresses the dependencies. (It seems to do so in this case since it tried to recompile the source file you modified.)

Qt5, MSVC2010 rebuilds every time, deletes *.obj on “DLL-link-fail”

I use QMake to gen *.vcproj (from *.pro) to create DLLs that expose C++ classes to QML (Qt5.0.1/MSVC2010). The DLLs work.
However, I have two problems (they might be related):
When I "build", it ALWAYS recompiles everything in the DLL. (It's never "up-to-date".)
If I get a "link-fail" (for example, some input lib doesn't have a needed-function defined), MSVC will delete all the *.obj and other intermediate files, requiring the next build to (unnecessarily) rebuild those intermediates. (The "link-success" will LEAVE the intermediate *.obj files, but the next build will force them to be regenerated anyway.) This means I can never do a "Project Only => Link Only" when I fix an "input-static-lib".
Both of these seem weird. And, they make me sad.
Note that since I "regenerate" the .vcproj each time, there are no "files-in-the-project" that do not exist on disk (which others observe as a cause to always-trigger-rebuild).
I've already tried the "silly-stuff" like re-installing service packs, clean builds, manually removing all intermediates/artifacts, reboot, etc.
From web searches (lots of reading for weeks to get around this), this might be related to:
Each DLL has its own directory for its "intermedate-OBJs", but they all write to the same (shared-debug)-"output" folder for their .dll/.lib. (That should be fine, right?)
Failing a "proper-fix" (where MSVC realizes that things are up-to-date), is there a work-around where I can suppress the delete-intermediate-files so I can later force a mere "re-link", when I know that things should be fine? At present, I can't "Project Only => Link Only" because the intermediates get deleted. (How to stop MSVC from deleting the .obj files?)

How to create an EDE project for C++

I have been trying to set up an EDE project for C++ (emacs24 + builtin CEDET) and I'm starting to get desperate because I can't seem to find the way I want the makefiles to be generated. I'm relatively new to Emacs.
I'll try to describe what I'm doing:
I have a toy project set like so:
main.cpp
other/
Utils.cpp
Utils.h
CGrabBuffer.cpp
CGrabBuffer.h
main.cpp includes both .h's inside the "other/" directory. These are the steps I follow to set up an EDE project with this simple directory setup:
Open main.cpp in emacs and do M-x ede-new ; type: Make ; name: main-proj.
Open one of the files in the "other" directory and do M-x ede-new ; type: Make ; name: aux-proj.
Now it's time to create the targets (which I believe are three in this case):
On the main.cpp buffer: M-x ede-new-target ; name: main ; type: program. When prompted, I add the main.cpp to this target.
I repeat the same for the other two targets (Utils which has Utils.cpp and Utils.h and CGrabBuffer which has CGrabBuffer.cpp and CGrabBuffer.h). Here I find the first problem. What type do these two targets have to be? I only want them to generate .o files.
Once this is done, I type M-x ede-customize-current-target to all three targets and I add some include paths, some libraries, etc.
After this, if I call M-x ede-compile-project it doesn't compile because:
It tries to compile main.cpp first; I have no idea how to specify (using EDE) that both Utils.o and CGrabBuffer.o are needed before attempting to build main.cpp.
If I manually change the order (editing the Makefile), it's not able to link main.cpp because it can't find Utils.o and CGrabBuffer.o.
As you can see, I am in the middle of a great mess. Maybe I'm not even understanding what "target" means in EDE. I have also read about the existence of ede-cpp-root-project which has to be specified inside the .emacs file. I haven't tried it because what I think it does is just help with the semantics. It doesn't generate Makefiles, does it? Can I have (or do I need) an EDE project built with Project.el's and the same thing using ede-cpp-root-project for the semantics? Or is it redundant?
Sorry If I misunderstood a lot of things but I'm very confused and being new to emacs makes things worse. Thanks for your patience!
EDIT: with some tinkering and the responses I received I have been able to figure out a lot of stuff, so thanks a lot. What I still don't understand is the use of the ede-cpp-root-project which has to be specified inside the .emacs file. Is it just for c++ semantics? Is it redundant to have the project with Project.el's AND also the elisp lines in .emacs?
EDE is designed to handle many different kinds of projects, usually of a type where the build system was written outside of Emacs in some other tool.
The EDE project type that creates Makefiles for you can do quite a few things, but you need to have some basic understanding of build systems for it to be helpful, and you really do need to customize the projects to get anything of any complexity working.
I've recently added a section to the EDE manual to help with basic project setups that autogenerate Automake files. You can check out the tutorial here:
http://www.randomsample.de/cedetdocs/ede/ede/Quick-Start.html
The same steps will apply for projects that just use Make instead, but Make based projects often have trouble with shared libraries due to the extra complexity.
Mike's answer is quite good, but I think it is ok to just add .h files to the same target as your .cpp sources. It will keep track of them separately.
Another useful trick is to use the whole project compile keystroke (C-c . C) which uses a capital C whenever you change something big. That will regenerate the Makefiles, rerun any needed Automake features, and start at the top.
EDIT: You only need one EDE project for a give project area. The ede-cpp-root project is useful when no other automatic project type works. That's when you create that in your .emacs file so that the other tools that need a project definition, like semantic's smart completion, and tag lookup, will work.
Well, I think I actually have it figured out this time, but it's ugly. Utils.cpp and CGrabBuffer.cpp should not get their own individual targets, because there doesn't seem to be an appropriate target type. Instead, you'll need to create an archive or library, which will automatically compile Utils.cpp and CGrabBuffer.cpp for you. Below, I'll assume you want static, but it's easy to change.
[For anyone to whom archives or libraries are not familiar, they basically just gather up .o files into a separate unit. It doesn't actually make the compilation harder. Read more here.]
1) Follow the first two and a half steps above (including making the main target, but not the other targets).
2) Switch to Utils.cpp and do M-x ede-new-target ; name: aux ; type: archive. When prompted, add Utils.cpp to this target.
3) Switch to CGrabBuffer.cpp and do C-c . a ; Target: aux .
4) Regenerate the Makefile with M-x ede-proj-regenerate. At this point, if you run make in the other subdirectory, you should get the archive libaux.a.
5) Switch back to main.cpp and do M-x ede-customize-current-target. This brings up an interactive emacs customization buffer, which allows you to edit details of the ede configuration. Under the Ldflags section, click [INS]. This pops out a new line that says Link Flag: and has some different-colored box for you to type in (mine is grey). Type -Lother -laux, so that other/libaux.a is included when compiling main. Then, at the top of the buffer, press [Accept], which should save that change and switch back to main.cpp.
6) Regenerate the Makefile with M-x ede-proj-regenerate.
Now, unfortunately, the Makefile makes the main target first, then descends into the other directory and makes that. Unfortunately, this means that a make from the top-level directory will not work on a clean tree. I don't know why this is, because it seems like that would never be what you want in any project that is ever made with EDE. I can't find any way to change that, except for this hack:
7) Do M-x customize-project; under Inference-Rules click [INS]. Then enter Target: all ; Dependencies: aux main ; Rules: [INS] ; String #: . (This last one is just to prevent an error on an empty rule with a tab; presumably an EDE bug.) Click [Accept], and regenerate the Makefiles.
So now, in your top directory, you can just run make, and main should be a working executable.
I'm quickly becoming convinced that EDE is not yet ready to be used by people other than its authors. Despite its size and the amount of effort they've clearly put into it, it is too buggy, too counterintuitive, and just not smart enough. That's a shame. Emacs needs something like this.

Waf throwing errors on c++ builds

Our project contains a lot of c++ sources, up until now we were sing make to build everything, however this takes ages. So I stumbled upon waf, which works quite well and speeds up the build a lot. However everytime I do a full build I end up with a couple of build errors that make no sense. If I do an incremental build now, most of the time some of the sources that could not be build the first time around are build now, some others still fail. On another incremental build I will finally get a successful build.
I have tried building the separate libraries in separate steps, just in case any dependent libraries are attempted to build in parallel, but the errors still appear.
EDIT: The errors I keep getting do not seem to have anything to do with my code, e.g.
Build failed
-> task failed (exit status -1):
{task 10777520: c constr_SET.c -> constr_SET.c.1.o}
After another "waf build" I do not get this error anymore.
EDIT2: The build step for my libraries looks like this:
def build(bld):
bld.shlib(source="foo.cpp bar.cpp foobar.cpp constr_SET.c",
target="foobar",
includes= "../ifinc",
name="foobar",
use="MAIN RW HEADERS",
install_path = "lib/")
MAIN, RW, HEADERS are just some flags and external libraries we use.
Has anyone seen similar behaviour on their system? Or even a solution?
I'm suspecting multiple targets are building the same required object in parallel. Try
export JOBS=1
or
waf --jobs 1