third_party: slurp in edk2, kubernetes, mkfs.xfs
This finishes the move from core/build/* into third_party/.
While at first this might look like wasted bandwidth, this separation
will make much more sense in the future, where different parts (not only
the Smalltown core) might depend on shared external dependencies. In
addition, having everything in third_party laid out in a similar fashion
lends itself to writing more general rules. Already there is quite a bit
of deduplicaiton that we could remove for reliability and readability.
This does not fix the problem of the big honkin' genrule for mkfs.xfs -
while I think we should fix it sooner than later by building a real
toolchain, that time is not yet now. But at least we've moved things out
of the way so that we can then drop in a better mkfs.xfs, once it is
built so.
Test Plan: build file mangling, CI should cover this
X-Origin-Diff: phab/D391
GitOrigin-RevId: fb99c6a6270c5c6a56eeb4f18a41323ffebbc655
diff --git a/third_party/xfsprogs/BUILD b/third_party/xfsprogs/BUILD
new file mode 100644
index 0000000..51301b7
--- /dev/null
+++ b/third_party/xfsprogs/BUILD
@@ -0,0 +1,86 @@
+# TODO(leo): I have not been able to figure out a clever way of separating this
+# into multiple rules, particularly musl, which hardcodes sandbox paths into its
+# toolchain such that a different rule cannot consume it.
+#
+# For now, using a single massive genrule is the least annoying way to do this.
+# As soon as we build more than just mkfs.xfs, we should re-visit this.
+#
+# Some possibilities:
+#
+# - Build the musl toolchain in the build container and use native rules
+# for headers_install and util_linux (they should, in theory, generate
+# well-defined artifacts that we can use in the build).
+#
+# This would use Bazel's toolchain definition mechanism to consume the
+# external toolchain, and would be compatible with the native C rules.
+#
+# Maybe we can even build the external toolchain inside Bazel somehow?
+#
+# - Write a custom rule that handles the toolchain.
+#
+# - Converting *everything* to native rules is probably not an option due
+# to how complex the third party build systems we touch are.
+
+genrule(
+ name = "mkfs.extfs",
+ srcs = [
+ "@xfsprogs//:all",
+ "@musl//:all",
+ "@util_linux//:all",
+ "@linux//:all",
+ ],
+ outs = [
+ "mkfs.xfs",
+ ],
+ cmd = """
+ MUSL=$$PWD/$(RULEDIR)/musl_prefix
+
+ echo "Compiling and installing musl..."
+ (
+ cd external/musl
+ ./configure --prefix=$$MUSL --syslibdir=$$MUSL/lib
+ make -j $$(nproc) install
+ ) > /dev/null
+
+ echo "Installing Linux kernel headers..."
+ (
+ cd external/linux
+ make headers_install ARCH=x86_64 INSTALL_HDR_PATH=$$MUSL
+ ) > /dev/null
+
+ echo "Compiling util_linux..."
+ (
+ cd external/util_linux
+ ./autogen.sh
+ ./configure \
+ CC="$$MUSL/bin/musl-gcc" \
+ --without-systemd \
+ --without-udev \
+ --without-btrfs \
+ --disable-pylibmount \
+ --without-tinfo \
+ --prefix=$$MUSL \
+ --disable-makeinstall-chown \
+ --disable-makeinstall-setuid \
+ --with-bashcompletiondir=$$MUSL/usr/share/bash-completion
+ make -j $$(nproc) libuuid.la libblkid.la
+ echo "Installing util_linux..."
+ cp -v .libs/* $$MUSL/lib/
+ mkdir -p $$MUSL/include/{uuid,blkid}
+ cp libuuid/src/uuid.h $$MUSL/include/uuid/
+ cp libblkid/src/blkid.h $$MUSL/include/blkid/
+ ) > /dev/null
+
+ echo "Compiling mkfs.xfs..."
+ (
+ cd external/xfsprogs
+ make configure
+ ./configure CC="$$MUSL/bin/musl-gcc" CFLAGS="-static" --prefix=$$MUSL
+ echo COMPILERING
+ make mkfs -j8
+ ) > /dev/null
+
+ cp external/xfsprogs/mkfs/mkfs.xfs $(RULEDIR)
+ """,
+ visibility = ["//visibility:public"],
+)