From 629138f205855e61af415799bc2df9ba648374ad Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 18 Oct 2020 23:50:26 -0400 Subject: [PATCH] Build LLVM gold in Mac toolchain. Clean up Makefile and Dockerfile. --- .gitignore | 4 +++- docker/Dockerfile => Dockerfile | 6 +++++- Makefile | 33 ++++++++++++++++++++++----------- 3 files changed, 30 insertions(+), 13 deletions(-) rename docker/Dockerfile => Dockerfile (80%) diff --git a/.gitignore b/.gitignore index 4e93949..05ed2a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -MacOSX10.13.sdk.tar.xz +MacOSX10.13.sdk.tar.* +local/ plugin-build/ +osxcross/ diff --git a/docker/Dockerfile b/Dockerfile similarity index 80% rename from docker/Dockerfile rename to Dockerfile index edcbade..ce4fa65 100644 --- a/docker/Dockerfile +++ b/Dockerfile @@ -1,13 +1,15 @@ FROM ubuntu:20.04 ENV LANG C.UTF-8 -# User to build toolchains and plugins +# Create unprivileged user to build toolchains and plugins RUN groupadd -g 1000 build RUN useradd --create-home --uid 1000 --gid 1000 --shell /bin/bash build +# Install make to run make ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends make +# Create toolchain directory USER build RUN mkdir -p /home/build/rack-plugin-toolchain WORKDIR /home/build/rack-plugin-toolchain @@ -17,11 +19,13 @@ COPY Makefile /home/build/rack-plugin-toolchain/ # Install dependencies for building toolchains and plugins USER root RUN make dep-ubuntu +# Clean up files to free up space RUN rm -rf /var/lib/apt/lists/* USER build COPY MacOSX10.13.sdk.tar.* /home/build/rack-plugin-toolchain/ +# Build toolchains RUN make toolchain-mac RUN make toolchain-win RUN make toolchain-lin diff --git a/Makefile b/Makefile index 664d624..79b9f10 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,3 @@ -.NOTPARALLEL: -.PHONY: all plugin-build - - # Installation path for executables LOCAL_DIR := $(PWD)/local # Local programs should have higher path priority than system-installed programs @@ -48,17 +44,27 @@ $(toolchain-win): $(crosstool-ng) toolchain-mac := $(LOCAL_DIR)/osxcross toolchain-mac: $(toolchain-mac) +MAC_CLANG_VERSION := 10.0.1 +MAC_BINUTILS_VERSION := 2.35 +# Binaries from ./build.sh must be available in order to run ./build_binutils.sh +$(toolchain-mac): export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH) $(toolchain-mac): - git clone "https://github.com/tpoechtrager/osxcross.git" $@ - cd $@ && git checkout a791ad4fca685ea9fceb520b77db586881cd3f3d + # Download osxcross + git clone "https://github.com/tpoechtrager/osxcross.git" osxcross + cd osxcross && git checkout a791ad4fca685ea9fceb520b77db586881cd3f3d # Build clang - #cd $@ && UNATTENDED=1 DISABLE_BOOTSTRAP=1 INSTALLPREFIX="$(LOCAL_DIR)" OCDEBUG=1 ./build_clang.sh - #cd $@/build/llvm-10.0.1.src/build && make install + cd osxcross && UNATTENDED=1 DISABLE_BOOTSTRAP=1 INSTALLPREFIX="$(LOCAL_DIR)" CLANG_VERSION=$(MAC_CLANG_VERSION) OCDEBUG=1 ./build_clang.sh + cd osxcross/build/llvm-$(MAC_CLANG_VERSION).src/build && make install # Build osxcross - cp MacOSX10.13.sdk.tar.* $@/tarballs/ - cd $@ && UNATTENDED=1 TARGET_DIR="$(LOCAL_DIR)/osxcross" ./build.sh + cp MacOSX10.13.sdk.tar.* osxcross/tarballs/ + cd osxcross && UNATTENDED=1 TARGET_DIR="$(LOCAL_DIR)/osxcross" ./build.sh + + # Build Mac version of binutils and build LLVM gold + cd osxcross && BINUTILS_VERSION=$(MAC_BINUTILS_VERSION) TARGET_DIR="$(LOCAL_DIR)/osxcross" ./build_binutils.sh + cd osxcross/build/llvm-$(MAC_CLANG_VERSION).src/build && cmake .. -DLLVM_BINUTILS_INCDIR=$(PWD)/osxcross/build/binutils-$(MAC_BINUTILS_VERSION)/include && make install + rm -rf osxcross @@ -82,6 +88,7 @@ toolchain-clean: PLUGIN_BUILD_DIR := plugin-build +PLUGIN_DIR ?= plugin-build-mac: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH) @@ -174,7 +181,7 @@ dep-arch-linux: docker-build: - docker build --tag rack-plugin-toolchain:1 docker + docker build --tag rack-plugin-toolchain:1 . DOCKER_RUN := docker run --rm --interactive --tty \ @@ -202,3 +209,7 @@ docker-plugin-build-lin: docker-plugin-build: mkdir -p $(PLUGIN_BUILD_DIR) $(DOCKER_RUN) -c "$(MAKE) plugin-build" + + +.NOTPARALLEL: +.PHONY: all plugin-build