Build mkfs.xfs using rules_cc
This drops the old big genrule for mkfs.xfs and replaces it with a nice rules_cc build system
with the help of bazel_cc_fix generated patches and our musl-based toolchain.
While we're at it I bumped the versions of all related dependencies to their latest stable release.
This also means pulling in ini.h which is a dependency of the new xfstools version.
Instructions to regenerate the patches are included in the spec files.
Toolchain selection is done by the existing transition in our rootfs rule so we automatically get a musl-built
static binary when building for the rootfs.
Test Plan: Tested with E2E tests, should fail fairly catastrophically if something were wrong.
X-Origin-Diff: phab/D708
GitOrigin-RevId: 648a05cdd08cfa84a8a9f4c057c52446e7005631
diff --git a/third_party/xfsprogs/cc_fix_spec.prototxt b/third_party/xfsprogs/cc_fix_spec.prototxt
new file mode 100644
index 0000000..ebc9ae0
--- /dev/null
+++ b/third_party/xfsprogs/cc_fix_spec.prototxt
@@ -0,0 +1,80 @@
+# proto-file: build/bazel_cc_fix/ccfixspec/ccfixspec.proto
+# proto-message: CCFixSpec
+
+# Note: As of 5.10 upstream doesn't build on any Linux distro I tried. You have to patch xfs.h to include its own headers
+# and not the system ones to get it to build. Revert this patch before running bazel_cc_fix as it interferes with the
+# auto-rewriting.
+
+# To regenerate the patch, run the following in the checked-out xfsprogs repo
+# make configure
+# ./configure
+# nice intercept-build make -j$(nproc) mkfs
+
+# And the following in the monorepo root
+# bazel run //build/bazel_cc_fix -- -workspace $path_to_repo -compilation_db $path_to_repo/compile_commands.json -spec third_party/xfsprogs/cc_fix_spec.prototxt
+
+# Resolve libuuid to our util_linux workspace
+replace {
+ type: SYSTEM
+ from: "uuid/uuid.h"
+ to: "libuuid/src/uuid.h"
+}
+
+# Resolve libblkid to our util_linux workspace
+replace {
+ type: SYSTEM
+ from: "blkid/blkid.h"
+ to: "blkid.h"
+}
+
+# Resolve libinih to our inih workspace
+replace {
+ type: SYSTEM
+ from: "ini.h"
+ to: "ini.h"
+}
+
+replace {
+ type: SYSTEM
+ from: "xfs/handle.h",
+ to: "include/handle.h",
+}
+
+# Force xfsprogs to use their own headers instead of the ones of the installed (!!) xfsprogs
+replace {
+ type: SYSTEM,
+ from: "xfs/xfs_fs.h",
+ to: "libxfs/xfs_fs.h"
+}
+replace {
+ type: SYSTEM,
+ from: "xfs/xfs_types.h",
+ to: "libxfs/xfs_types.h"
+}
+replace {
+ type: SYSTEM
+ from: "xfs/"
+ to: "include/"
+}
+
+# platform_defs.h is generated and cannot be placed in include/ as targets depend on random
+# things in there. Fix up all includes to instead point to the workspace root where it will be
+# generated.
+generated_file {
+ path: "include/platform_defs.h"
+}
+replace {
+ type: WORKSPACE
+ from: "include/platform_defs.h"
+ to: "platform_defs.h"
+}
+
+# Properly include CRC32 generated file which is also generated in the wrong place
+generated_file {
+ path: "libfrog/crc32table.h"
+}
+replace {
+ type: WORKSPACE
+ from: "libfrog/crc32table.h"
+ to: "crc32table.h"
+}
\ No newline at end of file