From a93e20a58fefde4e69e1d9c1b669947aec63918b Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 30 Nov 2016 13:20:26 +0000 Subject: [PATCH] Added dockerfile for march=core2 compilation Former-commit-id: 619c644acfdbb7373a05db09fb3e4eb4c86046cb --- core2.Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ docker/README | 3 +++ docker/g++ | 12 ++++++++++++ docker/gcc | 12 ++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 core2.Dockerfile create mode 100644 docker/README create mode 100755 docker/g++ create mode 100755 docker/gcc diff --git a/core2.Dockerfile b/core2.Dockerfile new file mode 100644 index 00000000..342f7382 --- /dev/null +++ b/core2.Dockerfile @@ -0,0 +1,36 @@ +#Pull in previously built packages image with lots of libraries. +FROM packages + +# Prepare directories +RUN mkdir /code +WORKDIR /code + +# Copy repository files +COPY ccd_defs_check.py /code/ccd_defs_check.py +COPY CMakeLists.txt /code/CMakeLists.txt +COPY configure.sh /code/configure.sh +COPY /.git/ /code/.git/ +COPY .gitignore /code/.gitignore +COPY .gitmodules /code/.gitmodules +COPY /modules/ /code/modules/ +COPY /opendm/ /code/opendm/ +COPY /patched_files/ /code/patched_files/ +COPY run.py /code/run.py +COPY /scripts/ /code/scripts/ +COPY /SuperBuild/cmake/ /code/SuperBuild/cmake/ +COPY /SuperBuild/CMakeLists.txt /code/SuperBuild/CMakeLists.txt +COPY /tests/ /code/tests/ + +# Update submodules +RUN git submodule init && git submodule update + +# Replace g++ and gcc with our own scripts +COPY /docker/ /code/docker/ +RUN mv -v /usr/bin/gcc /usr/bin/gcc_real && mv -v /usr/bin/g++ /usr/bin/g++_real && cp -v /code/docker/gcc /usr/bin/gcc && cp -v /code/docker/g++ /usr/bin/g++ + +#Compile code in SuperBuild and root directories +RUN cd SuperBuild && mkdir build && cd build && cmake .. && make -j$(nproc) \ + && cd ../.. && mkdir build && cd build && cmake .. && make -j$(nproc) + +# Entry point +ENTRYPOINT ["python", "/code/run.py", "--project-path", "/code/"] diff --git a/docker/README b/docker/README new file mode 100644 index 00000000..4b305a17 --- /dev/null +++ b/docker/README @@ -0,0 +1,3 @@ +The g++ and gcc scripts in this directory are used to replace the real g++ and gcc programs so that compilation across all projects (including dependencies) uses the -march=core2 flag, which allows us to build a docker image compatible with most CPU architectures. + +Without the -march=core2 flag, a docker image will contain binaries that are optimized for the machine that built the image, and will not run on older machines. diff --git a/docker/g++ b/docker/g++ new file mode 100755 index 00000000..0206851b --- /dev/null +++ b/docker/g++ @@ -0,0 +1,12 @@ +#!/bin/bash + +args="" + +for i in "$@" +do + if [[ $i != -march* ]]; then + args="$args $i" + fi +done + +/usr/bin/g++_real -march=core2 $args diff --git a/docker/gcc b/docker/gcc new file mode 100755 index 00000000..d72824c6 --- /dev/null +++ b/docker/gcc @@ -0,0 +1,12 @@ +#!/bin/bash + +args="" + +for i in "$@" +do + if [[ $i != -march* ]]; then + args="$args $i" + fi +done + +/usr/bin/gcc_real -march=core2 $args