Last active
December 4, 2018 03:17
-
-
Save hxy9243/0c9ca5d8205907d6c7d2c2dc8b0f57e2 to your computer and use it in GitHub Desktop.
Dockerfile and scripts to make an LLVM docker image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if test $# -lt 3; then | |
echo "Usage: $0 srcdir builddir" | |
fi | |
SRC_DIR=$1 | |
BUILD_DIR=$2 | |
# Optional flags setup | |
# Check the source code layout fit the llvm-project(-submodule) layout | |
# TODO | |
cp cmake.sh $BUILD_DIR | |
sudo docker run --privileged=true -i --rm=true \ | |
-v $SRC_DIR:/tmp/src -v $BUILD_DIR:/tmp/build \ | |
-w /tmp/build buildenv /tmp/build/cmake.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SRC_DIR=/src | |
BUILD_DIR=/build | |
BUILD_TYPE=${BUILD_TYPE:-Release} | |
CFLAGS=${CFLAGS:-"-O3"} | |
CXXFLAGS=${CXXFLAGS:-"-O3"} | |
BUILD_TARGETS=${BUILD_TARGETS:-"X86;AArch64"} | |
NUM_CORES=${NUM_CORES:-4} | |
# Run the actual build command | |
set -e | |
mkdir -p /build && cd /build | |
cmake ${SRC_DIR}/llvm -G Ninja \ | |
-DCMAKE_C_COMPILER:STRING=gcc \ | |
-DCMAKE_CXX_COMPILER:STRING=g++ \ | |
-DCMAKE_BUILD_TYPE:STRING=${BUILD_TYPE} \ | |
-DCMAKE_C_FLAGS:STRING=${CFLAGS} \ | |
-DCMAKE_CXX_FLAGS:STRING=${CXXFLAGS} \ | |
-DLLVM_TARGETS_TO_BUID:STRING=\"${BUILD_TARGETS}\" \ | |
-DLLVM_EXTERNAL_CLANG_SOURCE_DIR:PATH=${SRC_DIR}/clang \ | |
-DLLVM_EXTERNAL_LLD_SOURCE_DIR:PATH=${SRC_DIR}/lld \ | |
-DLLVM_EXTERNAL_POLLY_SOURCE_DIR:PATH=${SRC_DIR}/polly \ | |
-DLLVM_INSTALL_UTILS:BOOL=ON 2>&1 | tee cmake.log | |
ninja -j${NUM_CORES} 2>&1 | tee ninja.log | |
ninja install | |
ninja clean | |
exec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu | |
MAINTAINER Kevin Hu <[email protected]> | |
ARG LLVM_SRC=llvm-project | |
RUN apt-get update | |
RUN apt-get install -y cmake ninja-build $COMPILER | |
RUN apt-get build-dep -y llvm clang | |
RUN apt-get clean | |
WORKDIR /build | |
COPY cmake.sh . | |
ADD llvm-project /src | |
RUN ./cmake.sh | |
RUN rm -rf /src | |
USER cc | |
CMD clang --version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi met an error:
Step 6/14 : RUN apt-get build-dep -y llvm clang
---> Running in 7bd4084a86f3
Reading package lists...
E: You must put some 'source' URIs in your sources.list
The command '/bin/sh -c apt-get build-dep -y llvm clang' returned a non-zero code: 100
env: centos 7