Disable the option treated warnings as errors

83 views
Skip to first unread message

Jingwen Ye

unread,
May 10, 2022, 7:40:34 AM5/10/22
to Chromium OS Development
Hi, all

After I installed the patches to kernel v5.10. I ran the following command and shows errors (make treated warning as errors). 

cros_workon_make --board=${BOARD} chromeos-kernel-5_10

The warning message are about C language. Then I commented line 769 in chromiumos/src/third_party/kernel/v5.10/Makefile and run above command again

KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror

Problem solved. After the modification of kernel, I re-ran 

build_package 

but there are other errors like

chromeos-kernel-5_10-5.10.114-r1889: /build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:284:6: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
chromeos-kernel-5_10-5.10.114-r1889:         u64 ctlhi = (DWAXIDMAC_GHP_AR_PORT_VAL << CH_CTL_H_AR_PORT_POS) | (DWAXIDMAC_GHP_AW_PORT_VAL << CH_CTL_H_AW_PORT_POS);
chromeos-kernel-5_10-5.10.114-r1889:             ^
chromeos-kernel-5_10-5.10.114-r1889: /build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:319:10: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
chromeos-kernel-5_10-5.10.114-r1889:                 size_t block_num=first->total_blocks;//get total transfer blocks
chromeos-kernel-5_10-5.10.114-r1889:                        ^
chromeos-kernel-5_10-5.10.114-r1889: /build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:316:16: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
chromeos-kernel-5_10-5.10.114-r1889:         unsigned long was_soft_llp = test_and_set_bit(DW_DMA_IS_SOFT_LLP,&chan->flags);
chromeos-kernel-5_10-5.10.114-r1889:                       ^
chromeos-kernel-5_10-5.10.114-r1889: 3 errors generated.
chromeos-kernel-5_10-5.10.114-r1889: make[4]: *** [/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/scripts/Makefile.build:280: drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.o] Error 1
chromeos-kernel-5_10-5.10.114-r1889:   CC      fs/kernfs/inode.o
chromeos-kernel-5_10-5.10.114-r1889:   CC      fs/proc/inode.o
chromeos-kernel-5_10-5.10.114-r1889:   CC      drivers/acpi/acpica/evxfgpe.o
chromeos-kernel-5_10-5.10.114-r1889: /build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/test_dma.c:47:22: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
chromeos-kernel-5_10-5.10.114-r1889:     struct dma_chan *dma_channel;
chromeos-kernel-5_10-5.10.114-r1889:                      ^
chromeos-kernel-5_10-5.10.114-r1889: /build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/test_dma.c:48:19: error: unused variable 'status' [-Werror,-Wunused-variable]
chromeos-kernel-5_10-5.10.114-r1889:     unsigned char status;
chromeos-kernel-5_10-5.10.114-r1889:                   ^
chromeos-kernel-5_10-5.10.114-r1889: 2 errors generated.
chromeos-kernel-5_10-5.10.114-r1889: make[4]: *** [/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/scripts/Makefile.build:280: drivers/dma/dw-axi-dmac/test_dma.o] Error 1
chromeos-kernel-5_10-5.10.114-r1889: make[4]: Target '__build' not remade because of errors.

Thus, I want to disable all options that treated warnings as errors. For example, 

 -Wdeclaration-after-statement, -Wunused-variable

Can anybody tell me where I can disable them?


Jingwen Ye

unread,
May 10, 2022, 9:45:25 AM5/10/22
to Chromium OS Development, Jingwen Ye
I also 
1. added nowerror to USE in chromiumos/src/overlays/overlay-amd64-generic/profiles/base/make.defaults
2. comment line 770 in chromiumos/src/third_party/kernel/v5.10/Makefile 
    KBUILD_CFLAGS += $(KBUILD_CFLAGS-y)
 but whrn I run build_package, it still shows the same error.


