Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1611687 > unrolled thread

Re: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

Started byArnd Bergmann <arnd@arndb.de>
First post2017-03-29 10:40 +0200
Last post2017-03-30 13:10 +0200
Articles 3 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin Arnd Bergmann <arnd@arndb.de> - 2017-03-29 10:40 +0200
    Re: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin Arnd Bergmann <arnd@arndb.de> - 2017-03-29 11:00 +0200
      Re: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin Arnd Bergmann <arnd@arndb.de> - 2017-03-30 13:10 +0200

#1611687 — Re: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-29 10:40 +0200
SubjectRe: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin
Message-ID<tqhj3-4fY-1@gated-at.bofh.it>
Here is a reduced test case for one assertion failure I get with the
initify plugin:

8<------------
typedef unsigned int u32;

__attribute__ ((format(printf, 1, 2))) __attribute__ ((__cold__))
int printk(const char *fmt, ...);

void mv78xx0_pcie_id(u32 * dev, u32 * rev);

static char * __attribute__ ((__section__(".init.text")))
    __attribute__ ((__cold__)) __attribute__ ((no_instrument_function))
    __attribute__ ((latent_entropy)) mv78xx0_id(void)
{
        u32 dev, rev;
        mv78xx0_pcie_id(&dev, &rev);
        if (dev == 0x7820) {
                return "MV78200-A0";
        } else {
                return "Device-Unknown";
        }
}

void __attribute__ ((__section__(".init.text"))) __attribute__ ((__cold__))
    __attribute__ ((no_instrument_function))
    __attribute__ ((latent_entropy)) mv78xx0_init(void)
{
        printk("\001" "6" "%s ", mv78xx0_id());
}
------------->8

arm-linux-gnueabi-gcc-7.0.1 -Wimplicit-fallthrough=0
-Wno-duplicate-decl-specifier -Wno-override-init
-Wno-int-in-bool-context -Wno-bool-operation -Wno-format-truncation
-Werror -Wa,--fatal-warnings -DKCONFIG_SEED= -wrapper
/usr/bin/time,--format=%M:%U:%C,-o,/home/arnd/arm-soc/defconfig-kbytes,--append
-Wp,-MD,arch/arm/mach-mv78xx0/.common.o.d  -nostdinc -isystem
/home/arnd/cross-gcc/lib/gcc/arm-linux-gnueabi/7.0.1/include
-I/git/arm-soc/arch/arm/include -I./arch/arm/include/generated/uapi
-I./arch/arm/include/generated  -I/git/arm-soc/include -I./include
-I/git/arm-soc/arch/arm/include/uapi -I/git/arm-soc/include/uapi
-I./include/generated/uapi -include
/git/arm-soc/include/linux/kconfig.h
-I/git/arm-soc/arch/arm/mach-mv78xx0 -Iarch/arm/mach-mv78xx0
-D__KERNEL__ -mbig-endian -Wall -Wundef -Wstrict-prototypes
-fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
-std=gnu89 -fno-PIE -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux
-mno-thumb-interwork -mfpu=vfp -funwind-tables -marm
-D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=xscale -msoft-float -Uarm
-Wextra -Wno-frame-address -ffunction-sections -fdata-sections -O2
--param=allow-store-data-races=0 -DCC_HAVE_ASM_GOTO
-fplugin=./scripts/gcc-plugins/initify_plugin.so
-fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so
-DINITIFY_PLUGIN
-fplugin-arg-initify_plugin-search_init_exit_functions
-DLATENT_ENTROPY_PLUGIN -Wframe-larger-than=1024
-fstack-protector-strong -fno-delete-null-pointer-checks
-Wno-unused-but-set-variable -Wno-unused-const-variable
-fomit-frame-pointer -fno-var-tracking-assignments
-fno-inline-functions-called-once -Wdeclaration-after-statement
-Wno-pointer-sign -fno-strict-overflow -fconserve-stack
-Werror=implicit-int -Werror=strict-prototypes -Werror=date-time
-Werror=incompatible-pointer-types -Werror=designated-init
-Wno-type-limits -Wno-unused-parameter -Wno-missing-field-initializers
-Wno-sign-compare -Wmissing-include-dirs -Wformat=2
-Wno-format-nonliteral -Wtrampolines -Wold-style-definition
-Wnormalized -Wvolatile-register-var -Wdisabled-optimization
-Wno-format-security -Wimplicit-fallthrough=0
-Wno-duplicate-decl-specifier -Wno-int-in-bool-context
-Wno-bool-operation -Wformat-truncation=0 -Wformat-overflow=0
-I/git/arm-soc/arch/arm/plat-orion/include
-DKBUILD_BASENAME='"common"'  -DKBUILD_MODNAME='"common"' -c
arch/arm/mach-mv78xx0/common.c
*** WARNING *** there are active plugins, do not report this as a bug
unless you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_ATTRIBUTES                | latent_entropy_plugin initify_plugin
PLUGIN_START_UNIT                | latent_entropy_plugin initify_plugin
arch/arm/mach-mv78xx0/common.i: In function 'mv78xx0_init':
arch/arm/mach-mv78xx0/common.i:23:38: internal compiler error: in
search_constant_strings, at
git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
     __attribute__ ((latent_entropy)) mv78xx0_init(void)
                                      ^~~~~~~~~~~~
