Skip to content

Commit

Permalink
Bring folly in as a submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
jeaye committed Jun 1, 2024
1 parent 6aba6b6 commit 2229ae0
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "third-party/vcpkg"]
path = compiler+runtime/third-party/vcpkg
url = https://github.com/jank-lang/vcpkg.git
[submodule "compiler+runtime/third-party/folly"]
path = compiler+runtime/third-party/folly
url = git@github.com:jank-lang/folly.git
61 changes: 56 additions & 5 deletions compiler+runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ target_include_directories(
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/cpp>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/nanobench/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/folly>"
)
target_precompile_headers(
jank_lib
Expand All @@ -222,8 +223,7 @@ target_link_options(jank_lib PRIVATE ${jank_linker_flags})
find_package(Immer CONFIG REQUIRED)
find_package(magic_enum CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(folly CONFIG REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem)
find_package(Boost REQUIRED COMPONENTS filesystem preprocessor)
find_package(BDWgc CONFIG REQUIRED)
find_package(libzippp CONFIG REQUIRED)
find_package(CLI11 CONFIG REQUIRED)
Expand All @@ -237,11 +237,11 @@ target_link_directories(jank_lib PRIVATE ${jank_cling_build_dir}/build-compiler-
target_link_libraries(
jank_lib PRIVATE
jank_cling_lib immer fmt::fmt
Folly::folly Folly::folly_deps
BDWgc::gc BDWgc::cord BDWgc::gccpp BDWgc::gctba
libzippp::libzippp
CLI11::CLI11
readline
Boost::filesystem
)

set_target_properties(jank_lib PROPERTIES LINK_FLAGS_RELEASE "-s")
Expand Down Expand Up @@ -278,6 +278,57 @@ set_target_properties(nanobench_lib PROPERTIES LINK_FLAGS_RELEASE "-s")
set_target_properties(nanobench_lib PROPERTIES ENABLE_EXPORTS 1)
# ---- libnanobench.a ----

# ---- 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
# 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
# just rip the good bits out and only compile what we need.
#
# The Folly fork we have makes things even easier to build by commenting
# out some bits related to jemalloc and tcmalloc. Folly has a whole
# complex preprocessor system for this stuff, but it still ends up
# linking to them even when you say you don't want them.

add_library(
folly_lib STATIC
third-party/folly/folly/ScopeGuard.cpp
third-party/folly/folly/SharedMutex.cpp
third-party/folly/folly/concurrency/CacheLocality.cpp
third-party/folly/folly/synchronization/ParkingLot.cpp
third-party/folly/folly/synchronization/SanitizeThread.cpp
third-party/folly/folly/lang/SafeAssert.cpp
third-party/folly/folly/lang/ToAscii.cpp
third-party/folly/folly/system/ThreadId.cpp
third-party/folly/folly/system/AtFork.cpp
third-party/folly/folly/detail/Futex.cpp
)

target_include_directories(
folly_lib ${warning_guard}
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/folly>"
${BOOST_INCLUDE_DIRS}
)

set_property(TARGET folly_lib PROPERTY OUTPUT_NAME folly)

target_compile_features(folly_lib PUBLIC ${jank_cxx_standard})
target_compile_options(folly_lib PUBLIC ${jank_compiler_flags} -w)
target_link_options(folly_lib PRIVATE ${jank_linker_flags})

set_target_properties(folly_lib PROPERTIES LINK_FLAGS_RELEASE "-s")

# Symbol exporting for JIT.
set_target_properties(folly_lib PROPERTIES ENABLE_EXPORTS 1)

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

# ---- jank executable ----
add_executable(
jank_exe
Expand All @@ -303,7 +354,7 @@ 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}
Boost::boost
folly_lib
)
set_target_properties(jank_exe PROPERTIES LINK_FLAGS_RELEASE -s)
# ---- jank executable ----
Expand Down Expand Up @@ -340,7 +391,7 @@ if(jank_tests)
jank_test_exe PUBLIC
${jank_link_whole_start} jank_lib ${jank_link_whole_end}
${jank_link_whole_start} nanobench_lib ${jank_link_whole_end}
Boost::boost
folly_lib
doctest::doctest
)

Expand Down
19 changes: 8 additions & 11 deletions compiler+runtime/src/cpp/jank/jit/processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,14 @@ namespace jank::jit
optimization_level) };
}

auto const args(jank::util::make_array(
/* TODO: Path to clang++ from Cling build? Is this using the system clang++? */
"clang++",
"-std=c++17",
"-DHAVE_CXX14=1",
"-DIMMER_HAS_LIBGC=1",
"-include-pch",
pch_path_str.c_str(),
"-isystem",
include_path.c_str(),
O.data()));
auto const args(jank::util::make_array("-std=c++17",
"-DHAVE_CXX14=1",
"-DIMMER_HAS_LIBGC=1",
"-include-pch",
pch_path_str.c_str(),
"-isystem",
include_path.c_str(),
O.data()));
interpreter = std::make_unique<cling::Interpreter>(args.size(),
args.data(),
llvm_resource_path_str.c_str());
Expand Down
4 changes: 2 additions & 2 deletions compiler+runtime/test/cpp/jank/jit/processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ namespace jank::jit
continue;
}

auto const &filename(dir_entry.path().filename().string());
auto const filename(dir_entry.path().filename().string());
auto const expect_success(boost::algorithm::starts_with(filename, "pass-"));
auto const expect_failure(boost::algorithm::starts_with(filename, "fail-"));
auto const expect_throw(boost::algorithm::starts_with(filename, "throw-"));
auto const allow_failure(boost::algorithm::starts_with(filename, "warn-"));
CHECK_MESSAGE((expect_success || expect_failure || allow_failure || expect_throw),
"Test file needs to begin with pass- or fail- or throw- or warn-: ",
dir_entry);
filename);
++test_count;

/* TODO: Clear our rt_ctx for each run. Using the copy ctor leads to odd failures with
Expand Down
1 change: 1 addition & 0 deletions compiler+runtime/third-party/folly
Submodule folly added at dd0bd2
2 changes: 1 addition & 1 deletion compiler+runtime/third-party/vcpkg
Submodule vcpkg updated 6394 files
2 changes: 1 addition & 1 deletion compiler+runtime/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"boost-filesystem",
"boost-smart-ptr",
"boost-variant",
"boost-preprocessor",
"cli11",
"fmt",
"folly",
"immer",
"libzippp",
"magic-enum",
Expand Down

0 comments on commit 2229ae0

Please sign in to comment.