Skip to content

Commit b0e84ec

Browse files
authored
LLVM 18 (#33)
* gh: bump minor code version * third-party: remove unsupported submodules * tasks: bump to llvm 17 for clang formatting * remove unnecessary references to apps * cpython: use lllvm-17 for the native build * cpp: point to llvm-17 branch * cpython: fix func compilation * cpp: bump * cpython: set the target in the func compilation * cpp: bump dep * cpython: use llvm native version for native compilation * nits * nits: clang-format-17 checks passing * cpp: bump to latest version * cpp: bump after merge to main
1 parent ae6c8a1 commit b0e84ec

File tree

14 files changed

+61
-52
lines changed

14 files changed

+61
-52
lines changed

.clang-format

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,16 @@ AlwaysBreakAfterReturnType: None
1010

1111
IndentWidth: 4
1212
DerivePointerAlignment: false
13+
14+
# Precise control over braces alignment
15+
BreakBeforeBraces: Custom
16+
BraceWrapping:
17+
AfterClass: true
18+
AfterEnum: true
19+
AfterExternBlock: true
20+
AfterFunction: true
21+
AfterStruct: true
22+
AfterUnion: true
23+
SplitEmptyFunction: false
24+
SplitEmptyRecord: false
1325
---

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
if: github.event.pull_request.draft == false
2121
runs-on: ubuntu-latest
2222
container:
23-
image: faasm.azurecr.io/cpython:0.3.1
23+
image: faasm.azurecr.io/cpython:0.4.0
2424
credentials:
2525
username: ${{ secrets.ACR_SERVICE_PRINCIPAL_ID }}
2626
password: ${{ secrets.ACR_SERVICE_PRINCIPAL_PASSWORD }}
@@ -44,7 +44,7 @@ jobs:
4444
REDIS_QUEUE_HOST: redis
4545
REDIS_STATE_HOST: redis
4646
container:
47-
image: faasm.azurecr.io/cpython:0.3.1
47+
image: faasm.azurecr.io/cpython:0.4.0
4848
credentials:
4949
username: ${{ secrets.ACR_SERVICE_PRINCIPAL_ID }}
5050
password: ${{ secrets.ACR_SERVICE_PRINCIPAL_PASSWORD }}

.gitmodules

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,10 @@
22
path = third-party/cpython
33
url = https://github.com/faasm/cpython
44
branch = faasm
5-
[submodule "third-party/numpy"]
6-
path = third-party/numpy
7-
url = https://github.com/faasm/numpy
8-
branch = faasm
95
[submodule "third-party/crossenv"]
106
path = third-party/crossenv
117
url = https://github.com/faasm/crossenv
128
branch = faasm
13-
[submodule "third-party/horovod"]
14-
path = third-party/horovod
15-
url = https://github.com/faasm/horovod
16-
branch = faasm
17-
[submodule "third-party/mxnet"]
18-
path = third-party/mxnet
19-
url = https://github.com/faasm/incubator-mxnet
20-
branch = faasm
219
[submodule "third-party/cpp"]
2210
path = third-party/cpp
2311
url = https://github.com/faasm/cpp

Dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM faasm.azurecr.io/cpp-sysroot:0.2.4
1+
FROM faasm.azurecr.io/cpp-sysroot:0.4.0
22
ARG FAASM_PYTHON_VERSION
33

44
SHELL ["/bin/bash", "-c"]
@@ -41,11 +41,6 @@ RUN cd /code/python \
4141
&& source ./venv/bin/activate \
4242
&& inv modules.install
4343

44-
45-
# TODO: enable these once the MXNet/ Horovod work is completed
46-
# Build mxnet
47-
# RUN inv mxnet
48-
4944
# TODO: Install experimental pacakges
5045
# RUN . ./cross_venv/bin/activate && inv libs.install --experimental
5146

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.1
1+
0.4.0

crossenv/tasks/modules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
MODIFIED_LIBS_EXPERIMENTAL = {
2626
# 15/11/2022 - Move Numpy back to experimental as either the upgrades
2727
# to the CPP toolchain or LLVM 13 break the build
28+
# (experimental <=> not yet supported)
2829
"numpy": {
2930
"env": {"NPY_NUM_BUILD_JOBS": USABLE_CPUS},
3031
},

func/cpp/CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,32 @@ project(faasm-func)
33

44
set(CMAKE_CXX_STANDARD 17)
55

6-
if (CMAKE_SYSTEM_NAME STREQUAL "Wasm")
6+
if (CMAKE_SYSTEM_NAME STREQUAL "WASI")
7+
# Set the right target so that we look in the right sysroot
8+
set(CMAKE_C_FLAGS "--target=$ENV{FAASM_WASM_TRIPLE} ${CMAKE_C_FLAGS}")
9+
set(CMAKE_CXX_FLAGS "--target=$ENV{FAASM_WASM_TRIPLE} ${CMAKE_CXX_FLAGS}")
10+
711
# For Faasm functions, we add `_faasm_zygote` as an exported symbol
812
set(CMAKE_EXE_LINKER_FLAGS
913
"${CMAKE_EXE_LINKER_FLAGS} -Xlinker --export=_faasm_zygote"
1014
)
15+
1116
message(STATUS "Detected wasm build (sysroot=$ENV{FAASM_WASM_SYSROOT})")
1217
set(CMAKE_EXECUTABLE_SUFFIX ".wasm")
1318
endif ()
1419

15-
if (CMAKE_SYSTEM_NAME STREQUAL "Wasm")
20+
if (CMAKE_SYSTEM_NAME STREQUAL "WASI")
1621
set(FAASM_FUNC_LIBS faasm emscripten c-printscan-long-double)
1722

18-
set(PYTHON_LIBRARIES ${CMAKE_SYSROOT}/lib/wasm32-wasi/libpython3.8.a)
19-
set(PYTHON_INCLUDE_DIRS ${CMAKE_SYSROOT}/include/python3.8)
23+
set(PYTHON_LIBRARIES $ENV{FAASM_WASM_LIB_INSTALL_DIR}/libpython3.8.a)
24+
set(PYTHON_INCLUDE_DIRS $ENV{FAASM_WASM_HEADER_INSTALL_DIR}/python3.8)
2025
else ()
2126
find_package(PythonLibs)
2227
endif()
2328

2429
add_executable(py_func pyinit.c pyinit.h py_func.cpp)
2530

26-
if (CMAKE_SYSTEM_NAME STREQUAL "Wasm")
31+
if (CMAKE_SYSTEM_NAME STREQUAL "WASI")
2732
target_link_libraries(py_func ${FAASM_FUNC_LIBS} ${PYTHON_LIBRARIES} ffi)
2833
target_include_directories(py_func PUBLIC ${PYTHON_INCLUDE_DIRS})
2934

tasks/cpython.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
from copy import copy as deep_copy
22
from faasmctl.util.upload import upload_wasm
3-
from faasmtools.build import (
4-
FAASM_BUILD_ENV_DICT,
5-
WASM_HEADER_INSTALL,
6-
WASM_LIB_INSTALL,
7-
WASM_WASI_LIBC_LDFLAGS,
8-
build_config_cmd,
9-
)
3+
from faasmtools.build import build_config_cmd, get_faasm_build_env_dict
104
from faasmtools.compile_util import wasm_cmake, wasm_copy_upload
11-
from faasmtools.env import WASM_DIR
5+
from faasmtools.env import LLVM_NATIVE_VERSION, WASM_DIR
126
from invoke import task
137
from os import environ, makedirs
148
from os.path import join, exists
@@ -54,16 +48,18 @@
5448
"PATH": PATH_ENV_VAR,
5549
}
5650
)
57-
ENV_VARS.update(FAASM_BUILD_ENV_DICT)
51+
ENV_VARS.update(get_faasm_build_env_dict(is_threads=True))
5852