0x7f319a009b9d search_constant_strings
/git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
0x7f319a009950 search_constant_strings
/git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1335
0x7f319a009950 search_constant_strings
/git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1367
0x7f319a00aabe search_constant_strings
/git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1506
0x7f319a00aabe search_var_param
/git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1419
0x7f319a00aabe search_const_strs
/git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1471
0x7f319a00aabe initify_function_transform
/git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1519
0x932ce7 execute_one_ipa_transform_pass
/home/arnd/git/gcc/gcc/passes.c:2207
0x932ce7 execute_all_ipa_transforms()
/home/arnd/git/gcc/gcc/passes.c:2249
0x6b28fc cgraph_node::expand()
/home/arnd/git/gcc/gcc/cgraphunit.c:2031
0x6b3e5c expand_all_functions
/home/arnd/git/gcc/gcc/cgraphunit.c:2174
0x6b3e5c symbol_table::compile()
/home/arnd/git/gcc/gcc/cgraphunit.c:2531
0x6b58b7 symbol_table::compile()
/home/arnd/git/gcc/gcc/cgraphunit.c:2595
0x6b58b7 symbol_table::finalize_compilation_unit()
/home/arnd/git/gcc/gcc/cgraphunit.c:2621
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

[toc] | [next] | [standalone]


#1611701

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-29 11:00 +0200
Message-ID<tqhCp-4pL-9@gated-at.bofh.it>
In reply to#1611687
And here is a workaround that I applied locally to avoid the ICE, but
I wouldn't want to have this upstream.

commit 8712fd8979a5730318a84922fbcb8791ea5af40e
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Wed Mar 29 10:53:48 2017 +0200

    work around initify ICE

    arch/arm/mach-mv78xx0/common.i: In function 'mv78xx0_init':
    arch/arm/mach-mv78xx0/common.i:28:38: internal compiler error: in
