On 2024-07-21 Jonathan Corbet wrote: > I spent a little while trying to figure out why we need XZ_EXTERN at > all but lost in the #includes... This is a good question. I looked at it and now I think that it's not actually needed. Thus, this patch to Documentation/conf.py should be dropped from this series, and I will submit a new patch to remove XZ_EXTERN. Preboot code on several archs has "#define STATIC static", for example: arch/x86/boot/compressed/misc.c arch/arm/boot/compressed/decompress.c arch/mips/boot/compressed/decompress.c drivers/firmware/efi/libstub/zboot.c These files #include one of lib/decompress_*.c files. The STATIC macro is used to detect if the code is being built for preboot code instead of initramfs decompression. The STATIC macro is also used to make a few functions static in lib/decompress_*.c files (and also in lib/inflate.c). Note that even if STATIC isn't initially defined, the lib/decompress_*.c files have #include <linux/decompress/mm.h> which will then "#define STATIC" (empty value). lib/decompress_unxz.c makes all XZ functions static in preboot code via the XZ_EXTERN macro. I'm not sure why I have done so. The commit message from 2009 in my upstream tree isn't very specific. STATIC is used also in lib/inflate.c to make functions static. However, that file *seems* to be used only on alpha and nios2; it's *not* used by lib/decompress_inflate.c which uses lib/zlib_inflate/inflate.c with its extern functions in preboot code. But lib/inflate.c might have made me think that there's a need to make functions static in some cases. lib/decompress_unzstd.c is newer. It doesn't attempt to make all functions static in preboot use. Omitting XZ_EXTERN doesn't produce any warnings or make any difference in x86 or ARM64 (CONFIG_EFI_ZBOOT=y) kernel sizes. (I'm ignoring a few dozen bytes of noise on ARM64 between repeated builds.) The boot code on PowerPC is special and it touches the XZ_EXTERN macro in its xz_config.h. Relevant files: arch/powerpc/boot/xz_config.h arch/powerpc/boot/decompress.c The "#undef XZ_EXTERN" can be confusing but in the end all XZ_EXTERN uses become "static" still. Comparing to zlib usage on PowerPC, it seems that decompressor functions aren't required to be static (zlib's files are pre-processed with a sed script but it doesn't make anything static). So, even without testing, it seems quite clear that removing XZ_EXTERN would be fine on PowerPC too. Thus, let's drop this patch to Documentation/conf.py, and I submit a patch to remove XZ_EXTERN. Thanks! -- Lasse Collin