Skip to content

Commit beafe61

Browse files
authored
Enable ccache in CI (#290)
* Remove variant from analysis expressions * Enable CI on PR creation * Revert "Enable CI on PR creation" This reverts commit 335d72f. * Add more const-correctness * Use explicit type for conj in to_runtime_data * Add ccache to CI * Add clang-tidy-cache * Enable apt caching in CI again * Trigger CI * Put CI packages on one line * Only install ctcache when analyzing * Bump CI package version * Switch to ctcache * Trigger CI * Show clang-tidy-cache stats * Try not recursing submodules BppTree has a ton of them and I think they're just for testing and benchmarking. * Enable ctcache debug * Use stable version during analysis * Trigger CI * Trigger CI * Trigger CI * Verbose compile * Show shell env in job summary * Disable explicit boost install again * Show include dir * Try executing install scripts again * Trigger CI * Patch boost files * Disable boost user config * Remove boost filesystem dep * Drop boost filesystem CI dep * Remove boost filesystem from build docs * Remove some debug code * Remove remaining boost usages * Remove remaining boost references * Address some analysis issues
1 parent 5b42717 commit beafe61

File tree

33 files changed

+278
-194
lines changed

33 files changed

+278
-194
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,19 @@ jobs:
5858
steps:
5959
- uses: actions/checkout@v4
6060
with:
61-
submodules: recursive
61+
submodules: true
62+
- uses: awalsh128/[email protected]
63+
with:
64+
packages: default-jdk software-properties-common lsb-release npm lcov leiningen ccache curl git git-lfs zip build-essential entr libssl-dev libdouble-conversion-dev pkg-config ninja-build cmake zlib1g-dev libffi-dev libzip-dev libbz2-dev doctest-dev gcc g++ libgc-dev
65+
# Increment this when the package list changes.
66+
version: 4
67+
- name: Cache object files
68+
uses: actions/cache@v4
69+
with:
70+
path: |
71+
${{ github.workspace }}/compiler+runtime/.ccache
72+
${{ github.workspace }}/compiler+runtime/.ctcache
73+
key: ${{ env.JANK_MATRIX_ID }}
6274
- name: Build and test
6375
run: |
6476
curl -sL -o install-bb https://raw.githubusercontent.com/babashka/babashka/master/install

bin/jank/check_everything.clj

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env bb
22

33
(ns jank.check-everything
4-
(:require [jank.compiler+runtime.core]
4+
(:require [babashka.fs :as b.f]
5+
[jank.compiler+runtime.core]
56
[jank.clojure-cli.core]
67
[jank.lein-jank.core]
78
[jank.summary :as summary]
@@ -16,53 +17,52 @@
1617
(util/log-info "JANK_ANALYZE: " (System/getenv "JANK_ANALYZE"))
1718
(util/log-info "JANK_SANITIZE: " (System/getenv "JANK_SANITIZE")))
1819

19-
(def os->deps-cmd {"Linux" "sudo apt-get install -y curl git git-lfs zip build-essential entr libssl-dev libdouble-conversion-dev pkg-config ninja-build cmake zlib1g-dev libffi-dev libzip-dev libbz2-dev doctest-dev libboost-all-dev gcc g++ libgc-dev"
20+
; Most Linux deps are installed by a Github action. We need to manually install
21+
; boost for some reason. Otherwise, its headers aren't found by clang.
22+
(def os->deps-cmd {"Mac OS X" "brew install curl git git-lfs zip entr openssl double-conversion pkg-config ninja python cmake gnupg zlib doctest boost libzip lbzip2 llvm@19"})
2023

21-
"Mac OS X" "brew install curl git git-lfs zip entr openssl double-conversion pkg-config ninja python cmake gnupg zlib doctest boost libzip lbzip2 llvm@19"})
22-
23-
; TODO: Cache these deps using https://github.com/actions/cache/
24-
; Maybe follow this sort of thing: https://github.com/gerlero/apt-install/blob/main/action.yml
2524
(defmulti install-deps
26-
(fn []
25+
(fn [_props]
2726
(System/getProperty "os.name")))
2827

29-
(defmethod install-deps "Linux" []
30-
(let [apt? (try
31-
(util/quiet-shell {} "which apt-get")
32-
true
33-
(catch Exception _e
34-
false))]
35-
(if-not apt?
36-
(util/log-warning "Skipping dependency install, since we don't have apt-get")
37-
(do
38-
; Install deps required for running our tests.
39-
(util/quiet-shell {} "sudo apt-get update -y")
40-
(util/quiet-shell {} "sudo apt-get install -y default-jdk software-properties-common lsb-release npm lcov leiningen")
41-
; TODO: Enable once we're linting Clojure/jank again.
42-
;(util/quiet-shell {} "sudo npm install --global @chrisoakman/standard-clojure-style")
43-
44-
; Install jank's build deps.
45-
(util/quiet-shell {} (os->deps-cmd "Linux"))
46-
47-
; Install Clang/LLVM.
48-
(util/quiet-shell {} "curl -L -O https://apt.llvm.org/llvm.sh")
49-
(util/quiet-shell {} "chmod +x llvm.sh")
50-
(util/quiet-shell {} (str "sudo ./llvm.sh " util/llvm-version " all"))
51-
; The libc++abi headers conflict with the system headers:
52-
; https://github.com/llvm/llvm-project/issues/121300
53-
(util/quiet-shell {} (str "sudo apt-get remove -y libc++abi-" util/llvm-version "-dev"))
54-
55-
; Install the new Clojure CLI.
56-
(util/quiet-shell {} "curl -L -O https://github.com/clojure/brew-install/releases/latest/download/linux-install.sh")
57-
(util/quiet-shell {} "chmod +x linux-install.sh")
58-
(util/quiet-shell {} "sudo ./linux-install.sh")))))
59-
60-
(defmethod install-deps "Mac OS X" []
28+
(defmethod install-deps "Linux" [{:keys [validate-formatting?]}]
29+
; TODO: Cache this shit.
30+
(when (= "on" (util/get-env "JANK_ANALYZE"))
31+
(util/quiet-shell {} "curl -Lo clang-tidy-cache https://raw.githubusercontent.com/matus-chochlik/ctcache/refs/heads/main/src/ctcache/clang_tidy_cache.py")
32+
(util/quiet-shell {} "chmod +x clang-tidy-cache")
33+
(util/quiet-shell {} "sudo mv clang-tidy-cache /usr/local/bin")
34+
(spit "clang-tidy-cache-wrapper"
35+
"#!/bin/bash
36+
clang-tidy-cache clang-tidy \"${@}\"")
37+
(util/quiet-shell {} "chmod +x clang-tidy-cache-wrapper")
38+
(util/quiet-shell {} "sudo mv clang-tidy-cache-wrapper /usr/local/bin"))
39+
40+
; TODO: Enable once we're linting Clojure/jank again.
41+
;(util/quiet-shell {} "sudo npm install --global @chrisoakman/standard-clojure-style")
42+
43+
; Install Clang/LLVM.
44+
(util/quiet-shell {} "curl -L -O https://apt.llvm.org/llvm.sh")
45+
(util/quiet-shell {} "chmod +x llvm.sh")
46+
(util/quiet-shell {} (str "sudo ./llvm.sh " util/llvm-version " all"))
47+
; The libc++abi headers conflict with the system headers:
48+
; https://github.com/llvm/llvm-project/issues/121300
49+
(util/quiet-shell {} (str "sudo apt-get remove -y libc++abi-" util/llvm-version "-dev"))
50+
51+
; Install the new Clojure CLI.
52+
(util/quiet-shell {} "curl -L -O https://github.com/clojure/brew-install/releases/latest/download/linux-install.sh")
53+
(util/quiet-shell {} "chmod +x linux-install.sh")
54+
(util/quiet-shell {} "sudo ./linux-install.sh"))
55+
56+
(defmethod install-deps "Mac OS X" [_props]
6157
(util/quiet-shell {:extra-env {"HOMEBREW_NO_AUTO_UPDATE" "1"}}
62-
(os->deps-cmd "Mac OS X")))
58+
(os->deps-cmd "Mac OS X"))
59+
60+
; TODO: This is missing some of the other things above.
61+
)
6362

6463
(defn -main [{:keys [install-deps? validate-formatting? compiler+runtime
65-
clojure-cli lein-jank]}]
64+
clojure-cli lein-jank]
65+
:as props}]
6666
(summary/initialize)
6767

6868
(util/log-boundary "Show environment")
@@ -72,7 +72,7 @@
7272
(if-not install-deps?
7373
(util/log-info "Not enabled")
7474
(util/with-elapsed-time duration
75-
(install-deps)
75+
(install-deps props)
7676
(util/log-info-with-time duration "Dependencies installed")))
7777

7878
(jank.compiler+runtime.core/-main {:validate-formatting? validate-formatting?

bin/jank/summary.clj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@
3131
[s]
3232
(clojure.string/replace s #"\x1B\[[0-9;]*[mK]" ""))
3333

34-
(defn shell [success? cmd out]
34+
(defn shell [success? props cmd out]
3535
(append-line "\n<details>")
3636
(append-line (str "<summary>" (if success? "" "") " " cmd "</summary>\n"))
37+
(when-some [extra-env (:extra-env props)]
38+
(append-line "| Environment variable | Value |")
39+
(append-line "| --- | --- |")
40+
(doseq [[k v] extra-env]
41+
(append-line (str "| " k " | " v " |")))
42+
(append-line ""))
3743
(append-line "```text")
3844
(append-line (strip-ansi-codes out))
3945
(append-line "```")

bin/jank/util.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@
6969
(do
7070
(log-error "Failed to run command " cmd)
7171
(println (:out proc))
72-
(summary/shell false cmd (:out proc))
72+
(summary/shell false props cmd (:out proc))
7373
(System/exit 1))
7474
(do
75-
(summary/shell true cmd (:out proc))
75+
(summary/shell true props cmd (:out proc))
7676
proc))))
7777

7878
(defmacro with-elapsed-time

compiler+runtime/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ add_library(
163163
src/cpp/jank/util/escape.cpp
164164
src/cpp/jank/util/clang_format.cpp
165165
src/cpp/jank/util/string_builder.cpp
166+
src/cpp/jank/util/string.cpp
166167
src/cpp/jank/profile/time.cpp
167168
src/cpp/jank/ui/highlight.cpp
168169
src/cpp/jank/error.cpp
@@ -286,6 +287,7 @@ target_include_directories(
286287
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/fmt/include>"
287288
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/ftxui/include>"
288289
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/libzippp/src>"
290+
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/boost-preprocessor/include>"
289291
)
290292

291293
set_property(TARGET jank_lib PROPERTY OUTPUT_NAME jank)
@@ -302,7 +304,6 @@ include(cmake/dependency/ftxui.cmake)
302304
include(cmake/dependency/libzippp.cmake)
303305

304306
find_package(OpenSSL REQUIRED COMPONENTS Crypto)
305-
find_package(Boost CONFIG REQUIRED COMPONENTS filesystem)
306307
find_package(BDWgc REQUIRED)
307308

308309
target_link_libraries(
@@ -314,7 +315,6 @@ target_link_libraries(
314315
clang
315316
clang-cpp
316317
LLVM
317-
Boost::filesystem
318318
ftxui::screen ftxui::dom
319319
OpenSSL::Crypto
320320
)
@@ -453,7 +453,6 @@ target_link_libraries(
453453
${jank_link_whole_start} nanobench_lib ${jank_link_whole_end}
454454
folly_lib
455455
fmt::fmt
456-
Boost::filesystem
457456
)
458457

459458
jank_hook_llvm(jank_exe)
@@ -503,7 +502,6 @@ if(jank_tests)
503502
${jank_link_whole_start} nanobench_lib ${jank_link_whole_end}
504503
folly_lib
505504
doctest::doctest
506-
Boost::filesystem
507505
)
508506

509507
jank_hook_llvm(jank_test_exe)

compiler+runtime/bin/jank/compiler+runtime/build+test.clj

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,33 @@
1717
(util/log-info "Not enabled")
1818
(let [clang (util/find-llvm-tool "clang")
1919
clang++ (util/find-llvm-tool "clang++")
20-
exports {"CC" clang
21-
"CXX" clang++}
20+
exports (merge {"CC" clang
21+
"CXX" clang++
22+
"CCACHE_BASEDIR" compiler+runtime-dir
23+
"CCACHE_DIR" (str compiler+runtime-dir "/.ccache")
24+
"CCACHE_COMPRESS" "true"
25+
"CCACHE_MAXSIZE" "1G"
26+
"CTCACHE_DIR" (str compiler+runtime-dir "/.ctcache")})
2227
configure-flags ["-GNinja"
2328
"-Djank_tests=on"
2429
(str "-DCMAKE_BUILD_TYPE=" build-type)
2530
(str "-Djank_analyze=" analyze)
2631
(str "-Djank_sanitize=" sanitize)
2732
(str "-Djank_coverage=" coverage)]
28-
configure-cmd (str "./bin/configure " (clojure.string/join " " configure-flags))]
33+
configure-flags (cond-> configure-flags
34+
(not= "on" analyze)
35+
(conj "-DCMAKE_C_COMPILER_LAUNCHER=ccache"
36+
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache")
37+
(= "on" analyze)
38+
(conj "-DCMAKE_CXX_CLANG_TIDY=clang-tidy-cache-wrapper"))
39+
configure-cmd (str "./bin/configure " (clojure.string/join " " configure-flags))
40+
stats-cmd (if (= "on" analyze)
41+
"clang-tidy-cache"
42+
"ccache")]
43+
(util/quiet-shell {:dir compiler+runtime-dir
44+
:extra-env exports}
45+
(str stats-cmd " --zero-stats"))
46+
2947
(util/quiet-shell {:dir compiler+runtime-dir
3048
:extra-env exports}
3149
configure-cmd)
@@ -34,9 +52,13 @@
3452
(util/with-elapsed-time duration
3553
(util/quiet-shell {:dir compiler+runtime-dir
3654
:extra-env exports}
37-
"./bin/compile")
55+
"./bin/compile -v")
3856
(util/log-info-with-time duration "Compiled"))
3957

58+
(util/quiet-shell {:dir compiler+runtime-dir
59+
:extra-env exports}
60+
(str stats-cmd " --show-stats"))
61+
4062
(util/with-elapsed-time duration
4163
(util/quiet-shell {:dir compiler+runtime-dir
4264
:extra-env (merge exports

compiler+runtime/cmake/analyze.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ if(jank_analyze)
88
set(CMAKE_CXX_CLANG_TIDY clang-tidy --use-color)
99
endif()
1010
endif()
11+
12+
# Use a stable version name for analysis builds, to enable caching.
13+
set(jank_version "jank-${CMAKE_PROJECT_VERSION}-analyze")
1114
endif()

compiler+runtime/doc/build.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ scripts to compile your own. See the section on compiling Clang/LLVM below.
66
For Debian-based distros, this should be all you need:
77

88
```bash
9-
sudo apt-get install -y curl git git-lfs zip build-essential entr libssl-dev libdouble-conversion-dev pkg-config ninja-build cmake zlib1g-dev libffi-dev clang libclang-dev llvm llvm-dev libzip-dev libbz2-dev doctest-dev libboost-all-dev gcc g++ libgc-dev
9+
sudo apt-get install -y curl git git-lfs zip build-essential entr libssl-dev libdouble-conversion-dev pkg-config ninja-build cmake zlib1g-dev libffi-dev clang libclang-dev llvm llvm-dev libzip-dev libbz2-dev doctest-dev gcc g++ libgc-dev
1010
```
1111

1212
For Arch:
1313

1414
```bash
15-
sudo pacman -S git git-lfs clang llvm llvm-libs pkg-config cmake ninja make python3 libffi entr doctest boost libzip lbzip2 gc
15+
sudo pacman -S git git-lfs clang llvm llvm-libs pkg-config cmake ninja make python3 libffi entr doctest libzip lbzip2 gc
1616
```
1717

1818
For Nix:
@@ -27,7 +27,7 @@ nix develop ".#"
2727
For macOS:
2828

2929
```bash
30-
brew install curl git git-lfs zip entr openssl double-conversion pkg-config ninja python cmake gnupg zlib doctest boost libzip lbzip2 llvm@19 bdw-gc
30+
brew install curl git git-lfs zip entr openssl double-conversion pkg-config ninja python cmake gnupg zlib doctest libzip lbzip2 llvm@19 bdw-gc
3131

3232
# Ensure you have this set up in your shell.
3333
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)

compiler+runtime/include/cpp/jank/detail/to_runtime_data.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <boost/filesystem/path.hpp>
3+
#include <filesystem>
44

55
#include <jank/runtime/obj/symbol.hpp>
66
#include <jank/runtime/obj/persistent_array_map.hpp>
@@ -45,7 +45,7 @@ namespace jank::detail
4545
return make_box<obj::symbol>(d);
4646
}
4747

48-
inline object_ptr to_runtime_data(boost::filesystem::path const &p)
48+
inline object_ptr to_runtime_data(std::filesystem::path const &p)
4949
{
5050
return make_box(p.string());
5151
}

compiler+runtime/include/cpp/jank/jit/processor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <boost/filesystem/path.hpp>
3+
#include <filesystem>
44
#include <memory>
55

66
#include <clang/Interpreter/Interpreter.h>
@@ -57,6 +57,6 @@ namespace jank::jit
5757

5858
std::unique_ptr<clang::Interpreter> interpreter;
5959
native_integer optimization_level{};
60-
native_vector<boost::filesystem::path> library_dirs;
60+
native_vector<std::filesystem::path> library_dirs;
6161
};
6262
}

compiler+runtime/include/cpp/jank/option.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <cassert>
44
#include <utility> // move, forward
5-
#include <type_traits>
65

76
#include <jank/type.hpp>
87

@@ -52,17 +51,16 @@ namespace jank
5251
}
5352

5453
template <typename D = T>
55-
constexpr option(D &&d,
56-
std::enable_if_t<std::is_constructible_v<T, D>
57-
&& !std::is_same_v<std::decay_t<D>, option<T>>> * = nullptr)
54+
requires(std::is_constructible_v<T, D> && !std::is_same_v<std::decay_t<D>, option<T>>)
55+
constexpr option(D &&d)
5856
: set{ true }
5957
{
6058
new(reinterpret_cast<T *>(data)) T{ std::forward<D>(d) };
6159
}
6260

6361
template <typename D>
64-
constexpr option(option<D> const &o,
65-
std::enable_if_t<std::is_constructible_v<T, D>> * = nullptr)
62+
requires(std::is_constructible_v<T, D>)
63+
constexpr option(option<D> const &o)
6664
: set{ o.set }
6765
{
6866
if(set)

compiler+runtime/include/cpp/jank/prelude.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <random>
44
#include <chrono>
5-
//#include <cassert>
5+
#include <unordered_map>
66

77
#include <gc/gc.h>
88
#include <gc/gc_cpp.h>
@@ -12,8 +12,6 @@
1212
#include <immer/heap/heap_policy.hpp>
1313
#include <immer/memory_policy.hpp>
1414

15-
#include <boost/unordered_map.hpp>
16-
1715
#include <nanobench.h>
1816

1917
#include <jank/type.hpp>

0 commit comments

Comments
 (0)