search_constant_strings, at
git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
         __attribute__ ((latent_entropy)) mv78xx0_init(void)
                                          ^~~~~~~~~~~~
    0x7fe5cd711b9d search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
    0x7fe5cd711950 search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1335
    0x7fe5cd711950 search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1367
    0x7fe5cd712abe search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1506
    0x7fe5cd712abe search_var_param
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1419
    0x7fe5cd712abe search_const_strs
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1471
    0x7fe5cd712abe initify_function_transform
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1519
    0x932ce7 execute_one_ipa_transform_pass
            /home/arnd/git/gcc/gcc/passes.c:2207
    0x932ce7 execute_all_ipa_transforms()
            /home/arnd/git/gcc/gcc/passes.c:2249
    0x6b28fc cgraph_node::expand()
            /home/arnd/git/gcc/gcc/cgraphunit.c:2031
    0x6b3e5c expand_all_functions
            /home/arnd/git/gcc/gcc/cgraphunit.c:2174
    0x6b3e5c symbol_table::compile()
            /home/arnd/git/gcc/gcc/cgraphunit.c:2531
    0x6b58b7 symbol_table::compile()
            /home/arnd/git/gcc/gcc/cgraphunit.c:2595
    0x6b58b7 symbol_table::finalize_compilation_unit()
            /home/arnd/git/gcc/gcc/cgraphunit.c:2621
    Please submit a full bug report,
    with preprocessed source if appropriate.
    Please include the complete backtrace with any bug report.
    See <https://gcc.gnu.org/bugs/> for instructions.

    Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/arch/arm/mach-mv78xx0/common.c b/arch/arm/mach-mv78xx0/common.c
index f72e1e9f5fc5..66e04a770e32 100644
--- a/arch/arm/mach-mv78xx0/common.c
+++ b/arch/arm/mach-mv78xx0/common.c
@@ -348,31 +348,41 @@ void __ref mv78xx0_timer_init(void)
 /*****************************************************************************
  * General
  ****************************************************************************/
-static char * __init mv78xx0_id(void)
+static const char * __init mv78xx0_id(void)
 {
        u32 dev, rev;
+       static const char *chip_ids[] = {
+               "MV78X00-Z0",
+               "MV78X00-Rev-Unsupported",
+               "MV78100-A0",
+               "MV78100-A1",
+               "MV78100-Rev-Unsupported",
+               "MV78200-A0",
+               "MV78200-Rev-Unsupported",
+               "Device-Unknown",
+       };

        mv78xx0_pcie_id(&dev, &rev);

        if (dev == MV78X00_Z0_DEV_ID) {
                if (rev == MV78X00_REV_Z0)
-                       return "MV78X00-Z0";
+                       return chip_ids[0];
                else
-                       return "MV78X00-Rev-Unsupported";
+                       return chip_ids[1];
        } else if (dev == MV78100_DEV_ID) {
                if (rev == MV78100_REV_A0)
-                       return "MV78100-A0";
+                       return chip_ids[2];
                else if (rev == MV78100_REV_A1)
-                       return "MV78100-A1";
+                       return chip_ids[3];
                else
-                       return "MV78100-Rev-Unsupported";
+                       return chip_ids[4];
        } else if (dev == MV78200_DEV_ID) {
                if (rev == MV78100_REV_A0)
-                       return "MV78200-A0";
+                       return chip_ids[5];
                else
-                       return "MV78200-Rev-Unsupported";
+                       return chip_ids[6];
        } else {
-               return "Device-Unknown";
+               return chip_ids[7];
        }
 }

[toc] | [prev] | [next] | [standalone]


#1612958

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-30 13:10 +0200
Message-ID<tqG7L-5si-1@gated-at.bofh.it>
In reply to#1611701
On Wed, Mar 29, 2017 at 10:56 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> And here is a workaround that I applied locally to avoid the ICE, but
> I wouldn't want to have this upstream.
>
> commit 8712fd8979a5730318a84922fbcb8791ea5af40e
> Author: Arnd Bergmann <arnd@arndb.de>
> Date:   Wed Mar 29 10:53:48 2017 +0200
>
>     work around initify ICE
>
>     arch/arm/mach-mv78xx0/common.i: In function 'mv78xx0_init':
>     arch/arm/mach-mv78xx0/common.i:28:38: internal compiler error: in
> search_constant_strings, at
> git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
>          __attribute__ ((latent_entropy)) mv78xx0_init(void)
>                                           ^~~~~~~~~~~~
>     0x7fe5cd711b9d search_constant_strings
>             /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
>     0x7fe5cd711950 search_constant_strings
>             /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1335
>     0x7fe5cd711950 search_constant_strings
>             /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1367
>     0x7fe5cd712abe search_constant_strings
>             /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1506


