[cpp-linbuild] branch main updated: SSPCPP-999 Demonstrate C++14 features on CentOS/RHEL 7

John W. O'Brien john at saltant.com
Tue Dec 31 20:51:24 UTC 2024


This is an automated email from the git hooks/post-receive script.

obrienjw pushed a commit to branch main
in repository cpp-linbuild.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-linbuild.git;a=commit;h=f1cd23b6fb783c2dee8b6abb48d16cbe65f5df0a

The following commit(s) were added to refs/heads/main by this push:
     new f1cd23b  SSPCPP-999 Demonstrate C++14 features on CentOS/RHEL 7
f1cd23b is described below

commit f1cd23b6fb783c2dee8b6abb48d16cbe65f5df0a
Author: John W. O'Brien <john at saltant.com>
AuthorDate: Tue Dec 31 20:10:14 2024 +0000

    SSPCPP-999 Demonstrate C++14 features on CentOS/RHEL 7
    
    This patch adds the devtoolset-7 package to the centos7 and rhel7
    builder images, and creates a standalone SPEC file to demonstrate
    building an RPM with C++14 features (initially only
    std::shared_timed_mutex). The affected builder images do not enable
    the upgraded toolchain by default, and the top-level Makefile has
    no knowledge of the demo SPEC file.
    
    To exercise the demonstration launch the builder container
    interactively with the `run_container_<platform>` target. On centos7
    or rhel7 (x86-64 only), enable the upgraded toolchain.
    
        source /opt/rh/devtoolset-7/enable
    
    Then build the demo.
    
        sh -e /opt/build/external/in/build.sh sspcpp999
---
 common/SPECS/sspcpp999.spec | 55 +++++++++++++++++++++++++++++++++++++++++++++
 os/centos7/image/Dockerfile |  9 ++++++++
 os/rhel7/image/Dockerfile   |  2 ++
 3 files changed, 66 insertions(+)

diff --git a/common/SPECS/sspcpp999.spec b/common/SPECS/sspcpp999.spec
new file mode 100644
index 0000000..6797b0a
--- /dev/null
+++ b/common/SPECS/sspcpp999.spec
@@ -0,0 +1,55 @@
+Name:           sspcpp999
+Version:        1.0
+Release:        1%{?dist}
+Summary:        A simple demonstration that uses C++14 features
+
+License:        CC-BY-3.0
+
+BuildRequires:  gcc-c++
+
+%description
+A package demonstrating C++14 library features as listed at
+https://en.cppreference.com/w/cpp/14
+
+%prep
+cat <<EOF > %{name}.cc
+// https://en.cppreference.com/w/cpp/thread/shared_timed_mutex
+#include <mutex>
+#include <shared_mutex>
+
+class R
+{
+    mutable std::shared_timed_mutex mut;
+    /* data */
+public:
+    R& operator=(const R& other)
+    {
+        // requires exclusive ownership to write to *this
+        std::unique_lock<std::shared_timed_mutex> lhs(mut, std::defer_lock);
+        // requires shared ownership to read from other
+        std::shared_lock<std::shared_timed_mutex> rhs(other.mut, std::defer_lock);
+        std::lock(lhs, rhs);
+        /* assign data */
+        return *this;
+    }
+};
+
+int main()
+{
+    R r;
+}
+EOF
+
+%build
+g++ -o %{name} %{name}.cc
+
+%install
+mkdir -p $RPM_BUILD_ROOT/%{_bindir}
+cp %{name} $RPM_BUILD_ROOT/%{_bindir}
+
+%files
+%{_bindir}/%{name}
+
+%changelog
+* Tue Dec 31 2024 John W. O'Brien <john at saltant.com> - 1.0-1
+- Initial sspcpp999 package
diff --git a/os/centos7/image/Dockerfile b/os/centos7/image/Dockerfile
index bac2ac5..4303b93 100644
--- a/os/centos7/image/Dockerfile
+++ b/os/centos7/image/Dockerfile
@@ -13,6 +13,15 @@ RUN sed -i \
         openldap-devel openssl-devel pkgconfig \
         rpm-build stunnel systemd-devel unixODBC-devel zlib-devel \
         createrepo \
+    ; if [ $(uname -m) == "x86_64" ]; then \
+    yum -y install centos-release-scl \
+    && sed -i \
+        -e "s/^mirrorlist/#mirrorlist/" \
+        -e "s|^# \?baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|" \
+        /etc/yum.repos.d/CentOS-SCLo-scl.repo \
+        /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo \
+    && yum -y install devtoolset-7 \
+    ; fi \
     && yum clean all
 
 # internal and external are w.r.t. a container, where external locations
diff --git a/os/rhel7/image/Dockerfile b/os/rhel7/image/Dockerfile
index 4356219..2435e78 100644
--- a/os/rhel7/image/Dockerfile
+++ b/os/rhel7/image/Dockerfile
@@ -4,6 +4,7 @@ COPY *.repo /etc/yum.repos.d/
 
 RUN yum-config-manager \
         --enable rhel-7-server-optional-rpms \
+        --enable rhel-server-rhscl-7-rpms \
     && yum -y update \
     && yum -y install \
         autoconf automake boost-devel chrpath doxygen gcc-c++ git groff \
@@ -11,6 +12,7 @@ RUN yum-config-manager \
         openldap-devel openssl-devel pkgconfig \
         rpm-build stunnel systemd-devel unixODBC-devel zlib-devel \
         createrepo \
+        devtoolset-7 \
     && yum clean all
 
 # internal and external are w.r.t. a container, where external locations

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list