From 2a82e36e712b9b9242d2b9f315519f98edbc1761 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Thu, 2 Nov 2023 16:12:08 +0100 Subject: [PATCH] chore(ci): adding support for address-sanitizer images' build in dockerfiles Signed-off-by: Raphael Defosseux --- docker/Dockerfile.build.ubuntu20 | 5 ++++- docker/Dockerfile.eNB.ubuntu20 | 10 ++++++++-- docker/Dockerfile.gNB.ubuntu20 | 9 ++++++++- docker/Dockerfile.lteUE.ubuntu20 | 9 ++++++++- docker/Dockerfile.nr-cuup.ubuntu20 | 6 ++++++ docker/Dockerfile.nrUE.ubuntu20 | 8 +++++++- docker/README.md | 25 +++++++++++++++++++++++++ 7 files changed, 66 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile.build.ubuntu20 b/docker/Dockerfile.build.ubuntu20 index 807b7d258a..b5f8305ad2 100644 --- a/docker/Dockerfile.build.ubuntu20 +++ b/docker/Dockerfile.build.ubuntu20 @@ -26,6 +26,7 @@ #--------------------------------------------------------------------- FROM ran-base:latest as ran-build +ARG SANITIZE_OPTION RUN rm -Rf /oai-ran WORKDIR /oai-ran @@ -35,4 +36,6 @@ COPY . . RUN /bin/sh oaienv && \ cd cmake_targets && \ mkdir -p log && \ - ./build_oai --eNB --gNB --RU --UE --nrUE --ninja --build-lib "telnetsrv enbscope uescope nrscope nrqtscope" -w USRP -t Ethernet --noavx512 -c --cmake-opt -DCMAKE_C_FLAGS=-Werror --cmake-opt -DCMAKE_CXX_FLAGS=-Werror + ./build_oai --eNB --gNB --RU --UE --nrUE --ninja --build-lib "telnetsrv enbscope uescope nrscope nrqtscope" -w USRP -t Ethernet --noavx512 -c --cmake-opt -DCMAKE_C_FLAGS=-Werror --cmake-opt -DCMAKE_CXX_FLAGS=-Werror $SANITIZE_OPTION && \ + # Mainly to see if the sanitize option was perfectly executed + ldd ran_build/build/nr-softmodem diff --git a/docker/Dockerfile.eNB.ubuntu20 b/docker/Dockerfile.eNB.ubuntu20 index 15418474a9..618e0085e1 100644 --- a/docker/Dockerfile.eNB.ubuntu20 +++ b/docker/Dockerfile.eNB.ubuntu20 @@ -32,6 +32,7 @@ FROM ran-build:latest AS enb-build #start from scratch for target executable FROM ubuntu:focal as oai-enb +ARG SANITIZE_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Paris @@ -57,6 +58,11 @@ RUN apt-get update && \ python3-six \ python3-requests \ libusb-1.0-0 && \ +# if the --sanitize option was used to build, additional packages are required + /bin/bash -c 'if [[ "$SANITIZE_OPTION" = "--sanitize" ]]; then DEBIAN_FRONTEND=noninteractive apt-get install --yes \ + libasan5 \ + libubsan1 \ + liblapacke; fi' && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-enb/bin @@ -93,8 +99,8 @@ COPY --from=enb-base \ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so /usr/local/lib/liboai_transpro.so" && \ - ldconfig - + ldconfig && \ + ldd /opt/oai-enb/bin/lte-softmodem WORKDIR /opt/oai-enb diff --git a/docker/Dockerfile.gNB.ubuntu20 b/docker/Dockerfile.gNB.ubuntu20 index f9ee719839..fcbcf9e628 100644 --- a/docker/Dockerfile.gNB.ubuntu20 +++ b/docker/Dockerfile.gNB.ubuntu20 @@ -32,6 +32,7 @@ FROM ran-build:latest AS gnb-build #start from scratch for target executable FROM ubuntu:focal as oai-gnb +ARG SANITIZE_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe @@ -56,6 +57,11 @@ RUN apt-get update && \ python3-six \ python3-requests \ libusb-1.0-0 && \ +# if the --sanitize option was used to build, additional packages are required + /bin/bash -c 'if [[ "$SANITIZE_OPTION" = "--sanitize" ]]; then DEBIAN_FRONTEND=noninteractive apt-get install --yes \ + libasan5 \ + libubsan1 \ + liblapacke; fi' && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-gnb/bin @@ -91,7 +97,8 @@ COPY --from=gnb-base \ /usr/lib/x86_64-linux-gnu/ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ - ldconfig + ldconfig && \ + ldd /opt/oai-gnb/bin/nr-softmodem WORKDIR /opt/oai-gnb #EXPOSE 2152/udp # S1U, GTP/UDP diff --git a/docker/Dockerfile.lteUE.ubuntu20 b/docker/Dockerfile.lteUE.ubuntu20 index dc7376e644..37a8794b67 100644 --- a/docker/Dockerfile.lteUE.ubuntu20 +++ b/docker/Dockerfile.lteUE.ubuntu20 @@ -32,6 +32,7 @@ FROM ran-build:latest AS lte-ue-build #start from scratch for target executable FROM ubuntu:focal as oai-lte-ue +ARG SANITIZE_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Paris @@ -56,6 +57,11 @@ RUN apt-get update && \ iputils-ping \ iproute2 \ iperf && \ +# if the --sanitize option was used to build, additional packages are required + /bin/bash -c 'if [[ "$SANITIZE_OPTION" = "--sanitize" ]]; then DEBIAN_FRONTEND=noninteractive apt-get install --yes \ + libasan5 \ + libubsan1 \ + liblapacke; fi' && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-lte-ue/bin @@ -94,7 +100,8 @@ COPY --from=lte-ue-base \ /usr/lib/x86_64-linux-gnu/ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ - ldconfig + ldconfig && \ + ldd /opt/oai-lte-ue/bin/lte-uesoftmodem WORKDIR /opt/oai-lte-ue CMD ["/opt/oai-lte-ue/bin/lte-uesoftmodem"] diff --git a/docker/Dockerfile.nr-cuup.ubuntu20 b/docker/Dockerfile.nr-cuup.ubuntu20 index 222a4dd361..e05dc5055a 100644 --- a/docker/Dockerfile.nr-cuup.ubuntu20 +++ b/docker/Dockerfile.nr-cuup.ubuntu20 @@ -31,6 +31,7 @@ FROM ran-build:latest AS gnb-build FROM ubuntu:focal as oai-nr-cuup +ARG SANITIZE_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe @@ -40,6 +41,11 @@ RUN apt-get update && \ libsctp1 \ libconfig9 \ openssl && \ +# if the --sanitize option was used to build, additional packages are required + /bin/bash -c 'if [[ "$SANITIZE_OPTION" = "--sanitize" ]]; then DEBIAN_FRONTEND=noninteractive apt-get install --yes \ + libasan5 \ + libubsan1 \ + liblapacke; fi' && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-gnb/bin diff --git a/docker/Dockerfile.nrUE.ubuntu20 b/docker/Dockerfile.nrUE.ubuntu20 index a4b63d3cef..7d66890ceb 100644 --- a/docker/Dockerfile.nrUE.ubuntu20 +++ b/docker/Dockerfile.nrUE.ubuntu20 @@ -32,6 +32,7 @@ FROM ran-build:latest AS nr-ue-build #start from scratch for target executable FROM ubuntu:focal as oai-nr-ue +ARG SANITIZE_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Paris @@ -56,6 +57,10 @@ RUN apt-get update && \ iputils-ping \ iproute2 \ iperf && \ +# if the --sanitize option was used to build, additional packages are required + /bin/bash -c 'if [[ "$SANITIZE_OPTION" = "--sanitize" ]]; then DEBIAN_FRONTEND=noninteractive apt-get install --yes \ + libasan5 \ + libubsan1; fi' && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-nr-ue/bin @@ -95,7 +100,8 @@ COPY --from=nr-ue-base \ /usr/lib/x86_64-linux-gnu/ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ - ldconfig + ldconfig && \ + ldd /opt/oai-nr-ue/bin/nr-uesoftmodem WORKDIR /opt/oai-nr-ue CMD ["/opt/oai-nr-ue/bin/nr-uesoftmodem", "-O", "/opt/oai-nr-ue/etc/nr-ue.conf"] diff --git a/docker/README.md b/docker/README.md index ebfaefb3d2..b0377b2c5a 100644 --- a/docker/README.md +++ b/docker/README.md @@ -114,6 +114,23 @@ ran-base latest 5c9c02a5b4a8 1 minute ago Note that the steps are identical for `rocky-linux`. +You can also create `address-sanitizer` version of the ran-build image. This is only available for the Ubuntu-20 version. + +```bash +docker build --target ran-build --tag ran-build:latest --file docker/Dockerfile.build.ubuntu20 --build-arg "SANITIZE_OPTION=--sanitize" . +``` + +After building: + +```bash +docker image ls +REPOSITORY TAG IMAGE ID CREATED SIZE +ran-build latest f2633a7f5102 1 minute ago 8.78GB +... +``` + +Note that the image is much bigger. + ## 3.3. Building any target image ## For example, the eNB: @@ -141,6 +158,14 @@ docker image prune --force Note that the steps are identical for `rocky-linux`. +If you have used the sanitizer option, then you should also pass it when building the target image: + +```bash +docker build --target oai-gnb --tag oai-gnb:latest --file docker/Dockerfile.gNB.ubuntu20 --build-arg "SANITIZE_OPTION=--sanitize" . +``` + +Normally the target image will be around 200 Mbytes bigger. + # 4. Building using `podman` under Red Hat Entreprise Linux 8.2 # Analogous to the above steps: