in reply to Re: 'bld' project - signature(SHA1) based replacement for 'make'
in thread 'bld' project - signature(SHA1) based replacement for 'make'
This is an extensive post. I'll reply in detail, however, I want to formulate a considered reply. Maybe within a week or so. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: 'bld' project - signature(SHA1) based replacement for 'make'
by afoken (Chancellor) on Sep 05, 2014 at 06:20 UTC | |
I'll reply in detail, however, I want to formulate a considered reply. Sounds good. Meanwhile, let me "think loud" when and why make can go wrong and how to fix that. Make (in general, all variants) uses timestamps provided by the operating system and the file system to decide if a rule has to run or not. Rules run only once for each target during a single run of make, so make keeps an internal state, too. This state is obviously initially build from the timestamps. Timestamps in the future may be caused by system clock manipulation. This happens, for example, when you damage your Slackware system, boot from the install CD/DVD, and chroot to your real system to rebuild the kernel using make. The Slackware installer manipulates the system clock (but not the hardware clock) to work around some problems with time zones, so you virtually travel in time. The same problem may happen when root changes the system time back manually while make runs. GNU make detects both and warns ("File '%s' has modification time %d s in the future"). It could, perhaps should, be more paranoid and abort instead, because it is likely that your build is incomplete. Clock skew may happen when you use network filesystems (especially NFS) without tightly synchronising system clocks of client and server. The server sets the timestamps, using its system clock, but make on the client compares the timestamps using the client's system clock. That clock may have a very different idea of the current time, it may even jitter around the server's clock, so the freshly generated target may have a timestamp earlier than its source files. Again, it may also happen when root messes with the system clock. GNU make detects this and warns ("Clock skew detected"). Again, it could and perhaps should be more paranoid and abort, because again it is likely that your build is incomplete. These two problems are the most common problems with make using timestamps, but there are other ways to create wrong timestamps. FAT filesystems allow only a two-second-resolution of filestamps (you get only even values for seconds. So, your target may have the same timestamp as its source. But this should be no problem, you can get essentially the same problem because stat returns timestamps with only second resolution. Make only rebuilds when the target is older, i.e. timestamp of target is less than timestamp of source. But FAT stores local time, not universal time, so when you change the timezone, the FAT timestamps move back or forward in time. No problem: The ntp deamon manipulates the system clock so it agrees with the reference clocks, perhaps even while you run make. If ntpd was implemented stupidly, the system clock would wildly jump around, especially if the system clock was off by several seconds or even minutes or hours. But ntpd is smart, it slows down or accelerates the system clock just a little bit at a time, so it smoothly aproaches the reference clocks' time. Generally, systems allow ntpd a single big adjustment of the system time during system boot to compensate cheap battery buffered real-time clocks that tend to run too slow or too fast. Imagine a system without a battery-buffered realtime clock, like the old home computers or embedded systems. You boot the system, the system clock starts at some arbitary point in time (often with timer count = 0 or build date), and starts counting up, completely independant from any reference clock. No problem until you reboot. "Groundhog Day". Instant "timestamp in the future" problems. If the system has network access, start ntpd (or ntpdate) during boot. If the system is not networked (or just has no access to a reference clock), just make sure the system remembers the last count of its system clock across a reboot. This may be implemented as simply as touching a file once a second (or once a minute) as long as the system runs, and adjusting the system clock to the timestamp of that file during boot. Or, equally, by storing the timestamp in some kind of persistant storage (EEPROM, Flash, battery buffered RAM, ...) every minute or second, or at least in the shutdown script, and reading that value back during boot. In summary, make sure that the system clock is synchronised with the reference clocks, and keeps counting upwards with no jumps. This will not only help make, but all other programs that rely on timestamps. Most times, the easiest solution is to start ntpd during boot, allowing a single big adjustment during startup of ntpd. If you run on an isolated network, point to one arbitary machine and declare it holding the reference clock for that network. Serve time via NTP from that machine. Don't mess with its clock or timezone at all. If you have the resources, add a clock signal receiver to that machine (GPS or local radio like WWV, DCF77). Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-) | [reply] |
by rahogaboom (Novice) on Nov 15, 2014 at 19:24 UTC | |
Why did I start this project? Over many years I have used make to build many projects. My experiences with setting up a makefile system and my observations of already constructed makefile systems caused my realization that a great deal more effort was being used in setting up and maintaining these build systems then was necessary. I felt that with the use of one of the modern scripting languages - Perl, Python, Ruby - and a simplified design and incorporated automatic header file dependency checking that the whole process could be improved. I knew and liked Perl; so I used it. Perl is pretty much everywhere. You don't even need it to be installed in the system directories; perlbrew can be used to install to a local user directory. The major design goal was simplicity; complexity is the enemy. The existence of many other variations of make indicates to me that others as well were unsatisfied with many aspects of make and wanted to provide solutions. These all seemed, however, like band-aids on top of band-aids, never getting at the core of the problem. The current state of the project can handle C/C++/Objective C/Objective C++/ASM. I haven't tried to reproduce everything that make does in every instance. Simplicity is the goal; the ability to easily build Bld files for a single target or several Bld files for complex multi-target projects. The Bld files have a very simple syntax; a comment section - an EVAL section that requires 6 perl variables to be defined - a DIRS section with 'R dir:regex:{cmds}' or '{cmds}' specifications. I have succeeded in fully rebuilding the git, svn and systemd projects with this design without modifying in any way the directory structure of these projects. At present I have not attempted to incorporate Java or any other languages.
Signatures:
The perl standard module Digest::SHA provides sha1_hex() which is fast enough to fully rebuild complex projects like git, svn and
Signatures are portable; dates are not.
One of my goals in the use of signatures was security. At each step and for all file types a signature is calculated. Any attacker
A reply to the numbered items:
1. Why use signatures is explained above.
2. The assertion that make is simple to use is astonishing. Look at the GNU tools to automatically generate Makefiles. Why do this if http://www.scons.org/wiki/FromMakeToScons(Adrian Neagu)
I've seen many a Makefile that is so complex as to be unintelligible and that when modified has broken the build and requires a detailed
To quote Adrain Neagu(see link above):
"Difficult debugging
The inference process of Make may be elegant but its trace and debug features are dating back to the Stone Age. Most clones improved on that.
How rules are preferred when more than one rule can build the same target.
While not completely impossible, Make-based builds are tedious to track and debug. By way of consequence, Make-file authors will continue to
3. Yes, being non-recursive is an advantage. See the following article "Recursive Make Considered Harmful" by Peter Miller at
bld handles directories with the Bld file 'R dir:regex:{cmds}' specification. Use any number of these specifications. The R indicates
4. I designed bld to take signatures of source, objects and build cmds all the time. You assert that make can also do this by adding
5. See above about signatures. With a 160 bit signature collisions are unlikely in the extreme. Also, duplicate files are not necessarily a
6. Again, by just setting the $opt_lib Bld file variable to "warnlibcheck" you get full library file signature checking. bld does not
7. Security is one of the bld goals. I want to take and store(in Bld.sig) the signature of anything that may be tampered with. The
8. No, you don't need all those files just to compile 'a few files'. If you want to build a single target you only need the Bld file. All
The Notes comments:
1. I have no comments on this one. It's not a critique of anything.
2. The bld restriction that multi-target projects have targets that have unique names and the deposition of all targets into a single directory
3. I think you are confused about the difference between the project source directories and the project results directory. For all three
4. First, I have only used/tested bld with C/C++/Objective C/Objective C++. I have never tried Java and Perl is not compiled anyway.
Some other problems:
a. The ability of bld to save the signatures of all source, objects, build cmds, targets and dynamically linked libraries is all that is
b. The use of the system() perl call is in the bld code. There are two common ways to execute external cmds in perl; `` - backtics and
c. There are other tools that do not use built in rules - see PBS on cpan.org. The bld Bld file DIRS section 'R dir:regex:{cmds}' construct
R bld.example/example/C/y : ^.*\.c$ : {ls;$CC -c $INCLUDE $s;ls;} # Note: the {} may hold any number of ';' separated cmds
doesn't seem to me an excessive burden to compile all *.c files recursively from the bld.example/example/C/y directory.
d. The whole purpose of using Perl was to take advantage of the power the one of the modern scripting languages. Perl is everywhere. Also,
Lastly:
2. Try it!: I suspect that, in fact, you have not actually tried bld. Download bld, install the experimental.pm module, cd to the bld directory and
3. Security: The only way to maintain security for the entire bld process is to use signatures for every source, intermediate file, target and
4. The Linux kernel: I'd like to re-bld the Linux kernel. I used git, svn and systemd first because these were complex projects with many targets. | [reply] |
by roboticus (Chancellor) on Nov 15, 2014 at 19:42 UTC | |
Update: Thanks, that's *much* easier to read! I've read the dialog between you and afoken and found it interesting. I haven't downloaded the code yet and given it a try, yet, but I'll try to do so soon. I tend to agree with afoken in that make isn't really that difficult to use (though I tend to disable all the built-in rules and just build what I want by hand). But I like the idea of using hashes to detect changes, too, so it might be interesting. I can't promise to try it any time soon (as I'm swamped at $work right now), but if I do give it a go, I'll try to update my post to let you know what I think. I never thought I'd ask someone to remove code tags from a post, but there's a first time for everything, I guess.... ...roboticus When your only tool is a hammer, all problems look like your thumb. | [reply] |
by rahogaboom (Novice) on Mar 02, 2015 at 19:13 UTC | |
bld-1.0.6.tar.gz - changes related to: a. fixes for two gcc warnings in the example code(rdx and daa) b. use 'print STDERR' for all prints - more immediate output c. doc updates | [reply] |