Skip to content

Commit

Permalink
Fix compilation issues with cling
Browse files Browse the repository at this point in the history
  • Loading branch information
jeaye committed Jan 11, 2024
1 parent 2b38ff0 commit 384d3e7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,40 @@ There are pre-compiled binaries for Ubuntu 22.04, which are built to follow the
For Debian-based distros, this should be all you need:

```bash
$ sudo apt-get install -y curl git zip build-essential entr libssl-dev libdouble-conversion-dev pkg-config ninja-build python3-pip cmake debhelper devscripts gnupg zlib1g-dev
sudo apt-get install -y curl git zip build-essential entr libssl-dev libdouble-conversion-dev pkg-config ninja-build python3-pip cmake debhelper devscripts gnupg zlib1g-dev entr
```

For Arch:

```bash
sudo pacman -S clang pkg-config cmake ninja make python3 libffi jemalloc entr
```

For macOS, try this:

```bash
$ brew install curl git zip entr openssl double-conversion pkg-config ninja python cmake gnupg zlib
brew install curl git zip entr openssl double-conversion pkg-config ninja python cmake gnupg zlib
```

Clone the repo as follows:

```bash
$ git clone --recurse-submodules https://github.com/jank-lang/jank.git
git clone --recurse-submodules https://github.com/jank-lang/jank.git

# If you didn't recurse submodules when cloning, you'll need to run this.
$ git submodule update --recursive --init
git submodule update --recursive --init
```

### Compiling Cling
Note that you must compile Cling/Clang/LLVM. This can take an hour or two,
depending on your machine. Building jank itself should take less than a minute.

```
$ mkdir -p build
$ cd build
$ ../bin/build-cling
$ cd -
$ export CC=$PWD/build/cling-build/bin/clang; export CXX=$PWD/build/cling-build/bin/clang++;
mkdir -p build
cd build
../bin/build-cling
cd -
export CC=$PWD/build/cling-build/bin/clang; export CXX=$PWD/build/cling-build/bin/clang++;
```

At this point, you're ready to build jank.
Expand All @@ -62,19 +68,19 @@ At this point, you're ready to build jank.
A typical release build just needs the following:

```bash
$ ./bin/configure -GNinja -DCMAKE_BUILD_TYPE=Release -Djank_cling_build_dir=build/cling-build
$ ./bin/compile
./bin/configure -GNinja -DCMAKE_BUILD_TYPE=Release -Djank_cling_build_dir=build/cling-build
./bin/compile
```

#### Debug
To make a debug build, specify the build type when configuring.

```bash
$ ./bin/configure -GNinja -DCMAKE_BUILD_TYPE=Debug -Djank_cling_build_dir=build/cling-build -Djank_tests=on
$ ./bin/compile
./bin/configure -GNinja -DCMAKE_BUILD_TYPE=Debug -Djank_cling_build_dir=build/cling-build -Djank_tests=on
./bin/compile

# When developing, continuously run the tests locally.
$ ./bin/watch ./bin/test
./bin/watch ./bin/test
```

### Packaging
Expand All @@ -83,8 +89,8 @@ Note that this includes a lot of header files, which are necessary for jank's
JIT compilation.

```bash
$ ./bin/configure -GNinja -DCMAKE_BUILD_TYPE=Release -Djank_cling_build_dir=build/cling-build
$ ./bin/install
./bin/configure -GNinja -DCMAKE_BUILD_TYPE=Release -Djank_cling_build_dir=build/cling-build
./bin/install
```

## Sponsors
Expand Down
8 changes: 6 additions & 2 deletions bin/build-cling
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ srcdir="${PWD}"
cling_url="https://github.com/root-project/cling.git"
cling_branch="master"
llvm_url="https://github.com/root-project/llvm-project.git"
llvm_branch="cling-llvm13"
llvm_branch="cling-llvm13-20230802-01"

# $1 == Repo URL
# $2 == Repo branch
Expand All @@ -52,12 +52,16 @@ function prepare()
{
if [[ ! -d "${srcdir}/llvm" ]];
then
shallow_clone "${llvm_url}" "${llvm_branch}" "${srcdir}"/llvm
#shallow_clone "${llvm_url}" "${llvm_branch}" "${srcdir}"/llvm
git clone -b "${llvm_branch}" --shallow-submodules --single-branch "${llvm_url}" "${srcdir}"/llvm
fi

if [[ ! -d "${srcdir}/cling" ]];
then
git clone -b "${cling_branch}" --shallow-submodules --single-branch "${cling_url}" "${srcdir}"/cling
pushd "${srcdir}"/cling >/dev/null
git checkout 798c5659789923fe63b7a7edfa99b5af9300311f
popd >/dev/null
fi
}

Expand Down
4 changes: 2 additions & 2 deletions bin/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -euo pipefail

here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
build_dir="${here}/../build"
/bin/rm -rf "${build_dir}"/{CMakeCache.txt,CMakeFiles}
/bin/mkdir -p "${build_dir}"
rm -rf "${build_dir}"/{CMakeCache.txt,CMakeFiles}
mkdir -p "${build_dir}"

# Assume clang, but allow overriding.
export CC="${CC:-clang}"
Expand Down
1 change: 0 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"fmt",
"folly",
"immer",
"libguarded",
"libzippp",
"magic-enum",
"readline"
Expand Down

0 comments on commit 384d3e7

Please sign in to comment.