Exemple #1
0
    def test_toolset8_ubuntu(self):
        """full toolset"""
        l = llvm(toolset=True, version='8')
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        clang-8 \
        clang-format-8 \
        clang-tidy-8 \
        clang-tools-8 \
        libc++-8-dev \
        libc++1-8 \
        libc++abi1-8 \
        libclang-8-dev \
        libclang1-8 \
        liblldb-8-dev \
        libomp-8-dev \
        lld-8 \
        lldb-8 \
        llvm-8 \
        llvm-8-dev \
        llvm-8-runtime && \
    rm -rf /var/lib/apt/lists/*
RUN update-alternatives --install /usr/bin/clang clang $(which clang-8) 30 && \
    update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-8) 30 && \
    update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-8) 30 && \
    update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-8) 30 && \
    update-alternatives --install /usr/bin/lldb lldb $(which lldb-8) 30 && \
    update-alternatives --install /usr/bin/llvm-config llvm-config $(which llvm-config-8) 30 && \
    update-alternatives --install /usr/bin/llvm-cov llvm-cov $(which llvm-cov-8) 30'''
        )
Exemple #2
0
    def test_upstream_ubuntu18(self):
        """Upstream builds"""
        l = llvm(extra_tools=True, upstream=True)
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        apt-transport-https \
        ca-certificates \
        gnupg \
        wget && \
    rm -rf /var/lib/apt/lists/*
RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
    echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" >> /etc/apt/sources.list.d/hpccm.list && \
    echo "deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" >> /etc/apt/sources.list.d/hpccm.list && \
    apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        clang-11 \
        clang-format-11 \
        clang-tidy-11 \
        libomp-11-dev && \
    rm -rf /var/lib/apt/lists/*
RUN update-alternatives --install /usr/bin/clang clang $(which clang-11) 30 && \
    update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-11) 30 && \
    update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-11) 30 && \
    update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-11) 30'''
        )
    def test_defaults_centos(self):
        """Default llvm building block"""
        l = llvm()
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN yum install -y \
        clang && \
    rm -rf /var/cache/yum/*''')
Exemple #4
0
    def test_openmp_ubuntu(self):
        """openmp disabled"""
        l = llvm(openmp=False)
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        clang && \
    rm -rf /var/lib/apt/lists/*''')
Exemple #5
0
    def test_defaults_ubuntu(self):
        """Default llvm building block"""
        l = llvm()
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        clang && \
    rm -rf /var/lib/apt/lists/*''')
Exemple #6
0
    def test_runtime(self):
        """Runtime"""
        l = llvm()
        r = l.runtime()
        self.assertEqual(
            r, r'''# LLVM compiler runtime
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        libclang1 && \
    rm -rf /var/lib/apt/lists/*''')
    def test_version_centos(self):
        """LLVM compiler version"""
        l = llvm(extra_repository=True, version='7')
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN yum install -y centos-release-scl && \
    yum install -y \
        llvm-toolset-7-clang && \
    rm -rf /var/cache/yum/*
ENV LD_LIBRARY_PATH=/opt/rh/llvm-toolset-7/root/usr/lib64:$LD_LIBRARY_PATH \
    PATH=/opt/rh/llvm-toolset-7/root/usr/bin:$PATH''')
Exemple #8
0
    def test_version_ubuntu(self):
        """LLVM compiler version"""
        l = llvm(extra_repository=True, version='6.0')
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        clang-6.0 && \
    rm -rf /var/lib/apt/lists/*
RUN update-alternatives --install /usr/bin/clang clang $(which clang-6.0) 30 && \
    update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-6.0) 30'''
        )
Exemple #9
0
    def test_extra_tools_ubuntu(self):
        """clang-format and clang-tidy"""
        l = llvm(extra_tools=True)
        self.assertEqual(str(l),
r'''# LLVM compiler
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        clang \
        clang-format \
        clang-tidy \
        libomp-dev && \
    rm -rf /var/lib/apt/lists/*''')
Exemple #10
0
    def test_defaults_centos(self):
        """Default llvm building block"""
        l = llvm()
        self.assertEqual(str(l),
r'''# LLVM compiler
RUN yum install -y \
        gcc \
        gcc-c++ && \
    rm -rf /var/cache/yum/*
RUN yum install -y \
        clang && \
    rm -rf /var/cache/yum/*
ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include:$CPATH''')
Exemple #11
0
    def test_defaults_centos8(self):
        """Default llvm building block"""
        l = llvm(version='8')
        self.assertEqual(str(l),
r'''# LLVM compiler
RUN yum install -y \
        gcc \
        gcc-c++ && \
    rm -rf /var/cache/yum/*
RUN yum install -y \
        llvm-toolset-8.0.1 && \
    rm -rf /var/cache/yum/*
ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/8/include:$CPATH''')
Exemple #12
0
    def test_toolset_centos7(self):
        """full toolset"""
        l = llvm(toolset=True)
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN yum install -y \
        gcc \
        gcc-c++ && \
    rm -rf /var/cache/yum/*
RUN yum install -y \
        clang \
        llvm && \
    rm -rf /var/cache/yum/*
ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include:$CPATH''')
Exemple #13
0
    def test_aarch64_centos(self):
        """aarch64"""
        l = llvm()
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN yum install -y \
        gcc \
        gcc-c++ && \
    rm -rf /var/cache/yum/*
RUN yum install -y \
        clang && \
    rm -rf /var/cache/yum/*
ENV COMPILER_PATH=/usr/lib/gcc/aarch64-redhat-linux/4.8.2:$COMPILER_PATH \
    CPATH=/usr/include/c++/4.8.2:/usr/include/c++/4.8.2/aarch64-redhat-linux:$CPATH \
    LIBRARY_PATH=/usr/lib/gcc/aarch64-redhat-linux/4.8.2''')
Exemple #14
0
    def test_extra_tools_centos8(self):
        """Default llvm building block"""
        l = llvm(extra_tools=True, version='8')
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN yum install -y \
        gcc \
        gcc-c++ && \
    rm -rf /var/cache/yum/*
RUN yum install -y \
        clang \
        clang-tools-extra \
        libomp \
        llvm-libs && \
    rm -rf /var/cache/yum/*
ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/8/include:$CPATH''')
Exemple #15
0
    def test_version_centos(self):
        """LLVM compiler version"""
        l = llvm(extra_repository=True, extra_tools=True, version='7')
        self.assertEqual(str(l),
r'''# LLVM compiler
RUN yum install -y \
        gcc \
        gcc-c++ && \
    rm -rf /var/cache/yum/*
RUN yum install -y centos-release-scl && \
    yum install -y \
        llvm-toolset-7-clang \
        llvm-toolset-7-clang-tools-extra \
        llvm-toolset-7-libomp-devel && \
    rm -rf /var/cache/yum/*
ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include:$CPATH \
    LD_LIBRARY_PATH=/opt/rh/llvm-toolset-7/root/usr/lib64:$LD_LIBRARY_PATH \
    PATH=/opt/rh/llvm-toolset-7/root/usr/bin:$PATH''')
Exemple #16
0
def main():
    ############################################################################
    # setup basics
    ############################################################################
    hpccm.config.set_container_format('singularity')
    hpccm.config.set_singularity_version('3.3')

    stage0 = hpccm.Stage()
    stage0 += baseimage(image='ubuntu:bionic')

    stage0 += packages(ospackages=[
        'git', 'g++', 'wget', 'pkg-config', 'less', 'uuid-dev', 'gdb',
        'locales', 'gpg-agent', 'gnupg2', 'locales-all', 'unzip'
    ])
    # set language to en_US.UTF-8 to avoid some problems with the cling output system
    stage0 += shell(
        commands=['locale-gen en_US.UTF-8', 'update-locale LANG=en_US.UTF-8'])

    ############################################################################
    # install clang/llvm
    ############################################################################
    stage0 += llvm(version='9', extra_repository=True)

    ############################################################################
    # install ninja build system
    ############################################################################
    stage0 += shell(commands=[
        'cd /opt', 'wget --no-check-certificate ' +
        'https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip',
        'unzip ninja-linux.zip', 'mv ninja /usr/local/bin/',
        'rm ninja-linux.zip', 'cd -'
    ])

    ############################################################################
    # install cmake
    ############################################################################
    stage0 += cmake(eula=True, version='3.16.1')

    ############################################################################
    # write recipe.def
    ############################################################################
    with open('recipe.def', 'w') as filehandle:
        filehandle.write(stage0.__str__())
Exemple #17
0
    def test_toolset_ubuntu18(self):
        """full toolset"""
        l = llvm(toolset=True)
        self.assertEqual(
            str(l), r'''# LLVM compiler
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        clang \
        clang-format \
        clang-tidy \
        libc++-dev \
        libc++1 \
        libc++abi1 \
        libclang-dev \
        libclang1 \
        libomp-dev \
        lldb \
        llvm \
        llvm-dev \
        llvm-runtime && \
    rm -rf /var/lib/apt/lists/*''')
    def test_upstream_aarch64(self):
        """Upstream builds for aarch64"""
        l = llvm(upstream=True, version='11')
        self.assertMultiLineEqual(
            str(l), r'''# LLVM compiler
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        apt-transport-https \
        ca-certificates \
        gnupg \
        wget && \
    rm -rf /var/lib/apt/lists/*
RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
    echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main" >> /etc/apt/sources.list.d/hpccm.list && \
    echo "deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main" >> /etc/apt/sources.list.d/hpccm.list && \
    apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        clang-11 \
        libomp-11-dev && \
    rm -rf /var/lib/apt/lists/*
RUN update-alternatives --install /usr/bin/clang clang $(which clang-11) 30 && \
    update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-11) 30'''
        )
def add_clang(stage: hpccm.Stage, ubuntu_version: str, version: str):
    """Add commands to stage to install clang.

    :param stage: hpccm Stage
    :type stage: hpccm.Stage
    :param ubuntu_version: Ubuntu version number: '16.04' or '18.04'
    :type ubuntu_version: str
    :param version: Clang version: 5.0 - 7.0 or 8 - 9
    :type version: str

    """
    if ubuntu_version == '16.04':
        distro_name = 'xenial'
    elif ubuntu_version == '18.04':
        distro_name = 'bionic'
    else:
        print('clang error: unsupported Ubuntu version: ' + ubuntu_version,
              file=sys.stderr)
        print('supported Ubuntu version: 16.04, 18.04', file=sys.stderr)
        return

    # clang/llvm changed its name pattern and the ppa sources with clang 8
    # https://apt.llvm.org/
    ppa_version = '' if float(version) < 8.0 else '-' + str(version)

    stage += shell(commands=[
        'wget http://llvm.org/apt/llvm-snapshot.gpg.key',
        'apt-key add llvm-snapshot.gpg.key', 'rm llvm-snapshot.gpg.key',
        'echo "" >> /etc/apt/sources.list', 'echo "deb http://apt.llvm.org/' +
        distro_name + '/ llvm-toolchain-' + distro_name + ppa_version +
        ' main" >> /etc/apt/sources.list',
        'echo "deb-src http://apt.llvm.org/' + distro_name +
        '/ llvm-toolchain-' + distro_name + ppa_version +
        ' main" >> /etc/apt/sources.list'
    ])
    stage += llvm(version=str(version))
Exemple #20
0
 def test_ppc64le_centos(self):
     """ppc64le"""
     with self.assertRaises(RuntimeError):
         llvm()
Exemple #21
0
 def test_upstream_aarch64(self):
     """Upstream builds for aarch64"""
     with self.assertRaises(RuntimeError):
         llvm(upstream=True, version='11')
Exemple #22
0
 def test_toolchain_zen2(self):
     """CPU arch optimization flags"""
     l = llvm()
     tc = l.toolchain
     self.assertEqual(tc.CFLAGS, '-march=znver2 -mtune=znver2')
     self.assertEqual(tc.CXXFLAGS, '-march=znver2 -mtune=znver2')
Exemple #23
0
 def test_toolchain(self):
     """Toolchain"""
     l = llvm()
     tc = l.toolchain
     self.assertEqual(tc.CC, 'clang')
     self.assertEqual(tc.CXX, 'clang++')