tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Compiling NetBSD mtree in-tree with meson.build



Hi!

I would like to introduce what I have been hacking on yesterday evening and am looking for feedback if that is something this list’s group would be interested in being elaborated more in-depth.

I needed a recent build of `/usr/sbin/mtree` for use on my macOS, so I looked at the sources in the NetBSD tree and thought I would give it a go.

`build.sh tools` bailed on me, trying to compile in-tree gcc. As the complexity of build.sh was the usual overwhelming experience that is expected from an OS, I quickly decided I would cherry-pick mtree directly from the tree and build it without all the inert mass of `build.sh`.

I have decided to use meson.build (https://mesonbuild.com/) to define the build and use LLVM/Clang 19.1.6. To be able to look at native/cross differences, I have set-up meson to cross-compile to NetBSD with a sysroot from  release comp.tar.xz.

As the source tree is spotless clean, this was a pretty smooth ride
* bsdmake files can be almost technically converted to meson.build definitions as both carry intent
* tools/compat/configure.ac is a beast, but eventually I converted it to a 408 LOC meson.build definition
* for libutil (cross) I have implemented the on-demand build of byacc

So I got the build system up quite quickly and had a nice compile of `mtree` directly from the tree into a macOS binary.
Note that the cross build also worked quite well, so I could also build these tools cross to NetBSD target without any pain. Success is defined here for me as the compiler not barking, not the tool being run/tested.

I decided to further proof this setup with looking at `/usr/sbin/makefs`. This resulted in more meson.build files across the tree and eventually I failed as I sticked to my initial plan of not copy-filtering includes into place. This technique I considered un-mesonic. 

Takeaways:
* build.sh fails on macOS. If somebody has an idea on a quick fix, I am happy to try harder. I guess this is on-topic for this list.
* meson.build can replace autotools in tools/compat. I consider it a far better alternative than autotools. Happy to share my code.
** there is a quite ugly hack in configure.ac creating empty header files which I would recommend to refactor
* looking deeply at tools/compat I don’t really like the way it is structured and how it puts its compatibility layer in-place. Happy to discuss ideas. Here?
* meson.build can build the tree with some compromises.
** mimicking the bmake copying around of the header files, this would be instant success
** if you don’t like these headers to be copied around, then the includedir dependencies on TOPDIR/sys need to be carefully refactored at their uses (plenty).

So I have currently 44 meson.build files layering over the tree defining the build. If there is interest I am happy to share them. Here?

Looking forward to your feedback.

Cheers,

Keve



Home | Main Index | Thread Index | Old Index