Skip to content

Commit

Permalink
Merge main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
haruki7049 committed Nov 2, 2024
1 parent 3f60ab5 commit c221ce9
Show file tree
Hide file tree
Showing 26 changed files with 333 additions and 223 deletions.
18 changes: 18 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,21 @@
[submodule "compiler+runtime/third-party/bpptree"]
path = compiler+runtime/third-party/bpptree
url = https://github.com/jank-lang/BppTree.git
[submodule "compiler+runtime/third-party/bdwgc"]
path = compiler+runtime/third-party/bdwgc
url = https://github.com/jank-lang/bdwgc.git
[submodule "compiler+runtime/third-party/fmt"]
path = compiler+runtime/third-party/fmt
url = https://github.com/jank-lang/fmt.git
[submodule "compiler+runtime/third-party/immer"]
path = compiler+runtime/third-party/immer
url = https://github.com/jank-lang/immer.git
[submodule "compiler+runtime/third-party/magic_enum"]
path = compiler+runtime/third-party/magic_enum
url = https://github.com/jank-lang/magic_enum.git
[submodule "compiler+runtime/third-party/cli11"]
path = compiler+runtime/third-party/cli11
url = https://github.com/jank-lang/CLI11.git
[submodule "compiler+runtime/third-party/libzippp"]
path = compiler+runtime/third-party/libzippp
url = https://github.com/jank-lang/libzippp.git
69 changes: 30 additions & 39 deletions compiler+runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
)
)

# LTO is explicitly not used, since it leads to runtime symbol lookup issues with the JIT.
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)

set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_SOURCE_DIR}/vcpkg-triplet")
set(VCPKG_TARGET_TRIPLET "x64-clang-static")

