News for hackers. Stuff that matters.
Re:Why Not Make? by xyzzy_plugh on Thursday November 08, 2018 @07:23AM (#18405764)
TFA makes a bunch of claims about the functionality of make being bad or dangerous but doesn't really provide any backing scenarios to demonstrate why. E.g. where timestamps can bite you, how you can miss compiler flag changes, etc.

Without this, it reads as FUD.

Re:Why Not Make? by bhoessen on Thursday November 08, 2018 @07:59AM (#18405917)
The scenarios can be the following: timestamp are problem as soon as a drive is mapped from two different os without synced clock (happened to me with a virtualbox share). Taking care of compiler flags is important as you don't want to mix a debug build with a performance build for binary compatibility reasons.
Re:Why Not Make? by dfgdghdf on Thursday November 08, 2018 @08:40AM (#18406129)
Compiler flag changes might happen due to debug/release configurations.

Compiler (and standard library) might be changed to do testing with multiple compilers (very common use-case).

Often Makefiles are not written with these two cases in mind, forcing a "clean" between changes.

Re:Why Not Make? by zeroxfe on Thursday November 08, 2018 @07:57AM (#18405912)
Not sure if you read the whole thing, but it seemed to me like it made pretty good points.

From the article: "In determining when to rebuild, Make uses the timestamps of build inputs rather than their hashes. This results in many unnecessary rebuilds when a file has been touched, but has not actually changed. If this happens deep in the dependency tree, then the rebuild will take a long time!"

That's kinda clear to me -- why would this read as FUD?

Re:Why Not Make? by yetihehe on Thursday November 08, 2018 @08:31AM (#18406090)
> why would this read as FUD?

From article:

> Since You’re Here > We recently announced BuildInfer, a new tool to optimize your C/C++ build scripts. Take a look!

Re:Why Not Make? by rusk on Thursday November 08, 2018 @08:27AM (#18406069)
Make compares timestamp of object-file with source-file amiright? This is nice and cheap and stateless. Do modern build-systems maintain a separate tree of hashes? I haven't seen this in my day-to-day but I don't tend to work on the bleeding edge ... I'd have thought the cost of calculating hashes for trivial source-files would be maybe only an order of magnitude cheaper than compiling one? Over a large source-tree I'd expect these costs to mount - I think I'd prefer to take my chance with timestamps!
Re:Why Not Make? by dfgdghdf on Thursday November 08, 2018 @08:37AM (#18406114)
Modern build systems (Buck, Bazel, Pants, etc) will compute a tree of hashes and manage it for you. They will also do this in the background (e.g. using Watchman). This is how Google, Facebook, Uber, Amazon etc. build their code, so the approach scales well.
Re:Why Not Make? by rusk on Thursday November 08, 2018 @08:50AM (#18406193)
So what I guess is that this is for building at scale?

In my experience this kind of incremental build is a matter of developer convenience so that small changes can be made and checked quickly, but builds for test and release are always built clean.

I guess the codebases we're talking about here are at such a scale that the incremental approach is actually used for releases too?

It still seems to me as though this is something that s should be solved architecturally though with an appropriate composition of modules ...

Re:Why Not Make? by tom_ on Thursday November 08, 2018 @09:12AM (#18406325)
It's for your day-to-day builds, so when you switch between build types while working you don't have to suffer a full rebuild.
Re:Why Not Make? by rusk on Thursday November 08, 2018 @09:18AM (#18406381)
by build-types you mean release to test vs. build for my own work? All my code gets released off a build server, and I'd consider it bad practice for a developer to be releasing their own code from their own workspace ...
Re:Why Not Make? by tom_ on Thursday November 08, 2018 @09:59AM (#18406628)
Same build, sure, but you don't release it - you just run it on your own computer, as opposed to the development build you might ordinarily run, to make sure you didn't break anything.
Re:Why Not Make? by rusk on Thursday November 08, 2018 @10:35AM (#18406954)
I still can't help but feel this could be obviated by a more top-down approach, like decomposing into modules.

Even with a well-specified dependency tree there are areas where an incremental build can still bite you in the ass. Things like inlining and transitive dependencies ... I think you still need to build from scratch to be sure.

Re:Why Not Make? by dfgdghdf on Thursday November 08, 2018 @09:11AM (#18406320)
If your choices are:

- A: Builds well for small projects, scales poorly for large projects

- B: Builds well for small projects and scales well for large projects

Why not choose B?

Re:Why Not Make? by rusk on Thursday November 08, 2018 @09:16AM (#18406365)
I'd always choose B given a green field, but it's when you already have A that you have to justify the effort to migrate ...

EDIT my proposition is that the described build system actually scales poorly for large projects, because you've to maintain an entire tree of hashes! Notwithstanding of course having a helper process in the background to do this for me ...

Re:Why Not Make? by dfgdghdf on Thursday November 08, 2018 @09:34AM (#18406469)
Ah, I see your point now. However, in practice this is not the case. These hash-based systems scale very well in large organizations. Some more info from Google about Bazel: https://qconsf.com/sf2010/dl/qcon-sanfran-2010/slides/Ashish...
Re:Why Not Make? by rusk on Thursday November 08, 2018 @09:52AM (#18406578)
Very interesting ...

Two bullet points jumped out at me straightway:

- Single monolithic code tree with mixed language code

- Development on head; all releases from source

Just one other concern I have now.

Something like Make, or most other build-systems run pretty much straight out of the box.

Something like Bazel lets say is apparently an order of magnitude more complicated. There's a few more moving parts.

My only remaining qualm relates to the additional cognitive load of this stuff. At scale, as in Google this isn't so much a problem because these costs would diminish at the point where you can actually assign people to look after it.

I really like the idea though! Would be nice to work in a place like Google some day ...

Re:Why Not Make? by jcelerier on Thursday November 08, 2018 @09:02AM (#18406266)
> Over a large source-tree I'd expect these costs to mount - I think I'd prefer to take my chance with timestamps!

timestamps really sucks when e.g. you change header $foo which is used by a lot of your software (say, a basic data structure, or the definition of a 3d point), build (which rebuilds everything because of time stamps), do a git pull --rebase, so git undoes your changes, applies the remote commits, and redoes your change, and so you re-have to build everything again even though the header that was used everywhere has not actually changed

Re:Why Not Make? by rusk on Thursday November 08, 2018 @09:16AM (#18406354)
I'd actually expect and desire a full rebuild in the case that a widely used header is changed.

After a rebase it makes sense too, but I see what you mean about where no actual changes have been made though ... dare I suggest this sounds more like a bug in git though ...

Re:Why Not Make? by jcelerier on Thursday November 08, 2018 @10:08AM (#18406710)
> I'd actually expect and desire a full rebuild in the case that a widely used header is changed.

yes, me too, but in this case the rebuild happens twice while the header changes only once (from the point of view of the programmer of course, from the point of view of the filesystem it changes twice). If hashes were used this would not be a problem at all.

Re:Why Not Make? by rusk on Thursday November 08, 2018 @10:21AM (#18406828)
I don't understand your point, how does this happen twi ... ohhh because dependent files get changed as well? Surely this is just a matter of how you specify your dependencies?
Re:Why Not Make? by jcelerier on Thursday November 08, 2018 @11:17AM (#18407296)
imagine your project structure is the following :

    header.h
    src1.cpp
    src2.cpp
    src3.cpp
you do the following :

1. change header.h

2. rebuild. this rebuilds all your .cpp because they all use the header - this is fine and expected.

3. git pull --rebase because your coworker fixed a bug in src1.cpp which landed in the master branch

4. here when you rebuild with make, even though only src1.cpp has changed from your point of view, everything actually gets rebuilt because git stashes your change, applies the remote commits and unstashes your change, so header.h's timestamp gets changed again.

Re:Why Not Make? by rusk on Thursday November 08, 2018 @11:43AM (#18407569)
oh right yeah - this is the thing I was saying could probably be considered an issue with git.
Re:Why Not Make? by yetihehe on Thursday November 08, 2018 @08:35AM (#18406107)
Typical optimisation in such cases is to check file hash only when file timestamp or size changes. If after timestamp change hash is the same, it means file was not modified.
Re:Why Not Make? by rusk on Thursday November 08, 2018 @08:37AM (#18406115)
Okay that's half the problem. Where do I keep my database of hashes though?

W̶h̶i̶c̶h̶ ̶b̶u̶i̶l̶d̶ ̶s̶y̶s̶t̶e̶m̶s̶ ̶a̶c̶t̶u̶a̶l̶l̶y̶ ̶d̶o̶ ̶t̶h̶i̶s̶?̶ [answered by sibling comment]

Re:Why Not Make? by xyzzy_plugh on Thursday November 08, 2018 @08:28AM (#18406075)
Your sibling poster points out a great scenario that can trigger this: mounting shared/externally modified filesystems. Just saying "timestamps are bad and can cause inefficient builds" isn't compelling in itself.

For the record I definitely understand what the author is trying to point out, but I think they could be much more convincing.

Re:Why Not Make? by ams6110 on Thursday November 08, 2018 @08:48AM (#18406186)
Since the wide adoption of distributed version control systems (e.g. git), how many shops are still working on code on a shared filesystem being edited by multiple developers?

I'd think the far more usual case is each dev has a copy of the code on his/her own machine, and another copy is on a build/test machine. There won't be any timestamp issues there.

Make is like a lot of tools, it's simple and works well, up to a point. If your project complexity exceeds its abilities, you likely can afford something more sophisticated, since you probably have dozens or hundreds of developers anyway.

Re:Why Not Make? by maccard on Thursday November 08, 2018 @08:56AM (#18406230)
I had a shared drive on virtualbox where I had the problem of the clocks not being in sync. There is also the fact that some other tools aren't necessarily well behaved and will dirty files, causing spurious rebuilds.

For the most part though, you're right!