4 ms·
autoconf is a typical GNU project. It looks like it would be horrible and crufty but when you make an effort to get to know it it is actually pretty sweet. Jus
by fefe23 6y ago
autoconf is a typical GNU project. It looks like it would be horrible and crufty but when you make an effort to get to know it it is actually pretty sweet.
Just a little example of how clever it is:
If you want to cross compile to a target, you can't actually run the test programs you compile. So it becomes important to make them fail at compile or link time, not at run-time. If the expression to be tested is constant at compile time, autoconf will compile a test program that uses the expression in the size of an array type. So, let's say you want to check if sizeof(int) is at least 4. Then autoconf would make a test program that declares something like
typedef char foo[1-(sizeof(int)<4)*2];
If sizeof(int) is less than 4, then the array size would become negative, and that produces a compile time error. No need to actually run the program.
That is the place where I learned about this pattern many years ago. I'm still grateful for autoconf for teaching me that. This is how you did compile time assertions in C before C introduced _Static_assert.
Also note that autoconf has lots of other awesome features if you would like to learn about them. For example it can be configured to have a system-wide cache for test results, which speeds up future runs.
But the most important part of autoconf to me is that it is dependably configurable. On my system, I have both /usr/lib and /usr/lib64 so I can develop for both 32-bit and 64-bit worlds at the same time. Run configure with --libdir=/usr/lib64 and you are good to go. There is no single way to reliably do this with cmake. Among the conventions, -DLIB_SUFFIX=64 has apparently crystallized out as de-facto standard, but you can't rely on it. For LLVM you have to set LLVM_LIBDIR_SUFFIX instead.
Or let's say you want cmake to also look for include files in /usr/X11R7/include and for library files in /usr/X11R7/lib64. Good luck with that!
I'm not trying to say that cmake is bad. It is a good solution for what it is trying to achieve. But automake had higher goals and also achieved them.
But I think cmake vs autoconf is a false dichotomy. cmake is not the enemy here, and neither is autoconf.
I'm actually more disappointed in the hubris of all the people deciding they can make better build systems than automake or cmake and then roll their own, but consistently fail in situations that other people already encountered, thought about, and solved. We now have autoconf, cmake, jam, bjam (Boost), qmake (Qt), meson, waf, python and perl have their own stuff, everybody believes they need to ram a package manager down my throat as well.
To me, life time is the only resource that actually matters.
For every 5 minutes you think saved by not going autoconf, you made your "build from source" users waste 50 minutes per person to get your build scripts to work.
- jcranmer 6y ago> This is how you did compile time assertions in C before C introduced _Static_assert. That's the biggest issue with autoconf... it tends to spend a lot of time basically asking the question "are you some weird Unix from 1997?" that no one actually cares about the answer to, because people don't take the time to curate their build systems. At its core task of figuring out how to compile and install properly on a system, autotools can do a surprisingly bad job. One of its most frustrating habits is dropping flags from the linker invocation ("I don't know what -flto does, but I'll drop it from the linker even though the user explicitly told me to link with it because unknown flags tend to bad for the linker"). Yes, build systems are a complicated three-way tussle between the system, the developer, and the user, and we've done a very bad job as a community at finding good tools to mediate this tug-of-war.
- fefe23 6y agoYOU may not care about old crappy systems, but you'd be surprised how much cruft is still in use in large organisations. And I for one am glad GNU went through all the trouble to make their code work on non-standard environments, because it means that I can use GNU stuff to bootstrap a non-crufty userland on those systems. About the LTO stuff: Maybe you did it wrong? I just tried to reproduce your problem by downloading GNU coreutils and running configure like this: $ LDFLAGS=-flto CFLAGS="-Os -flto" ./configure it definitely passes -flto to the compiler. I can't get to the linking stage because binutils is missing a plugin. Probably something wrong with my gcc setup. But autoconf is not removing -flto. BTW: About non-standard environments: Go ask among your friends for people who do embedded systems development, and let them show you their environment. You'd be surprised.
- jcranmer 6y agoSupport for -flto was added in libtool about the time I was working with this (I want to say 2012 or 2013), which also means you get to run into the fun situation where it's fixed in the upstream codebase, but the repository you're working with has a checked-in stale version of it.