-
-
Notifications
You must be signed in to change notification settings - Fork 114
feat: introduce jank lib with static runtime #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,8 +153,7 @@ endfunction() | |
| # remains a static lib, since these symbols need to be accessible in the | ||
| # compiler's runtime by the JIT compiler. | ||
|
|
||
| add_library( | ||
| jank_lib STATIC | ||
| set(JANK_LIBRARY_COMMON_SOURCES | ||
| src/cpp/jtl/panic.cpp | ||
| src/cpp/jtl/assert.cpp | ||
| src/cpp/jank/c_api.cpp | ||
|
|
@@ -273,16 +272,24 @@ add_library( | |
| src/cpp/jank/analyze/expr/case.cpp | ||
| src/cpp/jank/analyze/local_frame.cpp | ||
| src/cpp/jank/analyze/step/force_boxed.cpp | ||
|
|
||
| # Native module sources. | ||
| src/cpp/clojure/core_native.cpp | ||
| src/cpp/clojure/string_native.cpp | ||
| src/cpp/jank/perf_native.cpp | ||
| ) | ||
|
|
||
| add_library( | ||
| jank_lib STATIC | ||
| ${JANK_LIBRARY_COMMON_SOURCES} | ||
|
|
||
| src/cpp/jank/evaluate.cpp | ||
| src/cpp/jank/codegen/llvm_processor.cpp | ||
| src/cpp/jank/jit/processor.cpp | ||
| src/cpp/jank/aot/processor.cpp | ||
|
|
||
| # Native module sources. | ||
| src/cpp/clojure/core_native.cpp | ||
| src/cpp/clojure/string_native.cpp | ||
| src/cpp/jank/compiler_native.cpp | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why keep this one in the static sources? It requires codegen for the only function in there. |
||
| src/cpp/jank/perf_native.cpp | ||
| ) | ||
|
|
||
| set_property(TARGET jank_lib PROPERTY OUTPUT_NAME jank) | ||
|
|
@@ -363,6 +370,75 @@ target_link_options(jank_lib PRIVATE ${jank_linker_flags}) | |
| set_target_properties(jank_lib PROPERTIES ENABLE_EXPORTS 1) | ||
| # ---- libjank.a ---- | ||
|
|
||
| # ---- libjank_static_rt.a ---- | ||
| add_library( | ||
| jank_lib_static_rt STATIC | ||
| ${JANK_LIBRARY_COMMON_SOURCES} | ||
|
|
||
| src/cpp/jank/evaluate_static_rt.cpp | ||
| ) | ||
|
|
||
| set_property(TARGET jank_lib_static_rt PROPERTY OUTPUT_NAME jank_static_rt) | ||
|
|
||
| target_compile_features(jank_lib_static_rt PUBLIC ${jank_cxx_standard}) | ||
| target_compile_options(jank_lib_static_rt PUBLIC ${jank_common_compiler_flags} ${jank_aot_compiler_flags}) | ||
|
|
||
| target_include_directories( | ||
| jank_lib_static_rt | ||
| PUBLIC | ||
| "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/cpp>" | ||
| ) | ||
| target_include_directories( | ||
| jank_lib_static_rt | ||
| SYSTEM | ||
| PUBLIC | ||
| ${BDWGC_INCLUDE_DIR} | ||
| "$<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/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/ftxui/include>" | ||
| "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/libzippp/src>" | ||
| "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/cpptrace/include>" | ||
| "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/boost-preprocessor/include>" | ||
| "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third-party/boost-multiprecision/include>" | ||
|
Comment on lines
+396
to
+406
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to not duplicate all of this between the two libs. Same goes for the linked libs and the common compile options. |
||
| ) | ||
|
|
||
| target_link_libraries( | ||
| jank_lib_static_rt PRIVATE | ||
| ${BDWGC_LIBRARIES} | ||
| libzippp::libzippp | ||
| cpptrace::cpptrace | ||
| # clang | ||
| # clang-cpp | ||
| # LLVM | ||
| ftxui::screen ftxui::dom | ||
| OpenSSL::Crypto | ||
| Boost::multiprecision | ||
| ) | ||
|
|
||
| # Build a string of all of our JIT compilation flags so we can load them up in the runtime. | ||
| set(jank_jit_compile_flags_list ${jank_common_compiler_flags} ${jank_jit_compiler_flags}) | ||
| list(JOIN jank_jit_compile_flags_list " " jank_jit_compile_flags_str) | ||
|
|
||
| set(jank_deps_library_dirs ${LLVM_LIBRARY_DIRS}) | ||
|
|
||
| target_compile_options( | ||
| jank_lib_static_rt | ||
| PUBLIC | ||
| -DJANK_VERSION="${jank_version}" | ||
| -DJANK_JIT_FLAGS="${jank_jit_compile_flags_str}" | ||
| -DJANK_CLANG_PREFIX="${CLANG_INSTALL_PREFIX}" | ||
| -DJANK_STATIC_RUNTIME | ||
| ) | ||
| target_link_options(jank_lib_static_rt PRIVATE ${jank_linker_flags}) | ||
|
|
||
| # Symbol exporting for JIT. | ||
| set_target_properties(jank_lib_static_rt PROPERTIES ENABLE_EXPORTS 1) | ||
| # ---- libjank_static_rt.a ---- | ||
|
|
||
| # ---- libnanobench.a ---- | ||
| # nanobench uses a single header for both .hpp and .cpp inclusion, based on | ||
| # whether a define has been set. This doesn't work with jank's pre-compiled | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ namespace jank::aot | |
| native_vector<jtl::immutable_string> define_macros; | ||
| native_vector<jtl::immutable_string> libs; | ||
|
|
||
| jtl::immutable_string runtime; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want an enum for this, not a string. It only has two possible values, whereas the domain of a string is infinite. |
||
| jtl::immutable_string output_filename; | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,7 +136,9 @@ namespace jank::runtime | |
| * of previous code. This is essential for REPL use. */ | ||
| /* TODO: This needs to be synchronized. */ | ||
| analyze::processor an_prc{ *this }; | ||
| #ifndef JANK_STATIC_RUNTIME | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's def |
||
| jit::processor jit_prc; | ||
| #endif | ||
| /* TODO: This needs to be a dynamic var. */ | ||
| native_unordered_map<jtl::immutable_string, native_vector<jtl::immutable_string>> | ||
| module_dependencies; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| #include <jank/evaluate.hpp> | ||
|
|
||
| namespace jank::evaluate | ||
| { | ||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wunused-parameter" | ||
|
Comment on lines
+5
to
+6
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed if you just remove the param names. |
||
|
|
||
| analyze::expr::function_ref wrap_expression( | ||
| analyze::expression_ref const expr, | ||
| jtl::immutable_string const &name, | ||
| native_vector<runtime::obj::symbol_ref> | ||
| params) // NOLINT(performance-unnecessary-value-param): This is a dummy implementation for static runtime | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put the comment before the arg, use |
||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's define a |
||
| } | ||
|
|
||
| analyze::expr::function_ref wrap_expressions(native_vector<analyze::expression_ref> const &exprs, | ||
| analyze::processor const &an_prc, | ||
| jtl::immutable_string const &name) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expression_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::def_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::var_deref_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::var_ref_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::call_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::primitive_literal_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::list_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::vector_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::map_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::set_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::local_reference_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::function_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::recur_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::recursion_reference_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::named_recursion_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::let_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::letfn_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::do_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::if_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::throw_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::try_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| runtime::object_ref eval(analyze::expr::case_ref) | ||
| { | ||
| throw std::runtime_error{ "Eval disabled in static runtime." }; | ||
| } | ||
|
|
||
| #pragma clang diagnostic pop | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to uppercase all of this. All of our CMake variables are lowercase.