Skip to content

Conversation

@Samy-33
Copy link
Contributor

@Samy-33 Samy-33 commented Jul 12, 2025

  • Also allows user to choose type of runtime while ahead of compiling their projects

- Also allows user to choose type of runtime while ahead of compiling
  their projects
@Samy-33 Samy-33 requested a review from jeaye July 12, 2025 16:03
Copy link
Member

@jeaye jeaye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This came together well. I have some cleanup requests, since there are a few different forms of duplication throughout, but I think the overall approach will work well.

Assuming you've tried this with your AOT compilation, will you please provide the ldd (linux) or otool -L (mac) output for the resulting static runtime AOT binary in the PR description?


add_library(
jank_lib STATIC
set(JANK_LIBRARY_COMMON_SOURCES
Copy link
Member

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.

# Native module sources.
src/cpp/clojure/core_native.cpp
src/cpp/clojure/string_native.cpp
src/cpp/jank/compiler_native.cpp
Copy link
Member

Choose a reason for hiding this comment

The 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.

Comment on lines +396 to +406
"$<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>"
Copy link
Member

Choose a reason for hiding this comment

The 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.

* of previous code. This is essential for REPL use. */
/* TODO: This needs to be synchronized. */
analyze::processor an_prc{ *this };
#ifndef JANK_STATIC_RUNTIME
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's def JANK_DYNAMIC_RUNTIME for dynamic builds and JANK_STATIC_RUNTIME for static builds. Checking for "not static" is both indirect and potentially too broad. For example, if we add a third runtime, this check would also match that.

native_vector<jtl::immutable_string> define_macros;
native_vector<jtl::immutable_string> libs;

jtl::immutable_string runtime;
Copy link
Member

Choose a reason for hiding this comment

The 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.

native_vector<runtime::obj::symbol_ref>
params) // NOLINT(performance-unnecessary-value-param): This is a dummy implementation for static runtime
{
throw std::runtime_error{ "Eval disabled in static runtime." };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's define a constexpr C string at the top of the file with this message, instead of duplicating it 24 times.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the comment before the arg, use NOLINTNEXTLINE, use /* */ style comments, and end the comment in a . since comments are documentation.

Comment on lines +5 to +6
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed if you just remove the param names.

}
return ok();
#else
return err("Load or eval not allowed in static runtime");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every error must be a complete sentence or paragraph, so please end this with a ..


return ok();
#else
return err("Can't load file in static runtime");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use correct grammar and punctuation for error messages.

Dynamic file loading is disable in jank's static runtime.

Let's use this for load_o, load_jank, and load_cpp. Put it into a constexpr global so we're not repeating it. Making sure we write helpful error messages is important in every part of the system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants