| Summary: | 11.0 -r303168 buildkernel via devel/amd64-gcc fails for: dev/cxgbe/common/t4_hw.c warning: overflow in implicit constant conversion; more | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Mark Millard <marklmi26-fbsd> |
| Component: | kern | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed Overcome By Events | ||
| Severity: | Affects Only Me | CC: | ngie, np |
| Priority: | --- | ||
| Version: | 11.0-BETA3 | ||
| Hardware: | Any | ||
| OS: | Any | ||
Didn't occur previously, but I ran my tests on ^/head, not ^/stable/11 a couple weeks ago. What version of gcc is it using? (In reply to Ngie Cooper from comment #1) # /usr/local/bin/x86_64-portbld-freebsd11.0-gcc --version x86_64-portbld-freebsd11.0-gcc (FreeBSD Ports Collection for amd64) 5.3.0 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # pkg info amd64-gcc amd64-gcc-5.3.0 Name : amd64-gcc Version : 5.3.0 Installed on : Thu Jan 28 18:11:08 2016 PST Origin : devel/amd64-gcc Architecture : freebsd:11:x86:64 Prefix : /usr/local Categories : devel Licenses : GPLv3 and GPLv3RLE Maintainer : bapt@FreeBSD.org WWW : http://gcc.gnu.org/ Comment : Cross GNU Compiler Collection for amd64 Shared Libs required: libmpfr.so.4 libmpc.so.3 libgmp.so.10 Shared Libs provided: liblto_plugin.so.0 Annotations : Flat size : 64.6MiB Description : GCC, the GNU Compiler Collection supporting C and C++ for targetting crossbuilding. WWW: http://gcc.gnu.org/ # pkg info '*gcc*' amd64-gcc-5.3.0 amd64-xtoolchain-gcc-0.1 gcc-4.8.5_2 gcc-ecj-4.5 gcc6-6.1.0 gcc6-aux-20160427 powerpc64-gcc-5.3.0 powerpc64-xtoolchain-gcc-0.1 (In reply to Mark Millard from comment #0) The code in question for the overflow in an implicit constant conversion is for: c.err_to_clearinit = cpu_to_be32( V_FW_HELLO_CMD_MASTERDIS(master == MASTER_CANT) | V_FW_HELLO_CMD_MASTERFORCE(master == MASTER_MUST) | V_FW_HELLO_CMD_MBMASTER(master == MASTER_MUST ? mbox : M_FW_HELLO_CMD_MBMASTER) | V_FW_HELLO_CMD_MBASYNCNOT(evt_mbox) | V_FW_HELLO_CMD_STAGE(FW_HELLO_CMD_STAGE_OS) | F_FW_HELLO_CMD_CLEARINIT); V_FW_HELLO_CMD_MASTERDIS uses S_FW_HELLO_CMD_MASTERDIS: # grep V_FW_HELLO_CMD_MASTERDIS /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/*/* /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/common/t4_hw.c: V_FW_HELLO_CMD_MASTERDIS(master == MASTER_CANT) | /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/firmware/t4fw_interface.h:#define V_FW_HELLO_CMD_MASTERDIS(x) ((x) << S_FW_HELLO_CMD_MASTERDIS) /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/firmware/t4fw_interface.h:#define F_FW_HELLO_CMD_MASTERDIS V_FW_HELLO_CMD_MASTERDIS(1U) S_FW_HELLO_CMD_MASTERDIS is 29: # grep S_FW_HELLO_CMD_MASTERDIS /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/*/* /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/firmware/t4fw_interface.h:#define S_FW_HELLO_CMD_MASTERDIS 29 /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/firmware/t4fw_interface.h:#define V_FW_HELLO_CMD_MASTERDIS(x) ((x) << S_FW_HELLO_CMD_MASTERDIS) /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/firmware/t4fw_interface.h: (((x) >> S_FW_HELLO_CMD_MASTERDIS) & M_FW_HELLO_CMD_MASTERDIS) S_FW_HELLO_CMD_MASTERDIS being 29 means that V_FW_HELLO_CMD_MASTERDIS(x)'s ((x) << S_FW_HELLO_CMD_MASTERDIS) is far more than 16 bits wide. (I'll not list the other example bits.) For: ./x86/endian.h:75:53: note: in definition of macro '__bswap16' __bswap16_gen((__uint16_t)(x)) : __bswap16_var(x))) ^ the __bswap16_var is (from x86/endian.h ): static __inline __uint16_t __bswap16_var(__uint16_t _x) { return (__bswap16_gen(_x)); } and so there is an implicit truncation to 16 bits before __bswap16_gen(_x) and its & 0xffff masking is involved. And that is what the compiler is complaining about: the implicit status of the truncation. The truncated value appears to be fine for the code's purpose. 11.0-BETA2 and 11.0-BETA3 have been added to the Version list and x86/endian.h still has the implicit truncation referenced: So update Version to 11.0-BETA3. My guess at this point is that changes for getting amd64-gcc based 11.0 builds to work will be done after 11.0-RELEASE. I'll note that Bruce Evans wrote a reply to the submittal notice that in part said: Try this old patch. The extra casts might fix this. The removal of masks is a style fix that perhaps depends on the casts to work. IIRC, without the casts, bswap16(x) and bswap32(x) can return extra bits in some macro cases, so they are incompatible with the KPI. In the inline function cases, function semantics of course prevent the extra bits from being returned, but the code might be a bit sloppy in depending on this. X Index: endian.h X =================================================================== X --- endian.h (revision 302972) X +++ endian.h (working copy) X @@ -65,20 +65,20 @@ X X #define __bswap16_gen(x) (__uint16_t)((x) << 8 | (x) >> 8) X #define __bswap32_gen(x) \ X - (((__uint32_t)__bswap16((x) & 0xffff) << 16) | __bswap16((x) >> 16)) X + (((__uint32_t)__bswap16(x) << 16) | __bswap16((x) >> 16)) X #define __bswap64_gen(x) \ X - (((__uint64_t)__bswap32((x) & 0xffffffff) << 32) | __bswap32((x) >> 32)) X + (((__uint64_t)__bswap32(x) << 32) | __bswap32((x) >> 32)) X X #ifdef __GNUCLIKE_BUILTIN_CONSTANT_P X #define __bswap16(x) \ X ((__uint16_t)(__builtin_constant_p(x) ? \ X - __bswap16_gen((__uint16_t)(x)) : __bswap16_var(x))) X + __bswap16_gen((__uint16_t)(x)) : __bswap16_var((__uint16_t)(x)))) X #define __bswap32(x) \ X (__builtin_constant_p(x) ? \ X - __bswap32_gen((__uint32_t)(x)) : __bswap32_var(x)) X + __bswap32_gen((__uint32_t)(x)) : __bswap32_var((__uint32_t)(x))) X #define __bswap64(x) \ X (__builtin_constant_p(x) ? \ X - __bswap64_gen((__uint64_t)(x)) : __bswap64_var(x)) X + __bswap64_gen((__uint64_t)(x)) : __bswap64_var((__uint64_t)(x))) X #else X /* XXX these are broken for use in static initializers. */ X #define __bswap16(x) __bswap16_var(x) Bruce (I've not tried his patch, in part because there are other submittals for amd64-gcc build issues and I'm guessing that such submittals will not be addressed for 11.0-STABLE until after 11.0-RELEASE. I've no clue if these various submittals are complete in their coverage yet.) cxgbe builds fine with gcc on amd64 these days. Please open another bug if you see any problems with a recent head or stable/11. |
Really 11.0-BETA2 but no such selection was available. -Woverflow and -Wunused-but-set-variable combined with "all warnings being treated as errors": --- all_subdir_cxgbe --- /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/common/t4_hw.c: In function 't4_set_trace_filter': /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/common/t4_hw.c:5370:6: warning: variable 'multitrc' set but not used [-Wunused-but-set-variable] u32 multitrc = F_TRCMULTIFILTER; ^ In file included from ./machine/endian.h:6:0, from /usr/src/sys/sys/types.h:44, from /usr/src/sys/sys/param.h:90, from /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/common/t4_hw.c:32: /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/common/t4_hw.c: In function 't4_fw_hello': ./x86/endian.h:68:26: warning: overflow in implicit constant conversion [-Woverflow] (((__uint32_t)__bswap16((x) & 0xffff) << 16) | __bswap16((x) >> 16)) ^ ./x86/endian.h:75:53: note: in definition of macro '__bswap16' __bswap16_gen((__uint16_t)(x)) : __bswap16_var(x))) ^ ./x86/endian.h:78:6: note: in expansion of macro '__bswap32_gen' __bswap32_gen((__uint32_t)(x)) : __bswap32_var(x)) ^ /usr/src/sys/sys/endian.h:60:20: note: in expansion of macro '__bswap32' #define bswap32(x) __bswap32(x) ^ /usr/src/sys/sys/endian.h:69:20: note: in expansion of macro 'bswap32' #define htobe32(x) bswap32((x)) ^ /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/osdep.h:107:24: note: in expansion of macro 'htobe32' #define cpu_to_be32(x) htobe32(x) ^ /usr/src/sys/modules/cxgbe/if_cxgbe/../../../dev/cxgbe/common/t4_hw.c:6170:23: note: in expansion of macro 'cpu_to_be32' c.err_to_clearinit = cpu_to_be32( ^ --- all_subdir_cxgb --- --- all_subdir_cxgb/tom --- cc1: all warnings being treated as errors *** [cxgb_listen.o] Error code 1 Context details: # uname -apKU FreeBSD FreeBSDx64 11.0-BETA2 FreeBSD 11.0-BETA2 #0 r303168M: Thu Jul 21 19:59:36 PDT 2016 markmi@FreeBSDx64:/usr/obj/clang/amd64.amd64/usr/src/sys/GENERIC-NODBG amd64 amd64 1100120 1100120 # more ~/src.configs/src.conf.amd64-xtoolchain.amd64-host TO_TYPE=amd64 TOOLS_TO_TYPE=x86_64 VERSION_CONTEXT=11.0 # KERNCONF=GENERIC-NODBG TARGET=${TO_TYPE} .if ${.MAKE.LEVEL} == 0 TARGET_ARCH=${TO_TYPE} .export TARGET_ARCH .endif # WITHOUT_CROSS_COMPILER= WITHOUT_SYSTEM_COMPILER= # WITH_LIBCPLUSPLUS= WITHOUT_BINUTILS_BOOTSTRAP= WITHOUT_CLANG_BOOTSTRAP= WITH_CLANG= WITH_CLANG_IS_CC= WITH_CLANG_FULL= WITH_CLANG_EXTRAS= WITH_LLDB= #PORTS_MODULES=emulators/virtualbox-ose-additions # #WITH_BOOT= for amd64-xtoolschain-gcc/amd64-gcc gets something like... #(last I tried anyway, it has been a while) # --- all_subdir_sys --- # -994 bytes available # *** [boot2] Error code 1 WITHOUT_BOOT= WITH_LIB32= # WITHOUT_ELFTOOLCHAIN_BOOTSTRAP= WITHOUT_GCC_BOOTSTRAP= WITHOUT_GCC= WITHOUT_GCC_IS_CC= WITHOUT_GNUCXX= # NO_WERROR= #WERROR= MALLOC_PRODUCTION= # WITH_DEBUG_FILES= # # # For TO (so-called "cross") stages . . . # So-called-cross via ${TO_TYPE}-xtoolchain-gcc/${TO_TYPE}-gcc. . . # TOOLS_TO_TYPE based on ${TO_TYPE}-xtoolchain-gcc related binutils. . . # CROSS_TOOLCHAIN=${TO_TYPE}-gcc X_COMPILER_TYPE=gcc CROSS_BINUTILS_PREFIX=/usr/local/${TOOLS_TO_TYPE}-freebsd/bin/ .if ${.MAKE.LEVEL} == 0 XCC=/usr/local/bin/${TOOLS_TO_TYPE}-portbld-freebsd${VERSION_CONTEXT}-gcc XCXX=/usr/local/bin/${TOOLS_TO_TYPE}-portbld-freebsd${VERSION_CONTEXT}-g++ XCPP=/usr/local/bin/${TOOLS_TO_TYPE}-portbld-freebsd${VERSION_CONTEXT}-cpp .export XCC .export XCXX .export XCPP XAS=/usr/local/${TOOLS_TO_TYPE}-freebsd/bin/as XAR=/usr/local/${TOOLS_TO_TYPE}-freebsd/bin/ar XLD=/usr/local/${TOOLS_TO_TYPE}-freebsd/bin/ld XNM=/usr/local/${TOOLS_TO_TYPE}-freebsd/bin/nm XOBJCOPY=/usr/local/${TOOLS_TO_TYPE}-freebsd/bin/objcopy XOBJDUMP=/usr/local/${TOOLS_TO_TYPE}-freebsd/bin/objdump XRANLIB=/usr/local/${TOOLS_TO_TYPE}-freebsd/bin/ranlib XSIZE=/usr/local/${TOOLS_TO_TYPE}-freebsd/bin/size #NO-SUCH: XSTRINGS=/usr/local/${TOOLS_TO_TYPE}-freebsd/bin/strings XSTRINGS=/usr/local/bin/${TOOLS_TO_TYPE}-freebsd-strings .export XAS .export XAR .export XLD .export XNM .export XOBJCOPY .export XOBJDUMP .export XRANLIB .export XSIZE .export XSTRINGS .endif # # # From based on clang (via system). . . # .if ${.MAKE.LEVEL} == 0 CC=/usr/bin/clang CXX=/usr/bin/clang++ CPP=/usr/bin/clang-cpp .export CC .export CXX .export CPP .endif make.conf empty. # svnlite status M contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp M lib/csu/powerpc64/Makefile ? sys/amd64/conf/GENERIC-NODBG ? sys/amd64/include/include ? sys/arm/conf/RPI2-NODBG ? sys/arm/include/include M sys/boot/ofw/Makefile.inc M sys/boot/powerpc/Makefile.inc M sys/boot/powerpc/kboot/Makefile M sys/boot/uboot/Makefile.inc M sys/conf/Makefile.powerpc M sys/conf/kern.mk M sys/conf/kmod.mk ? sys/powerpc/conf/GENERIC64-NODBG ? sys/powerpc/conf/GENERIC64vtsc ? sys/powerpc/conf/GENERIC64vtsc-NODEBUG ? sys/powerpc/conf/GENERICvtsc ? sys/powerpc/conf/GENERICvtsc-NODEBUG ? sys/powerpc/include/include M sys/powerpc/ofw/ofw_machdep.c M sys/powerpc/powerpc/exec_machdep.c ? sys/x86/include/include (Mostly powerpc and powerpc64 tied. The include/include examples were somehow automatically generated at some point and are links back to the parent include.)