Skip to content

Commit 3f590b9

Browse files
authored
Remove LLVM submodule and patch instead (#110)
* gh: bump code version * llvm: remove submodule and just track our patch * fix typo * llvm: apply patch in the right directory * llvm: call clean-libc before very-clean * docker: get llvm sources from parent image * docker: cleanup * gha: use access token instead of password
1 parent 90cf7f6 commit 3f590b9

File tree

13 files changed

+84
-19
lines changed

13 files changed

+84
-19
lines changed

.env

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SYSROOT_VERSION=0.2.2
2-
SYSROOT_CLI_IMAGE=faasm/cpp-sysroot:0.2.2
1+
SYSROOT_VERSION=0.2.3
2+
SYSROOT_CLI_IMAGE=faasm/cpp-sysroot:0.2.3
33
COMPOSE_PROJECT_NAME=cpp-dev

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: docker/login-action@v2
2828
with:
2929
username: ${{ secrets.DOCKER_USERNAME }}
30-
password: ${{ secrets.DOCKER_PASSWORD }}
30+
password: ${{ secrets.DOCKER_TOKEN }}
3131
- name: "Build and push cpp-sysroot container"
3232
id: docker_build
3333
uses: docker/build-push-action@v3

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
if: github.event.pull_request.draft == false
2020
runs-on: ubuntu-latest
2121
container:
22-
image: faasm/cpp-sysroot:0.2.2
22+
image: faasm/cpp-sysroot:0.2.3
2323
steps:
2424
# --- Update code ---
2525
- name: "Checkout code"

.gitmodules

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
path = third-party/wasi-libc
33
url = https://github.com/faasm/wasi-libc
44
branch = faasm
5-
[submodule "third-party/llvm-project"]
6-
path = third-party/llvm-project
7-
url = https://github.com/faasm/llvm-project.git
8-
branch = faasm
95
[submodule "third-party/libffi"]
106
path = third-party/libffi
117
url = https://github.com/faasm/libffi.git

LLVM.makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ clean-libc:
3030
rm -rf $(BUILD_DIR)/libc.BUILT $(WASI_LIBC_DIR)/build
3131

3232
.PHONY: very-clean-libc
33-
very-clean-libc:
33+
very-clean-libc: clean-libc
3434
# WARNING: this is going to remove _everything_ in FAASM_SYSROOT
3535
cd $(WASI_LIBC_DIR) && SYSROOT=$(FAASM_SYSROOT) make clean
3636

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.2
1+
0.2.3

docker/cpp-sysroot.dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# llvm image is not re-built often, so the tag may be behind
2-
FROM faasm/llvm:0.2.2 as llvm
2+
FROM faasm/llvm:0.2.3 as llvm
33

44
# faabric-base image is not re-built often, so tag may be behind
55
FROM faasm/faabric-base:0.4.1
66
SHELL ["/bin/bash", "-c"]
77
ENV CPP_DOCKER="on"
88

9-
# Copy the toolchain in from the LLVM container
9+
# Copy the toolchain and LLVM sources from the LLVM container
1010
COPY --from=llvm /usr/local/faasm /usr/local/faasm
11+
COPY --from=llvm /opt/llvm-project /opt/llvm-project
1112

1213
# Update APT dependencies
1314
RUN apt update && apt install -y autotools-dev
@@ -18,7 +19,6 @@ RUN mkdir -p /code \
1819
https://github.com/faasm/cpp \
1920
/code/cpp \
2021
&& cd /code/cpp \
21-
&& git submodule update --init -f third-party/llvm-project \
2222
&& git submodule update --init -f third-party/faabric \
2323
&& git submodule update --init -f third-party/faasm-clapack \
2424
&& git submodule update --init -f third-party/libffi \

docker/llvm.dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ RUN mkdir -p /code \
3838
https://github.com/faasm/cpp \
3939
/code/cpp \
4040
&& cd /code/cpp \
41-
&& git submodule update --init -f third-party/llvm-project \
4241
&& git submodule update --init -f third-party/wasi-libc \
4342
&& ./bin/create_venv.sh \
4443
&& source venv/bin/activate \

faasmtools/env.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# LLVM variables
1616
LLVM_VERSION = "13.0.1"
17-
LLVM_DIR = join(THIRD_PARTY_DIR, "llvm-project")
17+
LLVM_DIR = join("/opt", "llvm-project")
1818
LLVM_MAKEFILE = join(PROJ_ROOT, "LLVM.makefile")
1919
WASI_LIBC_DIR = join(THIRD_PARTY_DIR, "wasi-libc")
2020

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From 4d755c1f417a09cbe5156af4c04782a10cb047aa Mon Sep 17 00:00:00 2001
2+
From: Simon Shillaker <[email protected]>
3+
Date: Wed, 27 Apr 2022 16:55:11 +0000
4+
Subject: [PATCH] Remove __EMSCRIPTEN__ definitions from emscripten target
5+
6+
---
7+
clang/lib/Basic/Targets/OSTargets.h | 14 ++++++++++----
8+
1 file changed, 10 insertions(+), 4 deletions(-)
9+
10+
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
11+
index 12df95c19f35..5aaf0e7fc84c 100644
12+
--- a/clang/lib/Basic/Targets/OSTargets.h
13+
+++ b/clang/lib/Basic/Targets/OSTargets.h
14+
@@ -291,7 +291,7 @@ protected:
15+
Builder.defineMacro("__HAIKU__");
16+
Builder.defineMacro("__ELF__");
17+
DefineStd(Builder, "unix", Opts);
18+
- if (this->HasFloat128)
19+
+ if (this->HasFloat128)
20+
Builder.defineMacro("__FLOAT128__");
21+
}
22+
23+
@@ -946,9 +946,15 @@ class LLVM_LIBRARY_VISIBILITY EmscriptenTargetInfo
24+
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
25+
MacroBuilder &Builder) const final {
26+
WebAssemblyOSTargetInfo<Target>::getOSDefines(Opts, Triple, Builder);
27+
- Builder.defineMacro("__EMSCRIPTEN__");
28+
- if (Opts.POSIXThreads)
29+
- Builder.defineMacro("__EMSCRIPTEN_PTHREADS__");
30+
+ // For Faasm, we need to use the Emscripten target to build shared
31+
+ // libraries, but we don't actually want any of the emscripten features.
32+
+ // See htps://bugs.llvm.org/show_bug.cgi?id=42714
33+
+ //
34+
+ Builder.defineMacro("__wasi__");
35+
+
36+
+ //Builder.defineMacro("__EMSCRIPTEN__");
37+
+ //if (Opts.POSIXThreads)
38+
+ // Builder.defineMacro("__EMSCRIPTEN_PTHREADS__");
39+
}
40+
41+
public:
42+
--
43+
2.34.1
44+