5953
LIB_SRC_DIR = join(CPYTHON_INSTALL_DIR, "lib")
6054
LIB_DEST_DIR = join(FAASM_RUNTIME_ROOT, "lib")
6155

6256
LIBPYTHON_SRC_PATH = join(LIB_SRC_DIR, "libpython3.8.a")
63-
LIBPYTHON_DEST_PATH = join(WASM_LIB_INSTALL, "libpython3.8.a")
57+
LIBPYTHON_DEST_PATH = join(
58+
ENV_VARS["FAASM_WASM_LIB_INSTALL_DIR"], "libpython3.8.a"
59+
)
6460

6561
INCLUDE_SRC_DIR = join(CPYTHON_INSTALL_DIR, "include", "python3.8")
66-
INCLUDE_DEST_DIR = join(WASM_HEADER_INSTALL, "python3.8")
62+
INCLUDE_DEST_DIR = join(ENV_VARS["FAASM_WASM_HEADER_INSTALL_DIR"], "python3.8")
6763

6864
# See the CPython docs for more info:
6965
# - General: https://devguide.python.org/setup/#compile-and-build
@@ -96,21 +92,26 @@ def wasm(ctx, clean=False, noconf=False, nobuild=False):
9692
# relevant in the module builds.
9793

9894
# Link in extra wasi-libc long double support (see wasi-libc docs)
99-
link_libs = ["-lfaasm"] + WASM_WASI_LIBC_LDFLAGS
100-
link_libs = " ".join(link_libs)
95+
link_libs = "-lfaasm " + ENV_VARS["FAASM_WASM_STATIC_LINKER_FLAGS"]
96+
# link_libs = " ".join(link_libs)
10197

