Skip to content

Instantly share code, notes, and snippets.

@rrva
Created November 22, 2015 10:27
Show Gist options
  • Save rrva/201ff03512115e3d6768 to your computer and use it in GitHub Desktop.
Save rrva/201ff03512115e3d6768 to your computer and use it in GitHub Desktop.
FROM alpine
RUN apk update
RUN apk add alpine-sdk
RUN apk add python autoconf automake zlib-dev libtool zip xz sed cmake clang
RUN git clone git://github.com/ninja-build/ninja.git && cd ninja && ./configure.py --bootstrap && cp ninja /usr/bin && ninja -t clean && ninja && cp ninja /usr/bin
RUN mkdir /build && cd /build && curl -s -O http://llvm.org/releases/3.7.0/llvm-3.7.0.src.tar.xz && tar -xf llvm-3.7.0.src.tar.xz
WORKDIR /build
RUN cd llvm-3.7.0.src && curl -s https://gist.githubusercontent.com/cl91/bb927df2525738502131/raw/0305140e75046954a92002bd6b31e7c14a971f94/0001-Add-support-for-linux-musl-in-build-system.-Fix-glib.patch | patch -p1 || exit 0
RUN cd /usr && curl -s https://gist.githubusercontent.com/cl91/bb927df2525738502131/raw/0305140e75046954a92002bd6b31e7c14a971f94/0001-Fix-namespace-pollution-of-preprocessor-macros.patch | patch -p1
RUN mkdir llvm-3.7.0.build && cd llvm-3.7.0.build && CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /build/llvm-3.7.0.src && ln -s $(pwd)/compile_commands.json /build/llvm-3.7.0.src/ && ninja install
RUN cd /build && curl -s -O http://llvm.org/releases/3.7.0/cfe-3.7.0.src.tar.xz && tar -xf cfe-3.7.0.src.tar.xz
RUN mkdir cfe-3.7.0.static && cd cfe-3.7.0.static && CC=/usr/bin/clang CXX=/usr/bin/clang++ CXXFLAGS="-Oz -fmerge-all-constants -fsingle-precision-constant -fdata-sections -fno-exceptions -fno-rtti -fomit-frame-pointer -fno-stack-protector" LDFLAGS="-Wl,--gc-sections -Wl,-z,norelro" cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=NO -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /build/cfe-3.7.0.src && ln -fs $(pwd)/compile_commands.json /build/cfe-3.7.0.src && ninja clang-format
RUN strip -s /build/cfe-3.7.0.static/bin/clang-format
RUN ls -lh /build/cfe-3.7.0.static/bin/clang-format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment