Skip to content

Failed to compile os/linux/zfs/zfs_ioctl_os.c with clang lto #11987

Closed
@12101111

Description

@12101111

System information

Type Version/Name
Distribution Name Gentoo Linux
Distribution Version ~amd64
Linux Kernel 5.12.0
Architecture amd64
ZFS Version 2.1.0-rc4
SPL Version 2.1.0-rc4

Describe the problem you're observing

> make LLVM=1 LLVM_IAS=1 -j13
  DESCEND  objtool
  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.o
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: pasting formed ')6', an invalid preprocessing token
module_init(_init);
^
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
./include/linux/init.h:201:2: note: expanded from macro '__initcall_name'
        __PASTE(__iid, id))))
        ^
./include/linux/compiler_types.h:60:22: note: expanded from macro '__PASTE'
#define __PASTE(a,b) ___PASTE(a,b)
                     ^
./include/linux/compiler_types.h:59:24: note: expanded from macro '___PASTE'
#define ___PASTE(a,b) a##b
                       ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: pasting formed ')6', an invalid preprocessing token
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
./include/linux/init.h:201:2: note: expanded from macro '__initcall_name'
        __PASTE(__iid, id))))
        ^
./include/linux/compiler_types.h:60:22: note: expanded from macro '__PASTE'
#define __PASTE(a,b) ___PASTE(a,b)
                     ^
./include/linux/compiler_types.h:59:24: note: expanded from macro '___PASTE'
#define ___PASTE(a,b) a##b
                       ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: expected parameter declarator
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
./include/linux/compiler_types.h:59:23: note: expanded from macro '___PASTE'
#define ___PASTE(a,b) a##b
                      ^
<scratch space>:217:1: note: expanded from here
__init
^
./include/linux/init.h:50:27: note: expanded from macro '__init'
#define __init          __section(".init.text") __cold  __latent_entropy __noinitretpoline
                                  ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: expected ')'
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
./include/linux/compiler_types.h:59:23: note: expanded from macro '___PASTE'
#define ___PASTE(a,b) a##b
                      ^
<scratch space>:217:1: note: expanded from here
__init
^
./include/linux/init.h:50:27: note: expanded from macro '__init'
#define __init          __section(".init.text") __cold  __latent_entropy __noinitretpoline
                                  ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: note: to match this '('
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
<scratch space>:217:1: note: expanded from here
__init
^
./include/linux/init.h:50:17: note: expanded from macro '__init'
#define __init          __section(".init.text") __cold  __latent_entropy __noinitretpoline
                        ^
./include/linux/compiler_attributes.h:263:67: note: expanded from macro '__section'
#define __section(section)              __attribute__((__section__(section)))
                                                                  ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int]
module_init(_init);
^
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
<scratch space>:217:1: note: expanded from here
__init
^
./include/linux/init.h:50:17: note: expanded from macro '__init'
#define __init          __section(".init.text") __cold  __latent_entropy __noinitretpoline
                        ^
./include/linux/compiler_attributes.h:263:56: note: expanded from macro '__section'
#define __section(section)              __attribute__((__section__(section)))
                                                       ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
<scratch space>:217:1: note: expanded from here
__init
^
./include/linux/init.h:50:17: note: expanded from macro '__init'
#define __init          __section(".init.text") __cold  __latent_entropy __noinitretpoline
                        ^
./include/linux/compiler_attributes.h:263:67: note: expanded from macro '__section'
#define __section(section)              __attribute__((__section__(section)))
                                                                  ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: expected function body after function declarator
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:52: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                                              ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: expected parameter declarator
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
./include/linux/compiler_types.h:59:23: note: expanded from macro '___PASTE'
#define ___PASTE(a,b) a##b
                      ^
<scratch space>:217:1: note: expanded from here
__init
^
./include/linux/init.h:50:27: note: expanded from macro '__init'
#define __init          __section(".init.text") __cold  __latent_entropy __noinitretpoline
                                  ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: expected ')'
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
./include/linux/compiler_types.h:59:23: note: expanded from macro '___PASTE'
#define ___PASTE(a,b) a##b
                      ^
<scratch space>:217:1: note: expanded from here
__init
^
./include/linux/init.h:50:27: note: expanded from macro '__init'
#define __init          __section(".init.text") __cold  __latent_entropy __noinitretpoline
                                  ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: note: to match this '('
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
<scratch space>:217:1: note: expanded from here
__init
^
./include/linux/init.h:50:17: note: expanded from macro '__init'
#define __init          __section(".init.text") __cold  __latent_entropy __noinitretpoline
                        ^
./include/linux/compiler_attributes.h:263:67: note: expanded from macro '__section'
#define __section(section)              __attribute__((__section__(section)))
                                                                  ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int]
module_init(_init);
^
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
<scratch space>:217:1: note: expanded from here
__init
^
./include/linux/init.h:50:17: note: expanded from macro '__init'
#define __init          __section(".init.text") __cold  __latent_entropy __noinitretpoline
                        ^
