From 62a5c4996c6d9f265a945a6e838053e8d85b5dd2 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 19 Apr 2023 22:26:43 +0200 Subject: [PATCH] Add clang build on OpenShift Cluster Add Dockerfile, OpenShift build config, and OpenShift image stream, to compile OAI using clang, notably to get compiler warnings and keep it OAI compilable using clang. --- ci-scripts/cls_cluster.py | 11 +++++++-- docker/Dockerfile.clang.rhel8.2 | 43 +++++++++++++++++++++++++++++++++ openshift/oai-clang-bc.yaml | 39 ++++++++++++++++++++++++++++++ openshift/oai-clang-is.yaml | 30 +++++++++++++++++++++++ 4 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 docker/Dockerfile.clang.rhel8.2 create mode 100644 openshift/oai-clang-bc.yaml create mode 100644 openshift/oai-clang-is.yaml diff --git a/ci-scripts/cls_cluster.py b/ci-scripts/cls_cluster.py index 487e203d36..d5586dee88 100644 --- a/ci-scripts/cls_cluster.py +++ b/ci-scripts/cls_cluster.py @@ -273,11 +273,18 @@ class Cluster: ranbuild_job = self._start_build('ran-build') attemptedImages += ['ran-build'] - wait = ranbuild_job is not None and physim_job is not None and self._wait_build_end([ranbuild_job, physim_job], 1200) - if not wait: logging.error('error during build of ranbuild_job or physim_job') + self._recreate_is_tag('oai-clang', imageTag, 'openshift/oai-clang-is.yaml') + self._recreate_bc('oai-clang', imageTag, 'openshift/oai-clang-bc.yaml') + self._retag_image_statement('ran-base', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-base', baseTag, 'docker/Dockerfile.clang.rhel8.2') + clang_job = self._start_build('oai-clang') + attemptedImages += ['oai-clang'] + + wait = ranbuild_job is not None and physim_job is not None and clang_job is not None and self._wait_build_end([ranbuild_job, physim_job, clang_job], 1200) + if not wait: logging.error('error during build of ranbuild_job or physim_job or clang_job') status = status and wait self.cmd.run(f'oc logs {ranbuild_job} &> cmake_targets/log/ran-build.log') self.cmd.run(f'oc logs {physim_job} &> cmake_targets/log/oai-physim.log') + self.cmd.run(f'oc logs {clang_job} &> cmake_targets/log/oai-clang.log') self.cmd.run(f'oc get pods.metrics.k8s.io &>> cmake_targets/log/build-metrics.log', '\$', 10) if status: diff --git a/docker/Dockerfile.clang.rhel8.2 b/docker/Dockerfile.clang.rhel8.2 new file mode 100644 index 0000000000..11ead620ee --- /dev/null +++ b/docker/Dockerfile.clang.rhel8.2 @@ -0,0 +1,43 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Dockerfile for the Open-Air-Interface BUILD service +# Valid for RHEL8 +# +#--------------------------------------------------------------------- + +FROM ran-base:latest AS oai-clang + +RUN rm -Rf /oai-ran +WORKDIR /oai-ran +COPY . . + +#only install LLVM (clang, ...) for this container, the others don't need it +RUN yum install -y llvm-toolset + +#run build_oai to build the target image +RUN /bin/sh oaienv && \ + cd cmake_targets && \ + mkdir -p log && \ + export CC=/usr/bin/clang && \ + export CXX=/usr/bin/clang++ && \ + ./build_oai --phy_simulators --gNB --eNB --nrUE --UE --ninja --verbose-ci --noavx512 -c --cmake-opt -DCMAKE_C_FLAGS=-Werror --cmake-opt -DCMAKE_CXX_FLAGS=-Werror diff --git a/openshift/oai-clang-bc.yaml b/openshift/oai-clang-bc.yaml new file mode 100644 index 0000000000..f882df8700 --- /dev/null +++ b/openshift/oai-clang-bc.yaml @@ -0,0 +1,39 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- + +kind: BuildConfig +apiVersion: build.openshift.io/v1 +metadata: + name: "oai-clang" +spec: + runPolicy: "Serial" + nodeSelector: + kubernetes.io/hostname: theseus + source: + type: "Binary" + strategy: + dockerStrategy: + dockerfilePath: "docker/Dockerfile.clang.rhel8.2" + output: + to: + kind: "ImageStreamTag" + name: "oai-clang:latest" diff --git a/openshift/oai-clang-is.yaml b/openshift/oai-clang-is.yaml new file mode 100644 index 0000000000..d1d4c477f4 --- /dev/null +++ b/openshift/oai-clang-is.yaml @@ -0,0 +1,30 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: + name: oai-clang + namespace: oaicicd-ran +spec: + lookupPolicy: + local: true