project(
jank
VERSION 0.1
DESCRIPTION "A native Clojure dialect built on LLVM."
DESCRIPTION "The native Clojure dialect on LLVM."
HOMEPAGE_URL "https://jank-lang.org/"
# C is needed here, due to a clang issue:
# https://stackoverflow.com/questions/71740678/cmake-error-in-findterminfo-with-clang-15-on-macos
Expand Down Expand Up @@ -203,17 +200,22 @@ add_library(
)

target_include_directories(
jank_lib
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/cpp>"
jank_lib
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/cpp>"
)
target_include_directories(
jank_lib
SYSTEM
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/nanobench/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/folly>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/bpptree/include>"
jank_lib
SYSTEM
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/nanobench/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/folly>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/bpptree/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/bdwgc/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/immer>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/magic_enum/include/magic_enum>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/cli11/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/libzippp/src>"
)
target_precompile_headers(
jank_lib
Expand All @@ -225,29 +227,23 @@ set_property(TARGET jank_lib PROPERTY OUTPUT_NAME jank)
target_compile_features(jank_lib PUBLIC ${jank_cxx_standard})
target_compile_options(jank_lib PUBLIC ${jank_common_compiler_flags} ${jank_aot_compiler_flags})

find_package(Immer CONFIG REQUIRED)
find_package(magic_enum CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem preprocessor)
find_package(BDWgc CONFIG REQUIRED)
find_package(libzippp CONFIG REQUIRED)
find_package(CLI11 CONFIG REQUIRED)
find_package(OpenSSL CONFIG REQUIRED)
#find_package(libassert CONFIG REQUIRED)
include(FetchContent)
include(cmake/dependency/bdwgc.cmake)
include(cmake/dependency/fmt.cmake)
include(cmake/dependency/libzippp.cmake)

target_include_directories(jank_lib SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
find_package(OpenSSL REQUIRED COMPONENTS Crypto)
find_package(Boost REQUIRED COMPONENTS filesystem)

target_link_libraries(
jank_lib PRIVATE
immer fmt::fmt
BDWgc::gc BDWgc::cord BDWgc::gccpp BDWgc::gctba
fmt::fmt
bdwgc::gc bdwgc::gccpp
libzippp::libzippp
CLI11::CLI11
#libassert::assert
readline
clangInterpreter
Boost::boost
$<$<PLATFORM_ID:Darwin>:crypto>
Boost::filesystem
OpenSSL::Crypto
)

jank_hook_llvm(jank_lib)
Expand Down Expand Up @@ -330,7 +326,7 @@ set_target_properties(nanobench_lib PROPERTIES ENABLE_EXPORTS 1)

# ---- libfolly.a ----
# Folly is well and truly a pain in the ass to build through its
# own build system (via vcpkg). It regularly fails to build for me
# own build system. It regularly fails to build for me
# on all sorts of standard systems (both Linux and macOS) and jank
# has been running with custom patches for several months now. After
# running into compilation issues with it yet again, I've decided to
Expand Down Expand Up @@ -366,7 +362,6 @@ target_include_directories(
SYSTEM
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/folly>"
${BOOST_INCLUDE_DIRS}
)

set_property(TARGET folly_lib PROPERTY OUTPUT_NAME folly)
Expand All @@ -382,7 +377,7 @@ set_target_properties(folly_lib PROPERTIES ENABLE_EXPORTS 1)

target_link_libraries(
folly_lib PUBLIC
Boost::preprocessor
fmt::fmt
)
# ---- libfolly.a ----

Expand All @@ -402,15 +397,13 @@ target_compile_features(jank_exe PRIVATE ${jank_cxx_standard})
target_compile_options(jank_exe PUBLIC ${jank_common_compiler_flags} ${jank_aot_compiler_flags})
target_link_options(jank_exe PRIVATE ${jank_linker_flags})

target_include_directories(jank_exe SYSTEM PRIVATE ${BOOST_INCLUDE_DIRS})

target_link_libraries(
jank_exe PUBLIC
${jank_link_whole_start} jank_lib ${jank_link_whole_end}
${jank_link_whole_start} nanobench_lib ${jank_link_whole_end}
folly_lib
fmt::fmt
Boost::boost Boost::filesystem Boost::system
Boost::filesystem
)

jank_hook_llvm(jank_exe)
Expand Down Expand Up @@ -440,16 +433,14 @@ if(jank_tests)
target_compile_options(jank_test_exe PRIVATE -DDOCTEST_CONFIG_SUPER_FAST_ASSERTS)
target_link_options(jank_test_exe PRIVATE ${jank_linker_flags})

target_include_directories(jank_test_exe SYSTEM PRIVATE ${BOOST_INCLUDE_DIRS})

find_package(doctest REQUIRED)
target_link_libraries(
jank_test_exe PUBLIC
${jank_link_whole_start} jank_lib ${jank_link_whole_end}
${jank_link_whole_start} nanobench_lib ${jank_link_whole_end}
folly_lib
doctest::doctest
Boost::boost Boost::filesystem
Boost::filesystem
)

jank_hook_llvm(jank_test_exe)
Expand Down
19 changes: 19 additions & 0 deletions compiler+runtime/cmake/dependency/bdwgc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(CMAKE_C_FLAGS_OLD "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS_OLD "${CMAKE_CXX_FLAGS}")
set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
set(BUILD_SHARED_LIBS OFF)
set(enable_cplusplus ON CACHE BOOL "Enable C++")
set(build_cord OFF CACHE BOOL "Build cord")
set(enable_docs OFF CACHE BOOL "Enable docs")
set(enable_throw_bad_alloc_library OFF CACHE BOOL "Enable C++ gctba library build")

add_subdirectory(third-party/bdwgc)

unset(enable_cplusplus)
unset(build_cord)
unset(enable_docs)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_OLD}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_OLD}")
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD})
7 changes: 7 additions & 0 deletions compiler+runtime/cmake/dependency/fmt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(FMT_DOC OFF CACHE BOOL "Generate docs")
set(FMT_INSTALL OFF CACHE BOOL "Generate the install target.")

add_subdirectory(third-party/fmt)

unset(FMT_DOC)
unset(FMT_INSTALL)
8 changes: 8 additions & 0 deletions compiler+runtime/cmake/dependency/libzippp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(CMAKE_C_FLAGS_OLD "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS_OLD "${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")

add_subdirectory(third-party/libzippp)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_OLD}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_OLD}")
8 changes: 0 additions & 8 deletions compiler+runtime/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ let

# Deps
boost = pkgs.callPackage ./nix/boost.nix { };
boehmgc = pkgs.callPackage ./nix/boehmgc.nix { };
libzippp = pkgs.callPackage ./nix/libzippp.nix { };
openssl = pkgs.callPackage ./nix/openssl.nix { };
in