[1m/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:284:6: [0m [0;1;35mwarning: [0m [1mmixing declarations and code is a C99 extension [-Wdeclaration-after-statement] [0m
        u64 ctlhi = (DWAXIDMAC_GHP_AR_PORT_VAL << CH_CTL_H_AR_PORT_POS) | (DWAXIDMAC_GHP_AW_PORT_VAL << CH_CTL_H_AW_PORT_POS);
[0;1;32m            ^
[0m [1m/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:319:10: [0m [0;1;35mwarning: [0m [1mmixing declarations and code is a C99 extension [-Wdeclaration-after-statement] [0m
                size_t block_num=first->total_blocks;//get total transfer blocks
[0;1;32m                       ^
[0m [1m/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:316:16: [0m [0;1;35mwarning: [0m [1mmixing declarations and code is a C99 extension [-Wdeclaration-after-statement] [0m
        unsigned long was_soft_llp = test_and_set_bit(DW_DMA_IS_SOFT_LLP,&chan->flags);
[0;1;32m                      ^
[0m3 warnings generated.
  CC [M]  drivers/dma/dw-axi-dmac/test_dma.o
  CC      drivers/dma/dw/dw.o
  CC      drivers/acpi/acpica/exresop.o
  CC      fs/kernfs/symlink.o
  CC [M]  sound/soc/codecs/max98390.o
  CC      net/ipv4/tcp_cong.o
  CC      lib/zlib_deflate/deflate_syms.o
  CC      net/netfilter/nf_conntrack_netlink.o
  CC [M]  net/wireless/nl80211.o
  CC      drivers/acpi/acpica/exserial.o
  CC      drivers/clk/clk-divider.o
  CC      drivers/dma/dw/idma32.o
  AR      fs/kernfs/built-in.a
  AR      lib/zlib_deflate/built-in.a
  CC      fs/sysfs/file.o
  CC      lib/reed_solomon/reed_solomon.o
[1m/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/test_dma.c:47:22: [0m [0;1;35mwarning: [0m [1mmixing declarations and code is a C99 extension [-Wdeclaration-after-statement] [0m
    struct dma_chan *dma_channel;
[0;1;32m                     ^
[0m [1m/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/test_dma.c:48:19: [0m [0;1;35mwarning: [0m [1munused variable 'status' [-Wunused-variable] [0m
    unsigned char status;
[0;1;32m                  ^
[0m2 warnings generated.[1m/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:284:6: [0m [0;1;35mwarning: [0m [1mmixing declarations and code is a C99 extension [-Wdeclaration-after-statement] [0m
        u64 ctlhi = (DWAXIDMAC_GHP_AR_PORT_VAL << CH_CTL_H_AR_PORT_POS) | (DWAXIDMAC_GHP_AW_PORT_VAL << CH_CTL_H_AW_PORT_POS);
[0;1;32m            ^
[0m [1m/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:319:10: [0m [0;1;35mwarning: [0m [1mmixing declarations and code is a C99 extension [-Wdeclaration-after-statement] [0m
                size_t block_num=first->total_blocks;//get total transfer blocks
[0;1;32m                       ^
[0m [1m/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:316:16: [0m [0;1;35mwarning: [0m [1mmixing declarations and code is a C99 extension [-Wdeclaration-after-statement] [0m
        unsigned long was_soft_llp = test_and_set_bit(DW_DMA_IS_SOFT_LLP,&chan->flags);
[0;1;32m                      ^
[0m3 warnings generated.
  CC [M]  drivers/dma/dw-axi-dmac/test_dma.o
  CC      drivers/dma/dw/dw.o
  CC      drivers/acpi/acpica/exresop.o
  CC      fs/kernfs/symlink.o
  CC [M]  sound/soc/codecs/max98390.o
  CC      net/ipv4/tcp_cong.o
  CC      lib/zlib_deflate/deflate_syms.o
  CC      net/netfilter/nf_conntrack_netlink.o
  CC [M]  net/wireless/nl80211.o
  CC      drivers/acpi/acpica/exserial.o
  CC      drivers/clk/clk-divider.o
  CC      drivers/dma/dw/idma32.o
  AR      fs/kernfs/built-in.a
  AR      lib/zlib_deflate/built-in.a
  CC      fs/sysfs/file.o
  CC      lib/reed_solomon/reed_solomon.o
[1m/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/test_dma.c:47:22: [0m [0;1;35mwarning: [0m [1mmixing declarations and code is a C99 extension [-Wdeclaration-after-statement] [0m
    struct dma_chan *dma_channel;
[0;1;32m                     ^
[0m [1m/build/amd64-generic/tmp/portage/sys-kernel/chromeos-kernel-5_10-5.10.114-r1889/work/chromeos-kernel-5_10-5.10.114/drivers/dma/dw-axi-dmac/test_dma.c:48:19: [0m [0;1;35mwarning: [0m [1munused variable 'status' [-Wunused-variable] [0m
    unsigned char status;
[0;1;32m                  ^
[0m2 warnings generated.

Jingwen Ye

unread,
May 10, 2022, 10:09:48 AM5/10/22
to Chromium OS Development, Jingwen Ye
This problem makes me so confused. From log, I found when I ran cros_workon_make --board=${BOARD} chromeos-kernel-5_10, it showed warnings but not be treated as errors. But when I ran build_package, the same warnings are treated as errors based on log information.

Jingwen Ye

unread,
May 10, 2022, 10:17:35 AM5/10/22
to Chromium OS Development, Jingwen Ye
There are my modification steps.
1. cros_workon --board=${BOARD} start chromeos-kernel-5_10       //9999.ebuild
2. install patched, modified kernel config by config fragment            
3. cros_workon_make --board=${BOARD} chromeos-kernel-5_10      //this step success, warnings are not treated as errors
4. cros_workon --board=${BOARD} stop chromeos-kernel-5_10        // stop build 9999 version, use stable version
5. build_packages --board=${BOARD} --autosetgov                              //this step failed, warnings are treated as errors

ggg

unread,
May 10, 2022, 2:34:07 PM5/10/22
to Chromium OS Development, jy...@cornell.edu


On Tuesday, May 10, 2022 at 4:40:34 AM UTC-7 jy...@cornell.edu wrote:
...

Thus, I want to disable all options that treated warnings as errors. For example, 

 -Wdeclaration-after-statement, -Wunused-variable

Can anybody tell me where I can disable them?

Sorry, I have to ask the obvious question: Why don't you fix the warnings?

There are good reasons for not allowing these warnings.

cheers,
grant

ggg

unread,
May 10, 2022, 2:46:40 PM5/10/22
to Chromium OS Development, jy...@cornell.edu
On Tuesday, May 10, 2022 at 7:17:35 AM UTC-7 jy...@cornell.edu wrote:
There are my modification steps.
1. cros_workon --board=${BOARD} start chromeos-kernel-5_10       //9999.ebuild
2. install patched, modified kernel config by config fragment            
3. cros_workon_make --board=${BOARD} chromeos-kernel-5_10      //this step success, warnings are not treated as errors
4. cros_workon --board=${BOARD} stop chromeos-kernel-5_10        // stop build 9999 version, use stable version
5. build_packages --board=${BOARD} --autosetgov                              //this step failed, warnings are treated as errors

If you want to include your changes, you should be using 9999 build version: drop step 4

If you want to revert your changes, _also_ (step 4b) checkout the remotes/cros/main branch OR remotes/cros/stable branch in src/third_party/kernel/v5.10 directory.

[NOTE: you didn't mention if you created a local branch to manage your set of changes - learn how to do that with "git branch" command if you don't want to repeat step 2. ]

AFAIK, "cros_workon stop" only changes the ebuild version used (back to original). I believe, in the case of the kernel, "stop" does not change the source tree since the source is a local directory, not a download/unpack a tarball.

cheers,
grant

Jingwen Ye

unread,
May 10, 2022, 9:56:50 PM5/10/22
to Chromium OS Development, ggg, Jingwen Ye
Caused by the driver, the platform does not have the bus that I need. I "forced" to use this bus without relevent headers (.h files). This is the reason that caused warnings 

Jingwen Ye

unread,
May 10, 2022, 10:12:06 PM5/10/22
to Chromium OS Development, ggg, Jingwen Ye
Thanks for the help, I am a uni student and does not have many experience in Linux development. May be some questions seem to be "not smart". In addition, I found another method to solve this problem. Using  

#pragma GCC diagnostic ignored

ggg

unread,
May 11, 2022, 2:22:07 PM5/11/22
to Chromium OS Development, jy...@cornell.edu, ggg
On Tuesday, May 10, 2022 at 6:56:50 PM UTC-7 jy...@cornell.edu wrote:
Caused by the driver, the platform does not have the bus that I need. I "forced" to use this bus without relevent headers (.h files). This is the reason that caused warnings

The purpose of the warning is to tell you the tool chain can not help verify correct usage of  an existing API. Make one small mistake in this usage and you will be hunting for that mistake, possibly for days. Everyone eventually makes a mistake. And your own mistakes are the hardest ones to find:

It should not take you more than an hour or two to add the appropriate header files. I'm assuming they are available someplace and can be copied into the chromeos kernel source tree and referenced by your driver.

cheers,
grant
Reply all
Reply to author
Forward
0 new messages