tasks/llvm.py

+27-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
WASI_LIBC_DIR,
1414
)
1515
from invoke import task
16-
from os import environ
17-
from os.path import join
16+
from os import environ, listdir
17+
from os.path import exists, join
1818
from subprocess import run
19+
from tasks.util.env import PATCHES_DIR
1920

2021
LLVM_BUILD_DIR = join(LLVM_DIR, "build")
2122
LLVM_BUILD_ENV_VARS = {
@@ -29,6 +30,27 @@
2930
}
3031

3132

33+
def do_llvm_clone():
34+
"""
35+
Clone the llvm-project repo and apply faasm-specific patches
36+
"""
37+
print("WARNING: Cloning llvm-project, this can take a while...")
38+
git_cmd = [
39+
"git clone",
40+
"-b llvmorg-{}".format(LLVM_VERSION),
41+
"--depth 1",
42+
"https://github.com/llvm/llvm-project",
43+
LLVM_DIR,
44+
]
45+
git_cmd = " ".join(git_cmd)
46+
run(git_cmd, shell=True, check=True)
47+
48+
llvm_patches_dir = join(PATCHES_DIR, "llvm-project")
49+
for patch in listdir(llvm_patches_dir):
50+
git_cmd = "git apply {}".format(join(llvm_patches_dir, patch))
51+
run(git_cmd, shell=True, check=True, cwd=LLVM_DIR)
52+
53+
3254
def do_llvm_build(target, clean_target=None):
3355
build_env = environ.copy()
3456
# These env. variables are required for LLVM's build configuration (and
@@ -61,6 +83,9 @@ def build(ctx, clean=False):
6183
"""
6284
Build LLVM and all targets (including libc)
6385
"""
86+
if not exists(LLVM_DIR):
87+
do_llvm_clone()
88+
6489
do_llvm_build("", "clean-all" if clean else None)
6590

6691

tasks/util/env.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
from os.path import dirname, realpath
1+
from os.path import dirname, join, realpath
22

33
PROJ_ROOT = dirname(dirname(dirname(realpath(__file__))))
4+
5+
PATCHES_DIR = join(PROJ_ROOT, "patches")

third-party/llvm-project

-1
This file was deleted.

0 commit comments

Comments
 (0)