bcachefs-tools
bcachefs-tools copied to clipboard
musl build failure: linux/sort.c:32:1: error: unknown type name '__attribute_const__'
Eagerly trying to build bcachefs-tools-1.6.4 on Gentoo musl/clang with musl 1.2.5 as #213 should be fixed when building against 1.2.5.
But now I run into another build failure:
[...]
clang-17 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Os -march=bdver2 -pipe -std=gnu11 -MMD -Wall -fPIC -Wno-pointer-sign -Wno-deprecated-declarations -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Ic_src -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=35 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"1.6.4"' -D__SANE_USERSPACE_TYPES__ -Wno-unused-but-set-variable -Wno-missing-braces -Wno-zero-length-array -Wno-shift-overflow -Wno-enum-conversion -Wno-gnu-variable-sized-type-not-at-end -I/usr/include/blkid -I/usr/include/uuid -c -o linux/siphash.o linux/siphash.c
[CC] linux/sort.o
clang-17 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Os -march=bdver2 -pipe -std=gnu11 -MMD -Wall -fPIC -Wno-pointer-sign -Wno-deprecated-declarations -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Ic_src -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=35 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"1.6.4"' -D__SANE_USERSPACE_TYPES__ -Wno-unused-but-set-variable -Wno-missing-braces -Wno-zero-length-array -Wno-shift-overflow -Wno-enum-conversion -Wno-gnu-variable-sized-type-not-at-end -I/usr/include/blkid -I/usr/include/uuid -c -o linux/sort.o linux/sort.c
linux/sort.c:32:1: error: unknown type name '__attribute_const__'
32 | __attribute_const__ __always_inline
| ^
linux/sort.c:183:1: error: unknown type name '__attribute_const__'
183 | __attribute_const__ __always_inline
| ^
linux/sort.c:183:21: error: 'inline' can only appear on functions
183 | __attribute_const__ __always_inline
| ^
/usr/include/linux/stddef.h:8:25: note: expanded from macro
'__always_inline'
8 | #define __always_inline __inline__
| ^
linux/sort.c:184:14: error: expected ';' after top level declarator
184 | static size_t parent(size_t i, unsigned int lsbit, size_t size)
| ^
| ;
linux/sort.c:271:8: error: call to undeclared function 'parent'; ISO C99
and later do not support implicit function declarations
[-Wimplicit-function-declaration]
271 | b = parent(b, lsbit, size);
| ^
5 errors generated.
make: *** [Makefile:173: linux/sort.o] Error 1
The error above is from Gentoos bcachefs-tools-1.6.4 ebuild but building bcachefs-tools from git-master also gives me:
[...]
# make
Makefile:113: skipping systemd integration
[CC] linux/sort.o
linux/sort.c:32:20: error: expected ';' before '__inline__'
32 | __attribute_const__ __always_inline
| ^
| ;
linux/sort.c:183:20: error: expected ';' before '__inline__'
183 | __attribute_const__ __always_inline
| ^
| ;
make: *** [Makefile:173: linux/sort.o] Error 1
https://lore.kernel.org/linux-bcachefs/[email protected]/
That doesn't look like it the right fix - we're already pulling in compiler.h via kernel.h, did anyone test that?
Are you referring to the futureproofing fixes? Since sort.c doesn't include kernel.h anywhere (even indirectly), I could drop those though and re-submit just the fix itself if that's preferred. Regarding testing, I tested both musl and glibc and both compiled fine with the patch.
Edit: After updating to musl-1.2.5-r1 on musl/llvm and compiling bcachefs-tools I no longer have this issue. Maybe OP can try compiling bcachefs-tools-1.7.0?
Keep in mind first you would have to include the following patch:
--- a/linux/sort.c
+++ b/linux/sort.c
@@ -15,6 +15,7 @@
#include <linux/types.h>
#include <linux/export.h>
#include <linux/sort.h>
+#include <linux/compiler.h>
/**
* is_aligned - is this pointer & size okay for word-wide copying?
After doing that you still get another compiler error which I have reported in #300 . But its at the linker stage so we are getting close.
Edit: After updating to musl-1.2.5-r1 on musl/llvm and compiling bcachefs-tools I no longer have this issue. Maybe OP can try compiling bcachefs-tools-1.7.0?
Keep in mind first you would have to include the following patch:
--- a/linux/sort.c +++ b/linux/sort.c @@ -15,6 +15,7 @@ #include <linux/types.h> #include <linux/export.h> #include <linux/sort.h> +#include <linux/compiler.h> /** * is_aligned - is this pointer & size okay for word-wide copying?
After doing that you still get another compiler error which I have reported in #300 . But its at the linker stage so we are getting close.
The patch I have stated above no longer needs to be used for versions >=1.9.0.
This bug can be closed as its now possible to compile bcachefs-tools-1.9.1
on gentoo by passing -C default-linker-libraries
after obtaining >=musl-1.2.5
.
@ray-adams Correct. I only hit #300 now.