./include/linux/compiler_attributes.h:263:56: note: expanded from macro '__section'
#define __section(section)              __attribute__((__section__(section)))
                                                       ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
<scratch space>:217:1: note: expanded from here
__init
^
./include/linux/init.h:50:17: note: expanded from macro '__init'
#define __init          __section(".init.text") __cold  __latent_entropy __noinitretpoline
                        ^
./include/linux/compiler_attributes.h:263:67: note: expanded from macro '__section'
#define __section(section)              __attribute__((__section__(section)))
                                                                  ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: expected function body after function declarator
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:52: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                                              ^
12 errors generated.
make[3]: *** [scripts/Makefile.build:271: fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.o] Error 1
make[2]: *** [scripts/Makefile.build:514: fs/zfs/zfs] Error 2
make[1]: *** [scripts/Makefile.build:514: fs/zfs] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1851: fs] Error 2
make: *** Waiting for unfinished jobs....

Describe how to reproduce the problem

Enable CONFIG_LTO_CLANG_THIN

Include any warning/errors/backtraces from the system logs

Run this command:

clang -nostdinc -isystem /usr/lib/llvm/12/bin/../../../../lib/clang/12.0.0/include -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -include ./include/zfs/zfs_config.h -I./include/zfs/os/linux/kernel -I./include/zfs/os/linux/spl -I./include/zfs/os/linux/zfs -I./include/zfs -D_KERNEL -UDEBUG -DNDEBUG -DKBUILD_MODFILE='"fs/zfs/zfs/zfs"' -DKBUILD_BASENAME='"zfs_ioctl_os"' -DKBUILD_MODNAME='"zfs"' -D__KBUILD_MODNAME=kmod_zfs -c -E fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c

stderr:

fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: pasting formed ')6', an invalid preprocessing token
module_init(_init);
^
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
./include/linux/init.h:201:2: note: expanded from macro '__initcall_name'
        __PASTE(__iid, id))))
        ^
./include/linux/compiler_types.h:60:22: note: expanded from macro '__PASTE'
#define __PASTE(a,b) ___PASTE(a,b)
                     ^
./include/linux/compiler_types.h:59:24: note: expanded from macro '___PASTE'
#define ___PASTE(a,b) a##b
                       ^
fs/zfs/zfs/../os/linux/zfs/zfs_ioctl_os.c:322:1: error: pasting formed ')6', an invalid preprocessing token
./include/linux/module.h:86:24: note: expanded from macro 'module_init'
#define module_init(x)  __initcall(x);
                        ^
./include/linux/init.h:295:24: note: expanded from macro '__initcall'
#define __initcall(fn) device_initcall(fn)
                       ^
./include/linux/init.h:290:30: note: expanded from macro 'device_initcall'
#define device_initcall(fn)             __define_initcall(fn, 6)
                                        ^
note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
./include/linux/init.h:201:2: note: expanded from macro '__initcall_name'
        __PASTE(__iid, id))))
        ^
./include/linux/compiler_types.h:60:22: note: expanded from macro '__PASTE'
#define __PASTE(a,b) ___PASTE(a,b)
                     ^
./include/linux/compiler_types.h:59:24: note: expanded from macro '___PASTE'
#define ___PASTE(a,b) a##b
                       ^
2 errors generated.

end of stdout:

static void __attribute__((__section__(".exit.text"))) __attribute__((__used__)) __attribute__((__cold__)) __attribute__((no_instrument_function))
_fini(void)
{
 zfs_sysfs_fini();
 zfs_kmod_fini();

 printk("\001" "5" "ZFS: Unloaded module v%s-%s%s\n",
     "2.1.0", "rc4", "");
}


int __attribute__((__section__(".init.text"))) __attribute__((__cold__)) __initstub__kmod_zfs__396_322__attribute__((__section__(".init.text"))) __attribute__((__cold__))6(void); int __attribute__((__section__(".init.text"))) __attribute__((__cold__)) __initstub__kmod_zfs__396_322__attribute__((__section__(".init.text"))) __attribute__((__cold__))6(void) { return _init(); } static void * __attribute__((__section__(".discard.addressable"))) __attribute__((__used__)) __UNIQUE_ID___addressable___initstub__kmod_zfs__396_322__attribute__((__section__(".init.text"))) __attribute__((__cold__))6397 = (void *)&__initstub__kmod_zfs__396_322__attribute__((__section__(".init.text"))) __attribute__((__cold__))6; asm(".section      \"" ".initcall6" ".init.." "kmod_zfs__396_322__attribute__((__section__(\".init.text\"))) __attribute__((__cold__))" "\", \"a\"         \n" "__initcall__kmod_zfs__396_322__attribute__((__section__(\".init.text\"))) __attribute__((__cold__))6" ":                   \n" ".long      " "__initstub__kmod_zfs__396_322__attribute__((__section__(\".init.text\"))) __attribute__((__cold__))6" " - .  \n" ".previous                                  \n");;;               
static exitcall_t __exitcall__fini __attribute__((__used__)) __attribute__((__section__(".exitcall.exit"))) = _fini;;