10298
# Configure
10399
configure_cmd = build_config_cmd(
100+
ENV_VARS,
104101
[
105102
"CONFIG_SITE=./config.site",
106103
"READELF=true",
107104
"./configure",
108105
'LIBS="{}"'.format(link_libs),
106+
"--build=wasm32",
107+
"--host={}".format(ENV_VARS["FAASM_WASM_TRIPLE"]),
109108
"--disable-ipv6",
110109
"--disable-shared",
111110
"--prefix={}".format(CPYTHON_INSTALL_DIR),
112111
"--with-system-ffi",
113-
]
112+
],
113+
# Do not set the --host flag as we want to use the wasi-threads target
114+
conf_args=False,
114115
)
115116

116117
if not noconf:
@@ -133,8 +134,8 @@ def wasm(ctx, clean=False, noconf=False, nobuild=False):
133134
_run_cpython_cmd("bininstall", ["make", "bininstall"])
134135

135136
# Prepare destinations
136-
makedirs(WASM_HEADER_INSTALL, exist_ok=True)
137-
makedirs(WASM_LIB_INSTALL, exist_ok=True)
137+
makedirs(ENV_VARS["FAASM_WASM_HEADER_INSTALL_DIR"], exist_ok=True)
138+
makedirs(ENV_VARS["FAASM_WASM_LIB_INSTALL_DIR"], exist_ok=True)
138139

139140
rmtree(INCLUDE_DEST_DIR, ignore_errors=True)
140141

@@ -187,12 +188,13 @@ def native(ctx, clean=False):
187188
run("wget {}".format(tar_url), shell=True, check=True, cwd=workdir)
188189
run("tar -xf {}".format(tar_name), shell=True, check=True, cwd=workdir)
189190

191+
llvm_native_version_major = LLVM_NATIVE_VERSION.split(".")[0]
190192
workdir = join(workdir, PYTHON_VERSION)
191193
native_configure_cmd = [
192-
'CC="clang-13"',
193-
'CXX="clang++-13"',
194+
'CC="clang-{}"'.format(llvm_native_version_major),
195+
'CXX="clang++-{}"'.format(llvm_native_version_major),
194196
'CFLAGS="-O3 -DANSI"',
195-
'LD="clang-13"',
197+
'LD="clang-{}"'.format(llvm_native_version_major),
196198
"./configure",
197199
"--prefix={}".format(PYTHON_INSTALL_DIR),
198200
]
@@ -230,7 +232,14 @@ def func(ctx, clean=False, debug=False):
230232
wasm_file = join(func_build_dir, "{}.wasm".format(CPYTHON_FUNC_NAME))
231233

232234
# Build and install the wasm
233-
wasm_cmake(func_dir, func_build_dir, CPYTHON_FUNC_NAME, clean, debug)
235+
wasm_cmake(
236+
func_dir,
237+
func_build_dir,
238+
CPYTHON_FUNC_NAME,
239+
clean,
240+
debug,
241+
is_threads=True,
242+
)
234243
wasm_copy_upload(CPYTHON_FUNC_USER, CPYTHON_FUNC_NAME, wasm_file)
235244

236245

tasks/format_code.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from faasmtools.env import LLVM_NATIVE_VERSION
12
from invoke import task
23
from tasks.env import PROJ_ROOT
34
from subprocess import run
@@ -51,8 +52,9 @@ def format(ctx, check=False):
5152
)
5253

5354
clang_cmd = [
54-
"clang-format-13",
55+
"clang-format-{}".format(LLVM_NATIVE_VERSION.split(".")[0]),
5556
"--dry-run --Werror" if check else "-i",
57+
"-style=file",
5658
" ".join(files_to_check),
5759
]
5860
clang_cmd = " ".join(clang_cmd)

third-party/cpp

Submodule cpp updated 63 files

third-party/horovod

Lines changed: 0 additions & 1 deletion
This file was deleted.

third-party/mxnet

Lines changed: 0 additions & 1 deletion
This file was deleted.

third-party/numpy

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)