pulp-platform / pulp-sdk

Apache License 2.0
99 stars 73 forks source link

Pulp-SDK fails to build under GCC 11.1.0 #102

Open TobiasFaller opened 3 years ago

TobiasFaller commented 3 years ago

GCC 11.1.0 fails to build pulp-sdk with the following error message:

src/vp.cpp: In member function 'js::config* vp::component::get_vp_config()':
/pulp-sdk/install/workstation/include/vp/trace/trace.hpp:119:40: error: 'this' pointer is null [-Werror=nonnull]
  119 |       ((vp::trace *)(trace_ptr))->fatal(msg);      \
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
src/vp.cpp:235:5: note: in expansion of macro 'vp_assert_always'
  235 |     vp_assert_always(this->vp_config != NULL, NULL, "No VP config found\n");
      |     ^~~~~~~~~~~~~~~~
In file included from /pulp-sdk/install/workstation/include/vp/vp.hpp:28,
                 from src/vp.cpp:27:
/pulp-sdk/install/workstation/include/vp/trace/implementation.hpp:112:15: note: in a call to non-static member function 'void vp::trace::fatal(const char*, ...)'
  112 |   inline void vp::trace::fatal(const char *fmt, ...)
      |               ^~
cc1plus: all warnings being treated as errors

This seems to be a bug in the null pointer detection, as the null pointer is never dereferenced in this function. See: gvsoc/engine/include/vp/trace/trace.hpp#L102

As this is a GCC bug and not trivial to fix a workaround should be documented. I will update the documentation with a workaround as a MR.

How to reproduce

FROM ubuntu:20.04

ENV DEBIAN_FRONTEND "noninteractive"
ENV TZ "Europe/Berlin"

RUN apt-get update \
  && apt-get install -y software-properties-common \
  && add-apt-repository -y ppa:ubuntu-toolchain-r/test \
  && apt-get update \
  && apt-get install -y \
    git libftdi-dev libftdi1 doxygen python3-pip libsdl2-dev curl cmake \
    libusb-1.0-0-dev scons gtkwave libsndfile1-dev rsync autoconf \
    automake texinfo libtool pkg-config libsdl2-ttf-dev \
    autotools-dev libmpc-dev libmpfr-dev libgmp-dev gawk bison flex gperf \
    patchutils bc zlib1g-dev swig3.0 libjpeg-dev lsb-core \
    sox graphicsmagick-libmagick-dev-compat libswitch-perl libftdi1-dev \
    g++-11 gcc-11 \
  && pip3 install --user argcomplete pyelftools artifactory twisted \
    prettytable sqlalchemy pyelftools 'openpyxl==2.6.4' xlsxwriter \
    pyyaml numpy configparser pyvcd sphinx

RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11
RUN gcc --version
RUN g++ --version

RUN cd / \
  && git clone --depth 1 https://github.com/pulp-platform/pulp-riscv-gnu-toolchain.git pulp-riscv-gnu-toolchain \
  && cd pulp-riscv-gnu-toolchain \
  && git submodule update --init --recursive \
  && ./configure --prefix=/opt/riscv --with-arch=rv32imc --with-cmodel=medlow --enable-multilib \
  && make -j

ENV PULP_RISCV_GCC_TOOLCHAIN="/opt/riscv"
ENV PATH="${PULP_RISCV_GCC_TOOLCHAIN}/bin:/root/.local/bin/:${PATH}"

RUN cd / \
  && git clone --depth 1 https://github.com/pulp-platform/pulp-sdk.git pulp-sdk \
  && cd pulp-sdk \
  && git submodule update --init --recursive \
  && source configs/pulp-open.sh \
  && make build
dogukan-bicer commented 6 months ago

can anyone solve it? I encountered the same error

TobiasFaller commented 6 months ago

can anyone solve it? I encountered the same error

Hey @dogukan-bicer, have a look at https://github.com/pulp-platform/gvsoc/pull/15 which contains a fix for the problematic Makefile. Additionally, have a look at the following PRs which contain more required fixes to build the pulp platform:

Best Regards, Tobias

dogukan-bicer commented 6 months ago

I made the edits in pr. I even ran it as "VP_WORKAROUND_NONNULL_BUG=yes make build-pulp-sdk", but I still got the error 'this' pointer is null [-Werror=nonnull]. I am using ubuntu 22.04.4 as the operating system.

TobiasFaller commented 6 months ago

I made the edits in pr. I even ran it as "VP_WORKAROUND_NONNULL_BUG=yes make build-pulp-sdk", but I still got the error 'this' pointer is null [-Werror=nonnull]. I am using ubuntu 22.04.4 as the operating system.

Make sure that your sources actually include the fix for GVSOC, which disables treating this warning as an error (-Wno-error=nonnull). The environment variable VP_WORKAROUND_NONNULL_BUG=yes has no effect as the respective Pull Request (https://github.com/pulp-platform/gvsoc/pull/15) never was merged into GVSOC.