Currently there is not a __attribute_const__ defined anywhere in linux/sort.c, which results in compilation failure on musl libc systems. The compiler also does not necessarily guarantee the macro and has only worked on glibc because of possible leakage from the header, sys/cdefs.h, which just happened to define __attribute_const__ in the same way that bcachefs-tools defines it. linux/compiler.h has also been included in files that use __attribute_const__ or __always_inline without explicit including for futureproofing.
This was narrowed down as the cause by noting that linux/compiler.h is not included anywhere in linux/sort.c, yet it was compiling successfully on glibc. Then, the preprocessor definitions were printed out using the gcc args: -E -dM. To view the difference, the command: $ gcc -I./include -E -dM linux/sort.c on glibc and musl systems will reveal the discrepancy. Expected output: #define __attribute_const__ __attribute__ ((__const__)) On musl there is no output. Closes: https://github.com/koverstreet/bcachefs-tools/issues/248 Signed-off-by: Christopher Fore <csf...@posteo.net> --- libbcachefs/bkey.h | 1 + libbcachefs/bset.c | 1 + libbcachefs/btree_iter.h | 1 + libbcachefs/eytzinger.c | 1 + libbcachefs/fs-io-direct.c | 1 + libbcachefs/six.c | 1 + libbcachefs/str_hash.h | 1 + libbcachefs/subvolume.c | 1 + linux/mempool.c | 1 + linux/sort.c | 1 + 10 files changed, 10 insertions(+) diff --git a/libbcachefs/bkey.h b/libbcachefs/bkey.h index 3a45d12..d30d501 100644 --- a/libbcachefs/bkey.h +++ b/libbcachefs/bkey.h @@ -3,6 +3,7 @@ #define _BCACHEFS_BKEY_H #include <linux/bug.h> +#include <linux/compiler.h> #include "bcachefs_format.h" #include "bkey_types.h" #include "btree_types.h" diff --git a/libbcachefs/bset.c b/libbcachefs/bset.c index 3bb4778..7d6b57f 100644 --- a/libbcachefs/bset.c +++ b/libbcachefs/bset.c @@ -17,6 +17,7 @@ #include <linux/console.h> #include <linux/random.h> #include <linux/prefetch.h> +#include <linux/compiler.h> static inline void __bch2_btree_node_iter_advance(struct btree_node_iter *, struct btree *); diff --git a/libbcachefs/btree_iter.h b/libbcachefs/btree_iter.h index 1c70836..c4376c7 100644 --- a/libbcachefs/btree_iter.h +++ b/libbcachefs/btree_iter.h @@ -2,6 +2,7 @@ #ifndef _BCACHEFS_BTREE_ITER_H #define _BCACHEFS_BTREE_ITER_H +#include <linux/compiler.h> #include "bset.h" #include "btree_types.h" #include "trace.h" diff --git a/libbcachefs/eytzinger.c b/libbcachefs/eytzinger.c index 0f955c3..49c2069 100644 --- a/libbcachefs/eytzinger.c +++ b/libbcachefs/eytzinger.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 +#include <linux/compiler.h> #include "eytzinger.h" /** diff --git a/libbcachefs/fs-io-direct.c b/libbcachefs/fs-io-direct.c index b889370..e6598f0 100644 --- a/libbcachefs/fs-io-direct.c +++ b/libbcachefs/fs-io-direct.c @@ -14,6 +14,7 @@ #include <linux/pagemap.h> #include <linux/prefetch.h> #include <linux/task_io_accounting_ops.h> +#include <linux/compiler.h> /* O_DIRECT reads */ diff --git a/libbcachefs/six.c b/libbcachefs/six.c index 3a494c5..a99f365 100644 --- a/libbcachefs/six.c +++ b/libbcachefs/six.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 +#include <linux/compiler.h> #include <linux/export.h> #include <linux/log2.h> #include <linux/percpu.h> diff --git a/libbcachefs/str_hash.h b/libbcachefs/str_hash.h index 3976f80..ed467d9 100644 --- a/libbcachefs/str_hash.h +++ b/libbcachefs/str_hash.h @@ -12,6 +12,7 @@ #include "super.h" #include <linux/crc32c.h> +#include <linux/compiler.h> #include <crypto/hash.h> #include <crypto/sha2.h> diff --git a/libbcachefs/subvolume.c b/libbcachefs/subvolume.c index 88a79c8..8312d96 100644 --- a/libbcachefs/subvolume.c +++ b/libbcachefs/subvolume.c @@ -10,6 +10,7 @@ #include "subvolume.h" #include <linux/random.h> +#include <linux/compiler.h> static int bch2_subvolume_delete(struct btree_trans *, u32); diff --git a/linux/mempool.c b/linux/mempool.c index 74ed17b..5b71f77 100644 --- a/linux/mempool.c +++ b/linux/mempool.c @@ -18,6 +18,7 @@ #include <linux/mempool.h> #include <linux/mempool.h> #include <linux/sched.h> +#include <linux/compiler.h> #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB_DEBUG_ON) static void poison_error(mempool_t *pool, void *element, size_t size, diff --git a/linux/sort.c b/linux/sort.c index ecce71c..3d4ee41 100644 --- 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? -- 2.44.0