Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Jan 2017 16:56:37 -0800
From:      Mark Millard <markmi@dsl-only.net>
To:        FreeBSD Toolchain <freebsd-toolchain@freebsd.org>
Subject:   A C error that clang 3.9.1 did not catch while generating mlx5_en_ethtool.o (amd64-xtoolchain-gcc's amd64-gcc did catch it)
Message-ID:  <97A82CFE-EB66-48F8-A641-0A0BEDBC1EB7@dsl-only.net>

next in thread | raw e-mail | index | archive | help
Context: head -r312942

Generating:

=
/usr/obj/amd64_clang/amd64.amd64/usr/src/sys/GENERIC-NODBG/modules/usr/src=
/sys/modules/mlx5en/mlx5_en_ethtool.o

involves. . .

/usr/src/sys/dev/mlx5/diagnostics.h shows:

struct mlx5_core_diagnostics_entry {
        const char *const desc;
        u16     counter_id;
};

Note the const between * and desc: the pointer
field is declared to be constant.

/usr/src/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
shows:

static void
mlx5e_create_diagnostics(struct mlx5e_priv *priv)
{
        struct mlx5_core_diagnostics_entry entry;
. . .
        for (x =3D 0; x !=3D MLX5_CORE_PCI_DIAGNOSTICS_NUM; x++) {
                entry =3D mlx5_core_pci_diagnostics_table[x];
. . .
        }
         =20
        /* create general diagnostics */
        for (x =3D 0; x !=3D MLX5_CORE_GENERAL_DIAGNOSTICS_NUM; x++) {
                entry =3D mlx5_core_general_diagnostics_table[x];
 . .
        }
}

which involves assignments to constant pointers: the
desc value is supposed to be constant as things are
declared.

A clang 3.9.1 based build did not complain about this:

# Meta data file =
/usr/obj/amd64_clang/amd64.amd64/usr/src/sys/GENERIC-NODBG/modules/usr/src=
/sys/modules/mlx5en/mlx5_en_ethtool.o.meta
CMD cc -target x86_64-unknown-freebsd12.0 =
--sysroot=3D/usr/obj/amd64_clang/amd64.amd64/usr/src/tmp =
-B/usr/obj/amd64_clang/amd64.amd64/usr/src/tmp/usr/bin  -O2 -pipe  =
-fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc  =
-I/usr/src/sys/modules/mlx5en/../../ofed/include =
-I/usr/src/sys/modules/mlx5en/../../compat/linuxkpi/common/include =
-DHAVE_KERNEL_OPTION_HEADERS -include =
/usr/obj/amd64_clang/amd64.amd64/usr/src/sys/GENERIC-NODBG/opt_global.h =
-I. -I/usr/src/sys -fno-common -g -fno-omit-frame-pointer =
-mno-omit-leaf-frame-pointer =
-I/usr/obj/amd64_clang/amd64.amd64/usr/src/sys/GENERIC-NODBG  =
-mcmodel=3Dkernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  =
-fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector =
-gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes =
-Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef =
-Wno-pointer-sign -D__printf__=3D__freebsd_kprintf__ =
-Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas =
-Wno-error-tautological-compare -Wno-error-empty-body =
-Wno-error-parentheses-equality -Wno-error-unused-function =
-Wno-error-pointer-sign -Wno-error-shift-negative-value  -mno-aes =
-mno-avx  -std=3Diso9899:1999 -Wno-cast-qual -Wno-pointer-arith  -c =
/usr/src/sys/modules/mlx5en/../../dev/mlx5/mlx5_en/mlx5_en_ethtool.c -o =
mlx5_en_ethtool.o
CMD ctfconvert -L VERSION -g mlx5_en_ethtool.o
CWD =
/usr/obj/amd64_clang/amd64.amd64/usr/src/sys/GENERIC-NODBG/modules/usr/src=
/sys/modules/mlx5en
TARGET mlx5_en_ethtool.o
-- command output --


but amd64-xtoolchain-gcc's amd64-gcc got:
(I had CFLAGS.gcc +=3D -v for this.)

# Meta data file =
/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/sys/GENERIC-NODBG/modules/us=
r/src/sys/modules/mlx5en/mlx5_en_ethtool.o.meta
CMD /usr/local/bin/x86_64-unknown-freebsd12.0-gcc -isystem =
/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/tmp/usr/include =
-L/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/tmp/usr/lib =
-B/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/tmp/usr/lib =
--sysroot=3D/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/tmp =
-B/usr/local/x86_64-freebsd/bin/  -O2 -pipe  -fno-strict-aliasing =
-D_KERNEL -DKLD_MODULE -nostdinc  =
-I/usr/src/sys/modules/mlx5en/../../ofed/include =
-I/usr/src/sys/modules/mlx5en/../../compat/linuxkpi/common/include =
-DHAVE_KERNEL_OPTION_HEADERS -include =
/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/sys/GENERIC-NODBG/opt_global=
.h -I. -I/usr/src/sys -fno-common -g -fno-omit-frame-pointer =
-mno-omit-leaf-frame-pointer =
-I/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/sys/GENERIC-NODBG  =
-mcmodel=3Dkernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  =
-fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector =
-gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes =
-Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef =
-Wno-pointer-sign -fformat-extensions -Wmissing-include-dirs =
-fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=3Daddress =
-Wno-error=3Daggressive-loop-optimizations -Wno-error=3Darray-bounds =
-Wno-error=3Dattributes -Wno-error=3Dcast-qual -Wno-error=3Denum-compare =
-Wno-error=3Dinline -Wno-error=3Dmaybe-uninitialized -Wno-error=3Doverflow=
 -Wno-error=3Dsequence-point -Wno-error=3Dstrict-overflow =
-Wno-error=3Dunused-but-set-variable -Wno-error=3Dmisleading-indentation =
-Wno-error=3Dnonnull-compare -Wno-error=3Dshift-overflow =
-Wno-error=3Dtautological-compare  -v -finline-limit=3D8000 =
-fms-extensions --param inline-unit-growth=3D100 --param =
large-function-growth=3D1000  -std=3Diso9899:1999 -Wno-cast-qual =
-Wno-pointer-arith  -c =
/usr/src/sys/modules/mlx5en/../../dev/mlx5/mlx5_en/mlx5_en_ethtool.c -o =
mlx5_en_ethtool.o
CMD ctfconvert -L VERSION -g mlx5_en_ethtool.o
CWD =
/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/sys/GENERIC-NODBG/modules/us=
r/src/sys/modules/mlx5en
TARGET mlx5_en_ethtool.o
-- command output --
Using built-in specs.
COLLECT_GCC=3D/usr/local/bin/x86_64-unknown-freebsd12.0-gcc
Target: x86_64-unknown-freebsd12.0
Configured with: =
/usr/obj/portswork/usr/ports/devel/amd64-gcc/work/gcc-6.3.0/configure =
--target=3Dx86_64-unknown-freebsd12.0 --disable-nls =
--enable-languages=3Dc,c++ --without-headers --with-gmp=3D/usr/local =
--with-pkgversion=3D'FreeBSD Ports Collection for amd64' =
--with-system-zlib --with-gcc-include-dir=3D/usr/include/c++/v1/ =
--with-as=3D/usr/local/bin/x86_64-freebsd-as =
--with-ld=3D/usr/local/bin/x86_64-freebsd-ld --prefix=3D/usr/local =
--localstatedir=3D/var --mandir=3D/usr/local/man =
--infodir=3D/usr/local/info/ --build=3Dx86_64-unknown-freebsd12.0
Thread model: posix
gcc version 6.3.0 (FreeBSD Ports Collection for amd64)=20
COLLECT_GCC_OPTIONS=3D'-isystem' =
'/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/tmp/usr/include' =
'-L/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/tmp/usr/lib' '-B' =
'/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/tmp/usr/lib' '-B' =
'/usr/local/x86_64-freebsd/bin/' '-O2' '-pipe' '-fno-strict-aliasing' =
'-D' '_KERNEL' '-D' 'KLD_MODULE' '-nostdinc' '-I' =
'/usr/src/sys/modules/mlx5en/../../ofed/include' '-I' =
'/usr/src/sys/modules/mlx5en/../../compat/linuxkpi/common/include' '-D' =
'HAVE_KERNEL_OPTION_HEADERS' '-include' =
'/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/sys/GENERIC-NODBG/opt_globa=
l.h' '-I' '.' '-I' '/usr/src/sys' '-fno-common' '-g' =
'-fno-omit-frame-pointer' '-mno-omit-leaf-frame-pointer' '-I' =
'/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/sys/GENERIC-NODBG' =
'-mcmodel=3Dkernel' '-mno-red-zone' '-mno-mmx' '-mno-sse' '-msoft-float' =
'-fno-asynchronous-unwind-tables' '-ffreestanding' '-fwrapv' =
'-fstack-protector' '-gdwarf-2' '-Wall' '-Wredundant-decls' =
'-Wnested-externs' '-Wstrict-prototypes' '-Wmissing-prototypes' =
'-Winline' '-Wundef' '-Wno-pointer-sign' '-fformat-extensions' =
'-Wmissing-include-dirs' '-fdiagnostics-show-option' =
'-Wno-unknown-pragmas' '-Wno-error=3Daddress' =
'-Wno-error=3Daggressive-loop-optimizations' '-Wno-error=3Darray-bounds' =
'-Wno-error=3Dattributes' '-Wno-error=3Dcast-qual' =
'-Wno-error=3Denum-compare' '-Wno-error=3Dinline' =
'-Wno-error=3Dmaybe-uninitialized' '-Wno-error=3Doverflow' =
'-Wno-error=3Dsequence-point' '-Wno-error=3Dstrict-overflow' =
'-Wno-error=3Dunused-but-set-variable' =
'-Wno-error=3Dmisleading-indentation' '-Wno-error=3Dnonnull-compare' =
'-Wno-error=3Dshift-overflow' '-Wno-error=3Dtautological-compare' '-v' =
'-finline-limit=3D8000' '-fms-extensions' '--param' =
'inline-unit-growth=3D100' '--param' 'large-function-growth=3D1000' =
'-std=3Dc99' '-Wno-cast-qual' '-Wno-pointer-arith' '-c' '-o' =
'mlx5_en_ethtool.o' '-mtune=3Dgeneric' '-march=3Dx86-64'
 /usr/local/libexec/gcc/x86_64-unknown-freebsd12.0/6.3.0/cc1 -quiet =
-nostdinc -v -I /usr/src/sys/modules/mlx5en/../../ofed/include -I =
/usr/src/sys/modules/mlx5en/../../compat/linuxkpi/common/include -I . -I =
/usr/src/sys -I =
/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/sys/GENERIC-NODBG =
-isysroot /usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/tmp -D _KERNEL =
-D KLD_MODULE -D HAVE_KERNEL_OPTION_HEADERS -isystem =
/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/tmp/usr/include -include =
/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/sys/GENERIC-NODBG/opt_global=
.h /usr/src/sys/modules/mlx5en/../../dev/mlx5/mlx5_en/mlx5_en_ethtool.c =
-quiet -dumpbase mlx5_en_ethtool.c -mno-omit-leaf-frame-pointer =
-mcmodel=3Dkernel -mno-red-zone -mno-mmx -mno-sse -msoft-float =
-mtune=3Dgeneric -march=3Dx86-64 -auxbase-strip mlx5_en_ethtool.o -g =
-gdwarf-2 -O2 -Wall -Wredundant-decls -Wnested-externs =
-Wstrict-prototypes -Wmissing-prototypes -Winline -Wundef =
-Wno-pointer-sign -Wmissing-include-dirs -Wno-unknown-pragmas =
-Wno-error=3Daddress -Wno-error=3Daggressive-loop-optimizations =
-Wno-error=3Darray-bounds -Wno-error=3Dattributes -Wno-error=3Dcast-qual =
-Wno-error=3Denum-compare -Wno-error=3Dinline =
-Wno-error=3Dmaybe-uninitialized -Wno-error=3Doverflow =
-Wno-error=3Dsequence-point -Wno-error=3Dstrict-overflow =
-Wno-error=3Dunused-but-set-variable -Wno-error=3Dmisleading-indentation =
-Wno-error=3Dnonnull-compare -Wno-error=3Dshift-overflow =
-Wno-error=3Dtautological-compare -Wno-cast-qual -Wno-pointer-arith =
-std=3Dc99 -version -fno-strict-aliasing -fno-common =
-fno-omit-frame-pointer -fno-asynchronous-unwind-tables -ffreestanding =
-fwrapv -fstack-protector -fformat-extensions -fdiagnostics-show-option =
-finline-limit=3D8000 -fms-extensions --param inline-unit-growth=3D100 =
--param large-function-growth=3D1000 -o - |
 /usr/local/bin/x86_64-freebsd-as -v -I =
/usr/src/sys/modules/mlx5en/../../ofed/include -I =
/usr/src/sys/modules/mlx5en/../../compat/linuxkpi/common/include -I . -I =
/usr/src/sys -I =
/usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/sys/GENERIC-NODBG -o =
mlx5_en_ethtool.o
GNU assembler version 2.27 (x86_64-freebsd) using BFD version (GNU =
Binutils) 2.27
GNU C99 (FreeBSD Ports Collection for amd64) version 6.3.0 =
(x86_64-unknown-freebsd12.0)
        compiled by GNU C version 4.2.1 Compatible FreeBSD Clang 3.9.1 =
(tags/RELEASE_391/final 289601), GMP version 5.1.3, MPFR version 3.1.5, =
MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=3D100 --param =
ggc-min-heapsize=3D131072
#include "..." search starts here:
#include <...> search starts here:
 /usr/src/sys/modules/mlx5en/../../ofed/include
 /usr/src/sys/modules/mlx5en/../../compat/linuxkpi/common/include
 .
 /usr/src/sys
 /usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/sys/GENERIC-NODBG
 /usr/obj/amd64_xtoolchain/amd64.amd64/usr/src/tmp/usr/include
End of search list.
GNU C99 (FreeBSD Ports Collection for amd64) version 6.3.0 =
(x86_64-unknown-freebsd12.0)
        compiled by GNU C version 4.2.1 Compatible FreeBSD Clang 3.9.1 =
(tags/RELEASE_391/final 289601), GMP version 5.1.3, MPFR version 3.1.5, =
MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=3D100 --param =
ggc-min-heapsize=3D131072
Compiler executable checksum: c39bf6f6d020224fff5a44bbb0af2fd5
In file included from /usr/src/sys/sys/refcount.h:36:0,
                 from =
/usr/src/sys/modules/mlx5en/../../compat/linuxkpi/common/include/linux/kmo=
d.h:36,
                 from =
/usr/src/sys/modules/mlx5en/../../dev/mlx5/mlx5_en/en.h:31,
                 from =
/usr/src/sys/modules/mlx5en/../../dev/mlx5/mlx5_en/mlx5_en_ethtool.c:28:
/usr/src/sys/dev/mlx5/device.h:530:29: warning: comparison between 'enum =
<anonymous>' and 'enum <anonymous>' [-Wenum-compare]
 CTASSERT(MLX5_CMD_MBOX_SIZE <=3D MLX5_ADAPTER_PAGE_SIZE);
                             ^
/usr/src/sys/sys/systm.h:105:36: note: in definition of macro 'CTASSERT'
 #define CTASSERT(x) _Static_assert(x, "compile-time assertion failed")
                                    ^
/usr/src/sys/modules/mlx5en/../../dev/mlx5/mlx5_en/mlx5_en_ethtool.c: In =
function 'mlx5e_create_diagnostics':
=
/usr/src/sys/modules/mlx5en/../../dev/mlx5/mlx5_en/mlx5_en_ethtool.c:665:9=
: error: assignment of read-only variable 'entry'
   entry =3D mlx5_core_pci_diagnostics_table[x];
         ^
=
/usr/src/sys/modules/mlx5en/../../dev/mlx5/mlx5_en/mlx5_en_ethtool.c:675:9=
: error: assignment of read-only variable 'entry'
   entry =3D mlx5_core_general_diagnostics_table[x];
         ^
*** Error code 1



=3D=3D=3D
Mark Millard
markmi at dsl-only.net




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?97A82CFE-EB66-48F8-A641-0A0BEDBC1EB7>