OpenOCD icon indicating copy to clipboard operation
OpenOCD copied to clipboard

Build fails in branch openocd-cubeide-r4 or tag openocd-cubeide-v1.8.0 or later [-Werror=maybe-uninitialized]

Open etienz opened this issue 3 years ago • 3 comments

Build fails in fresh docker build on branch openocd-cubeide-r4 or tag openocd-cubeide-v1.8.0 or later. Tag openocd-cubeide-v1.7.0 and branch openocd-cubeide-r3 build fine.

Docker commands:

ARG VARIANT="focal"
FROM ubuntu:${VARIANT} AS openocd-builder

ARG OPENOCD_PATH=/opt/openocd-stm

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
    && apt-get -y install --no-install-recommends \
    build-essential \
    ca-certificates \
    git \
    # build tools for openocd
    libhidapi-dev \
    libusb-1.0-0-dev \
    libusb-dev \
    libtool \ 
    make \
    automake \
    autoconf \
    pkg-config \
    tclsh \
    telnet \
 && rm -rf /var/lib/apt/lists/*

RUN git clone --branch openocd-cubeide-r4 https://github.com/STMicroelectronics/OpenOCD.git ${OPENOCD_PATH} \
 && cd ${OPENOCD_PATH} \
 && ./bootstrap \
 && ./configure --enable-stlink \
 && make -j"$($(nproc) + 2)"

Full error message:

#6 67.64 /bin/bash ./libtool  --tag=CC   --mode=link gcc -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Wpointer-arith -Wundef -Wno-error=deprecated-declarations -Werror -g -O2   -o src/target/openrisc/libopenrisc.la  src/target/openrisc/or1k.lo src/target/openrisc/or1k_du_adv.lo src/target/openrisc/or1k_tap_mohor.lo src/target/openrisc/or1k_tap_vjtag.lo src/target/openrisc/or1k_tap_xilinx_bscan.lo src/target/openrisc/jsp_server.lo  -lutil -ldl
#6 67.71 In file included from ./src/helper/list.h:21,
#6 67.71                  from ./src/helper/binarybuffer.h:25,
#6 67.71                  from src/jtag/drivers/stlink_usb.c:37:
#6 67.71 src/jtag/drivers/stlink_usb.c: In function 'stlink_dap_op_queue_run_internal':
#6 67.71 mv -f src/target/.deps/libtarget_la-armv8_dpm.Tpo src/target/.deps/libtarget_la-armv8_dpm.Plo
#6 67.74 ./src/helper/types.h:194:9: error: 'misc_items' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#6 67.74   194 |  buf[0] = (uint8_t) (val >> 0);
#6 67.74       |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#6 67.74 src/jtag/drivers/stlink_usb.c:4595:20: note: 'misc_items' was declared here
#6 67.74  4595 |  unsigned int cnt, misc_items;
#6 67.74       |                    ^~~~~~~~~~

etienz avatar Sep 06 '22 21:09 etienz

I encountered the same issue. I simply initialized the misc_items to 0 and passed the compilation.

XiaZhouZero avatar Oct 09 '22 13:10 XiaZhouZero

Thanks @etienz and @XiaZhouZero for reporting this. It seems that we are building using a difference GCC version that's why we have not encountered the same issue as you.

could you please share with us the GCC version you are using, so we can fix this in the official openocd gerrit

tarek-bochkati avatar Dec 22 '22 14:12 tarek-bochkati

I'm using the GCC 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) @tarek-bochkati

XiaZhouZero avatar Feb 03 '23 12:02 XiaZhouZero