Two more ICEs:

a)
*** WARNING *** there are active plugins, do not report this as a bug
unless you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_ATTRIBUTES                | latent_entropy_plugin initify_plugin
PLUGIN_START_UNIT                | latent_entropy_plugin initify_plugin
/git/arm-soc/drivers/scsi/gdth.c: In function 'gdth_search_drives':
/git/arm-soc/drivers/scsi/gdth.c:1550:12: internal compiler error: in
search_constant_strings, at
git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
 static int gdth_search_drives(gdth_ha_str *ha)
            ^~~~~~~~~~~~~~~~~~
0x2b0f7a831b9d search_constant_strings
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
0x2b0f7a831950 search_constant_strings
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1335
0x2b0f7a831950 search_constant_strings
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1367
0x2b0f7a832abe search_constant_strings
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1506
0x2b0f7a832abe search_var_param
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1419
0x2b0f7a832abe search_const_strs
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1471
0x2b0f7a832abe initify_function_transform
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1519
0x9b6c07 execute_one_ipa_transform_pass
        /home/arnd/git/gcc/gcc/passes.c:2207
0x9b6c07 execute_all_ipa_transforms()
        /home/arnd/git/gcc/gcc/passes.c:2249
0x734d6c cgraph_node::expand()
        /home/arnd/git/gcc/gcc/cgraphunit.c:2031
0x7362cc expand_all_functions
        /home/arnd/git/gcc/gcc/cgraphunit.c:2174
0x7362cc symbol_table::compile()
        /home/arnd/git/gcc/gcc/cgraphunit.c:2531
0x737d27 symbol_table::compile()
        /home/arnd/git/gcc/gcc/cgraphunit.c:2595
0x737d27 symbol_table::finalize_compilation_unit()
        /home/arnd/git/gcc/gcc/cgraphunit.c:2621
Please submit a full bug report,
with preprocessed source if appropriate.

This is the probably the same bug as the first, and I've worked around
it incorrectly for now:

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index d020a13646ae..37c9cf7a4e82 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -3846,6 +3846,8 @@ static const char *gdth_ctr_name(gdth_ha_str *ha)
 {
     TRACE2(("gdth_ctr_name()\n"));

+       return "";
+
     if (ha->type == GDT_EISA) {
         switch (ha->stype) {
           case GDT3_ID:


b)
*** WARNING *** there are active plugins, do not report this as a bug
unless you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_ATTRIBUTES                | initify_plugin
PLUGIN_START_UNIT                | initify_plugin
/git/arm-soc/arch/x86/kernel/traps.c:1049:1: internal compiler error:
in set_section, at symtab.c:1514
 }
 ^
0x724dd6 symtab_node::set_section(char const*)
/home/arnd/git/gcc/gcc/symtab.c:1514
0x2b26ed538c51 move_function_to_init_exit_text
/git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1751
0x2b26ed538c51 initify_execute
/git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1771
0x2b26ed538c51 execute
/git/arm-soc/scripts/gcc-plugins/gcc-generate-ipa-pass.h:215
Please submit a full bug report,

This one is different from the other two, and I don't know
much about what happened, but this clearly bogus change
avoids the problem:

diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index d0a21b12dd58..3793900f7f73 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -508,7 +508,7 @@ static inline void alloc_system_vector(int vector)
  */
 static inline void set_system_intr_gate(unsigned int n, void *addr)
 {
-       BUG_ON((unsigned)n > 0xFF);
+       //BUG_ON((unsigned)n > 0xFF);
        _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
 }


Aside from these problems and the annotations I sent yesterday, the
initify plugin doesn't cause any more build-time regressions for me,
so I'm leaving it enabled.

       Arnd

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web