mirror_zfs/include
Rob Norris 96f382d113
spl/thread: explicitly define thread_func_t as noreturn
All of our thread entry functions have this signature:

    void (*)(void*) __attribute__((noreturn))

The low-level `__thread_create()` function accepts a `thread_func_t` as
the entry point, which is defined more simply as:

    void (*)(void *)

And then the `thread_create()` and `thread_create_named()` macros cast
the passed-in function point down to `thread_func_t`, that is, casting
away the `noreturn` attribute.

Clang considers casting between these two types to be invalid because
both the caller and the callee may have elided parts of the stack frame
save and restore, knowing that they won't be needed.

Recent Linux appears to be setting `-Wcast-function-type-strict`, which
causes this invalid cast to emit a warning, which with `-Werror` is
converted to an error, breaking the build.

This commit fixes this in the simplest possible way: adding `noreturn`
to the `thread_func_t` attribute. Since all our thread entry functions
already have this attribute, it's arguably a just a consistency fix
anyway.

I considered removing the casts in the macros, which silences the
warnings, but it turns out that Clang has a bug that won't emit this
error for implicit conversions, only explicit casts. So leaving them
there seems like a reasonable belt-and-suspenders approach. Also,
frankly, this whole mechanism seems a little undercooked inside LLVM, so
I'm content go with my intuition about the smallest, least invaisve
change.

**NOTE**: `__thread_create` is exported by `spl.ko` and has a
`thread_func_t` arg, so this is an ABI break. Whether that matters in
practice, I have no idea.

Further reading:
- 1aad641c79
- https://github.com/llvm/llvm-project/issues/7325
- https://github.com/llvm/llvm-project/issues/41465

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #16672 
Closes #16673
2024-10-21 11:38:30 -07:00
..
os spl/thread: explicitly define thread_func_t as noreturn 2024-10-21 11:38:30 -07:00
sys Always validate checksums for Direct I/O reads 2024-10-09 12:28:08 -07:00
.gitignore OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
cityhash.h zcommon: add specialized versions of cityhash4 2024-09-19 15:18:59 -07:00
libnvpair.h nvpair: Constify string functions 2023-03-14 15:25:50 -07:00
libuutil_common.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
libuutil_impl.h libuutil: deobfuscate internal pointers 2022-11-03 09:57:05 -07:00
libuutil.h Cleanup: Remove unused uu_pname code 2022-09-19 17:33:52 -07:00
libzdb.h libzdb: Initial breakout of libzdb 2024-02-05 10:00:41 -08:00
libzfs_core.h Add DDT prune command 2024-09-04 14:17:02 -07:00
libzfs.h Add DDT prune command 2024-09-04 14:17:02 -07:00
libzfsbootenv.h lib{efi,avl,share,tpool,zfs_core,zfsbootenv,zutil}: -fvisibility=hidden 2021-06-09 17:04:32 -07:00
libzutil.h Fallback to strerror() when strerror_l() isn't available 2024-10-12 13:48:56 -07:00
Makefile.am value strings: pretty printers for flags and enums 2024-09-05 13:40:05 -07:00
thread_pool.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfeature_common.h feature: large_microzap 2024-10-02 20:47:11 -07:00
zfs_comutil.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs_deleg.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs_fletcher.h Drop lying to the compiler in the fletcher4 code 2023-03-24 10:29:19 -07:00
zfs_namecheck.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs_prop.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs_valstr.h value strings: pretty printers for flags and enums 2024-09-05 13:40:05 -07:00