Skip to content

Commit d86e338

Browse files
Dwight Guthrv-jenkins
andauthored
add libunwind as dependency (#1081)
This is one of a sequence of PRs designed to make progress towards generating stack maps so that we can trigger the GC during allocation rather than in between rewrite steps only. The first few PRs will be preliminaries that add small features that will be used by future PRs. This PR adds the libunwind library as a runtime dependency to the llvm backend. Libunwind is going to be used by the garbage collector to walk the stack and find the GC roots for each stack frame. The code to actually generate the stack maps and walk the stack will be added in a future PR. --------- Co-authored-by: rv-jenkins <[email protected]>
1 parent 30495f7 commit d86e338

File tree

8 files changed

+16
-12
lines changed

8 files changed

+16
-12
lines changed

.github/workflows/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ RUN apt-get update \
2727
libfmt-dev \
2828
libgmp-dev \
2929
libmpfr-dev \
30-
libyaml-dev \
3130
libjemalloc-dev \
31+
libunwind-dev \
32+
libyaml-dev \
3233
openjdk-${JDK_VERSION}-jdk \
3334
curl \
3435
maven \

Dockerfile.arch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM archlinux:base
22

33
RUN pacman -Syyu --noconfirm && \
4-
pacman -S --noconfirm base-devel git cmake clang llvm lld flex boost gmp mpfr libyaml jemalloc curl maven pkg-config python3
4+
pacman -S --noconfirm base-devel git cmake clang llvm lld flex boost gmp mpfr jemalloc libunwind libyaml curl maven pkg-config python3
55

66
ARG USER_ID=1000
77
ARG GROUP_ID=1000

INSTALL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ sudo apt install \
1616
libgmp-dev \
1717
libjemalloc-dev \
1818
libmpfr-dev \
19+
libunwind-dev \
1920
libyaml-dev \
2021
lld-15 \
2122
llvm-15-tools \
@@ -40,6 +41,7 @@ brew install \
4041
git \
4142
gmp \
4243
jemalloc \
44+
libunwind \
4345
libyaml \
4446
llvm@15 \
4547
maven \

bin/llvm-kompile-clang

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ if [ "$main" = "static" ]; then
217217
elif [[ "$main" =~ "python" ]]; then
218218
# Don't link jemalloc when building a python library; it clashes with the
219219
# pymalloc implementation that Python expects you to use.
220-
all_libraries=("${libraries[@]}" "-lgmp" "-lgmpxx" "-lmpfr" "-lpthread" "-ldl" "-lffi")
220+
all_libraries=("${libraries[@]}" "-lgmp" "-lgmpxx" "-lmpfr" "-lpthread" "-ldl" "-lffi" "-lunwind")
221221
flags+=("-fPIC" "-shared" "-I${INCDIR}" "-fvisibility=hidden")
222222

223223
read -r -a python_include_flags <<< "$("${python_cmd}" -m pybind11 --includes)"
@@ -239,11 +239,11 @@ elif [ "$main" = "c" ]; then
239239

240240
# Avoid jemalloc for similar reasons as Python; we don't know who is loading
241241
# this library so don't want to impose it.
242-
all_libraries=("${libraries[@]}" "-lgmp" "-lgmpxx" "-lmpfr" "-lpthread" "-ldl" "-lffi")
242+
all_libraries=("${libraries[@]}" "-lgmp" "-lgmpxx" "-lmpfr" "-lpthread" "-ldl" "-lffi" "-lunwind")
243243
flags+=("-fPIC" "-shared" "$start_whole_archive" "$LIBDIR/libkllvmcruntime.a" "$end_whole_archive")
244244
clangpp_args+=("-o" "${output_file}")
245245
else
246-
all_libraries=("${libraries[@]}" "-lgmp" "-lgmpxx" "-lmpfr" "-lpthread" "-ldl" "-lffi" "-ljemalloc")
246+
all_libraries=("${libraries[@]}" "-lgmp" "-lgmpxx" "-lmpfr" "-lpthread" "-ldl" "-lffi" "-ljemalloc" "-lunwind")
247247
fi
248248

249249
if $link; then

nix/llvm-backend.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{ lib, src, cmake, flex, fmt, pkg-config, llvm, libllvm, libcxx, stdenv, boost, gmp
2-
, jemalloc, libffi, libiconv, libyaml, mpfr, ncurses, python310, unixtools,
2+
, jemalloc, libffi, libiconv, libunwind, libyaml, mpfr, ncurses, python310, unixtools,
33
# Runtime dependencies:
44
host,
55
# Options:
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
1515
nativeBuildInputs = [ cmake flex llvm pkg-config ];
1616
buildInputs = [ libyaml ];
1717
propagatedBuildInputs = [
18-
boost fmt gmp jemalloc libffi mpfr ncurses python-env unixtools.xxd
18+
boost fmt gmp libunwind jemalloc libffi mpfr ncurses python-env unixtools.xxd
1919
] ++ lib.optional stdenv.isDarwin libiconv;
2020

2121
dontStrip = true;
@@ -40,6 +40,7 @@ stdenv.mkDerivation {
4040
--replace '"-liconv"' '"-L${libiconv}/lib" "-liconv"' \
4141
--replace '"-lncurses"' '"-L${ncurses}/lib" "-lncurses"' \
4242
--replace '"-ltinfo"' '"-L${ncurses}/lib" "-ltinfo"' \
43+
--replace '"-lunwind"' '"-L${libunwind}/lib" "-lunwind"' \
4344
--replace '"-L@BREW_PREFIX@/opt/libffi/lib"' ' ' \
4445
--replace '-L@BREW_PREFIX@/lib' '-L${libcxx}/lib' \
4546
--replace '-I "$(dirname "$0")"/../include/kllvm' \

nix/overlay.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let
1212
clang = llvmPackages.clangNoLibcxx;
1313

1414
llvm-backend = prev.callPackage ./llvm-backend.nix {
15-
inherit (llvmPackages) llvm libllvm libcxx;
15+
inherit (llvmPackages) llvm libllvm libcxx libunwind;
1616
stdenv = llvmPackages.stdenv;
1717
cmakeBuildType = prev.llvm-backend-build-type;
1818
src = prev.llvm-backend-src;

package/debian/control.jammy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ Source: k-llvm-backend
22
Section: devel
33
Priority: optional
44
Maintainer: Bruce Collie <[email protected]>
5-
Build-Depends: clang-15 , cmake , debhelper (>=10) , flex , libboost-dev , libboost-test-dev , libfmt-dev , libgmp-dev , libjemalloc-dev , libmpfr-dev , libyaml-dev , llvm-15-tools , pkg-config , python3 , python3-dev , xxd
5+
Build-Depends: clang-15 , cmake , debhelper (>=10) , flex , libboost-dev , libboost-test-dev , libfmt-dev , libgmp-dev , libjemalloc-dev , libmpfr-dev , libunwind-dev , libyaml-dev , llvm-15-tools , pkg-config , python3 , python3-dev , xxd
66
Standards-Version: 3.9.6
77
Homepage: https://github.com/runtimeverification/llvm-backend
88

99
Package: k-llvm-backend
1010
Architecture: any
1111
Section: devel
1212
Priority: optional
13-
Depends: clang-15 , flex , libboost-dev , libffi-dev , libfmt-dev , libgmp-dev , libjemalloc-dev , libmpfr-dev , libyaml-0-2 , lld-15 , llvm-15 , pkg-config
13+
Depends: clang-15 , flex , libboost-dev , libffi-dev , libfmt-dev , libgmp-dev , libjemalloc-dev , libmpfr-dev , libunwind-dev , libyaml-0-2 , lld-15 , llvm-15 , pkg-config
1414
Description: K Framework LLVM backend
1515
Fast concrete execution backend for programming language semantics implemented using the K Framework.
1616
Homepage: https://github.com/runtimeverification/llvm-backend

package/debian/control.noble

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ Source: k-llvm-backend
22
Section: devel
33
Priority: optional
44
Maintainer: Bruce Collie <[email protected]>
5-
Build-Depends: clang-17 , cmake , debhelper (>=10) , flex , libboost-dev , libboost-test-dev , libfmt-dev , libgmp-dev , libjemalloc-dev , libmpfr-dev , libyaml-dev , llvm-17-tools , pkg-config , python3 , python3-dev , xxd
5+
Build-Depends: clang-17 , cmake , debhelper (>=10) , flex , libboost-dev , libboost-test-dev , libfmt-dev , libgmp-dev , libjemalloc-dev , libmpfr-dev , libunwind-dev , libyaml-dev , llvm-17-tools , pkg-config , python3 , python3-dev , xxd
66
Standards-Version: 3.9.6
77
Homepage: https://github.com/runtimeverification/llvm-backend
88

99
Package: k-llvm-backend
1010
Architecture: any
1111
Section: devel
1212
Priority: optional
13-
Depends: clang-17 , flex , libboost-dev , libffi-dev , libfmt-dev , libgmp-dev , libjemalloc-dev , libmpfr-dev , libyaml-0-2 , lld-17 , llvm-17 , pkg-config
13+
Depends: clang-17 , flex , libboost-dev , libffi-dev , libfmt-dev , libgmp-dev , libjemalloc-dev , libmpfr-dev , libunwind-dev , libyaml-0-2 , lld-17 , llvm-17 , pkg-config
1414
Description: K Framework LLVM backend
1515
Fast concrete execution backend for programming language semantics implemented using the K Framework.
1616
Homepage: https://github.com/runtimeverification/llvm-backend

0 commit comments

Comments
 (0)