Expand All @@ -28,17 +26,11 @@ pkgs.llvmPackages_19.stdenv.mkDerivation {

buildInputs = [
boost
boehmgc
libzippp
openssl
pkgs.doctest
pkgs.double-conversion
pkgs.readline
pkgs.libzip
pkgs.immer
pkgs.cli11
pkgs.magic-enum
pkgs.fmt
pkgs.llvmPackages_19.clang-unwrapped
pkgs.llvmPackages_19.llvm
];
Expand Down
10 changes: 5 additions & 5 deletions compiler+runtime/doc/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
For Debian-based distros, this should be all you need:

```bash
sudo apt-get install -y curl git git-lfs zip build-essential entr libssl-dev libdouble-conversion-dev pkg-config ninja-build python3-pip cmake debhelper devscripts gnupg zlib1g-dev entr libffi-dev clang libjemalloc-dev libreadline-dev
sudo apt-get install -y curl git git-lfs zip build-essential entr libssl-dev libdouble-conversion-dev pkg-config ninja-build python3-pip cmake debhelper devscripts gnupg zlib1g-dev entr libffi-dev clang libreadline-dev libzip-dev libbz2-dev doctest-dev libboost-all-dev
```

For Arch:

```bash
sudo pacman -S git git-lfs clang pkg-config cmake ninja make python3 libffi jemalloc entr
sudo pacman -S git git-lfs clang pkg-config cmake ninja make python3 libffi entr doctest boost libzip lbzip2
```

For macOS, try this:

```bash
brew install curl git git-lfs zip entr openssl double-conversion pkg-config ninja python cmake gnupg zlib jemalloc
brew install curl git git-lfs zip entr openssl double-conversion pkg-config ninja python cmake gnupg zlib doctest boost libzip lbzip2
```

Clone the repo as follows:
Expand All @@ -27,8 +27,8 @@ git clone --recurse-submodules https://github.com/jank-lang/jank.git
git submodule update --recursive --init
```

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

```
Expand Down
2 changes: 0 additions & 2 deletions compiler+runtime/include/cpp/jank/prelude.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include <boost/unordered_map.hpp>

//#include <libassert/assert.hpp>

#include <nanobench.h>

#include <jank/type.hpp>
Expand Down
41 changes: 10 additions & 31 deletions compiler+runtime/include/cpp/jank/read/parse.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <codecvt>

#include <jank/result.hpp>
#include <jank/option.hpp>
#include <jank/read/lex.hpp>
Expand All @@ -12,39 +14,16 @@ namespace jank::runtime
/* TODO: Rename file to processor. */
namespace jank::read::parse
{
static option<char> get_char_from_literal(native_persistent_string const &sv)

struct char_parse_error
{
if(sv.size() == 2)
{
return sv[1];
}
else if(sv == R"(\newline)")
{
return '\n';
}
else if(sv == R"(\space)")
{
return ' ';
}
else if(sv == R"(\tab)")
{
return '\t';
}
else if(sv == R"(\backspace)")
{
return '\b';
}
else if(sv == R"(\formfeed)")
{
return '\f';
}
else if(sv == R"(\return)")
{
return '\r';
}
native_persistent_string error;
};

result<native_persistent_string, char_parse_error>
parse_character_in_base(native_persistent_string const &char_literal, int const base);

return none;
}
option<char> get_char_from_literal(native_persistent_string const &s);

struct processor
{
Expand Down
2 changes: 1 addition & 1 deletion compiler+runtime/include/cpp/jank/util/escape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct fmt::formatter<jank::util::escape_view<S>>
}

template <typename C>
auto format(jank::util::escape_view<S> const &s, C &ctx)
auto format(jank::util::escape_view<S> const &s, C &ctx) const
{
return s.copy(ctx.out());
}
Expand Down
31 changes: 0 additions & 31 deletions compiler+runtime/nix/boehmgc.nix

This file was deleted.

12 changes: 2 additions & 10 deletions compiler+runtime/nix/boost.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
{
pkgs ? import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/75b209227dff3cbfac19f510a62f9446c92beac4.tar.gz";
sha256 = "166varzdamn2kkw5zslarzl6026q87wjnss1hlhdsq89hwvfgd2d";
}) { },
pkgs,
}:

let
stdenv = pkgs.llvmPackages_19.stdenv;
cc = stdenv.cc.cc;
in

stdenv.mkDerivation rec {
pkgs.stdenv.mkDerivation rec {
pname = "boost";
version = "1.86.0";

Expand Down
Loading

0 comments on commit c221ce9

Please sign in to comment.