-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (46 loc) · 1.73 KB
/
Dockerfile
File metadata and controls
55 lines (46 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Use Fedora as it has llvm-4 packages that seem to work
FROM fedora
RUN dnf -y update && dnf clean all
RUN dnf -y install llvm-4.0.1 llvm-devel-4.0.1 llvm-libs-4.0.1 \
llvm-static-4.0.1 clang-4.0.1 \
ncurses-devel zlib-devel \
git cmake which findutils \
&& dnf clean all
ENV CMAKE_BUILD_TYPE Release
ENV MAKE_JOBS 4
# Modified clang
RUN mkdir -p /opt/src/ \
&& git clone https://github.com/flang-compiler/clang.git /opt/src/clang \
&& cd /opt/src/clang \
&& git checkout flang_release_40 \
&& mkdir build && cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
&& make -j ${MAKE_JOBS} \
&& make install \
&& rm -rf /opt/src/clang
# OpenMP required by flang
RUN git clone https://github.com/llvm-mirror/openmp.git /opt/src/openmp \
&& cd /opt/src/openmp/runtime \
&& git checkout release_40 \
&& mkdir build && cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
&& make -j ${MAKE_JOBS} \
&& make install \
&& rm -rf /opt/src/openmp
# Compile flang with modified clang
RUN git clone https://github.com/flang-compiler/flang.git /opt/src/flang \
&& cd /opt/src/flang \
&& mkdir build && cd build \
&& cmake -DLLVM_CMAKE_PATH=/usr/lib64/cmake/llvm -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_Fortran_COMPILER=flang -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} .. \
&& make -j ${MAKE_JOBS} \
&& make install \
&& rm -rf /opt/src/flang
# Add to linker path so that binaries can find the libraries
RUN echo -e "/usr/local/lib\n/usr/local/lib64" > /etc/ld.so.conf.d/flang.conf
RUN ldconfig
# Test if it works
WORKDIR /root/
RUN echo -e "program hello\n print *, 'hello world'\n end" > hello.f90
RUN flang -o hello hello.f90
RUN ./hello
CMD exec bash