void-linux / runit

The init system for Void Linux.
https://voidlinux.org
169 stars 22 forks source link

Build system rewrite #23

Open 0x5c opened 1 year ago

0x5c commented 1 year ago

This has dramatic effects on the build system complexity, and in the process exposing lots of dead weight.

Split header files (.h1 .h2) are merged, and header files that only contained a single define have been fully replaced with -D. The makefile is no longer generating scripts, and their files that hardcoded cc/ld/ar calls are gone.

The build system is now fully compatible with standard variables like CC, PREFIX, DESTDIR, and such. The compiler is autodetected when unspecified, build flags are checked for compatibility, and installation directories can now be specified with configure flags.

The configure script was heavily inspired by XBPS's.

The "compile" script is gone along with the original top-level Makefile, both replaced with straightforward and more conventional makefiles. The "man" and "completions" subdirs are now integrated into the build system and use configure-time variables for the paths.

No sed calls or patches should be required to set any paths or toolchain settings.

Usage of .gitattributes and $Id$ strings is now replaced with a VERSION define in the configure script, which optionally uses git to append the 8-digit commit hash to the version string. This also makes -V more meaningful.

Multiple configure checks were removed, some were unused, while others required to be run on the host at build time and were not compatible with cross. This means we are now assuming C99 compiler and availability of poll(); both seem reasonable.

After ~17 years of being deprecated, excluded from builds, and de-documented, svwait{up,down} and runsv{ctrl,stat} were removed from the codebase.

Closes #11 Closes #12

Things left to do

Going further


Most of this was a learning experience, so I may have missed obvious things; feedback welcome.

About that complexity...

The makefile in src/ before The original makefile ... and after. The new makefile

.dots here. I recommend opening original.dot in an interactive dot viewer to better see the node relationships.

0x5c commented 1 year ago

Long term there's probably room to improve/modernise the tests.

Hum yeah, the mechanism is clunky and most of these don't seem very useful at all

0x5c commented 1 year ago

-std=c99 was added to the CFLAGS to get uint64_t, however this now means that many files generate -Wimplicit-function-declaration, only solved by the definition of _DEFAULT_SOURCE or _POSIX_SOURCE in those files.

Are the feature macros an ok solution? Should they be defined everywhere? Is there a flag that does it better? y understanding is that -std=c99 does deactivate some defaults, but it's not obvious to me if there's a flag to reactivate them.

nekopsykose commented 1 year ago

Should they be defined everywhere?

unless there's something you're gaining by selectively defining them (you would know; generally it's to selectively expose a different standard of a function in some places intentionally), yes, just -D global cflags.