static const char __UNIQUE_ID_description398[] __attribute__((__used__)) __attribute__((__section__(".modinfo"))) __attribute__((__aligned__(1))) = "zfs" "." "description" "=" "ZFS";
static const char __UNIQUE_ID_author399[] __attribute__((__used__)) __attribute__((__section__(".modinfo"))) __attribute__((__aligned__(1))) = "zfs" "." "author" "=" "OpenZFS";
static const char __UNIQUE_ID_file400[] __attribute__((__used__)) __attribute__((__section__(".modinfo"))) __attribute__((__aligned__(1))) = "zfs" "." "file" "=" "fs/zfs/zfs/zfs"; static const char __UNIQUE_ID_license401[] __attribute__((__used__)) __attribute__((__section__(".modinfo"))) __attribute__((__aligned__(1))) = "zfs" "." "license" "=" "CDDL";
static const char __UNIQUE_ID_version402[] __attribute__((__used__)) __attribute__((__section__(".modinfo"))) __attribute__((__aligned__(1))) = "zfs" "." "version" "=" "2.1.0" "-" "rc4"; static struct module_version_attribute __modver_attr __attribute__((__used__)) __attribute__((__section__("__modver"))) __attribute__((__aligned__(__alignof__(struct module_version_attribute)))) = { .mattr = { .attr = { .name = "version", .mode = (00400|00040|00004), }, .show = __modver_version_show, }, .module_name = "zfs", .version = "2.1.0" "-" "rc4", };

The broken line is

int __attribute__((__section__(".init.text"))) __attribute__((__cold__)) __initstub__kmod_zfs__396_322__attribute__((__section__(".init.text"))) __attribute__((__cold__))6(void); int __attribute__((__section__(".init.text"))) __attribute__((__cold__)) __initstub__kmod_zfs__396_322__attribute__((__section__(".init.text"))) __attribute__((__cold__))6(void) { return _init(); } static void * __attribute__((__section__(".discard.addressable"))) __attribute__((__used__)) __UNIQUE_ID___addressable___initstub__kmod_zfs__396_322__attribute__((__section__(".init.text"))) __attribute__((__cold__))6397 = (void *)&__initstub__kmod_zfs__396_322__attribute__((__section__(".init.text"))) __attribute__((__cold__))6; asm(".section      \"" ".initcall6" ".init.." "kmod_zfs__396_322__attribute__((__section__(\".init.text\"))) __attribute__((__cold__))" "\", \"a\"         \n" "__initcall__kmod_zfs__396_322__attribute__((__section__(\".init.text\"))) __attribute__((__cold__))6" ":                   \n" ".long      " "__initstub__kmod_zfs__396_322__attribute__((__section__(\".init.text\"))) __attribute__((__cold__))6" " - .  \n" ".previous                                  \n");;;               

Format by hand:

int __attribute__(
    (__section__
        (".init.text")
    )
) 
__attribute__(
    (__cold__)
)
__initstub__kmod_zfs__396_322__attribute__(
    (__section__
        (".init.text")
    )
)
__attribute__(
    (__cold__)
)6(void); 

int __attribute__(
    (__section__
        (".init.text")
    )
) 
__attribute__(
    (__cold__)
)
__initstub__kmod_zfs__396_322__attribute__(
    (__section__
        (".init.text")
    )
)
__attribute__(
    (__cold__)
)6(void) {
    return _init(); 
} 

static void * __attribute__(
    (
        __section__(".discard.addressable")
    )
)
__attribute__(
    (__used__)
)
__UNIQUE_ID___addressable___initstub__kmod_zfs__396_322__attribute__(
    (__section__
        (".init.text")
    )
)
__attribute__(
    (__cold__)
)
6397 = (void *)&__initstub__kmod_zfs__396_322__attribute__(
    (__section__
        (".init.text")
    )
)
__attribute__(
    (__cold__)
)6;

asm(
    ".section      \""
    ".initcall6"
    ".init.."
    "kmod_zfs__396_322__attribute__(
        (__section__
            (\".init.text\")
        )
    ) __attribute__((__cold__))"
    "\", \"a\"         \n"
    "__initcall__kmod_zfs__396_322__attribute__(
        (__section__
            (\".init.text\")
        )
    ) __attribute__((__cold__))6"
    ":                   \n"
    ".long      "
    "__initstub__kmod_zfs__396_322__attribute__(
        (__section__
            (\".init.text\")
        )
    ) __attribute__((__cold__))6"
    " - .  \n"
    ".previous                                  \n"
);;;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Triage NeededNew issue which needs to be triagedType: DefectIncorrect behavior (e.g. crash, hang)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions