-
Notifications
You must be signed in to change notification settings - Fork 415
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
chore: CI: build 64-bit platforms consistently with GMP #5144
base: master
Are you sure you want to change the base?
Changes from all commits
094eb1f
50569ce
db86ed2
2788c53
81b0086
8521037
6fe6690
1caf8b6
9f4b852
523ce7e
ee2d033
06fe6e7
f58fd18
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 |
---|---|---|
|
@@ -49,17 +49,30 @@ namespace lean { | |
struct olean_header { | ||
// 5 bytes: magic number | ||
char marker[5] = {'o', 'l', 'e', 'a', 'n'}; | ||
// 1 byte: version, currently always `1` | ||
uint8_t version = 1; | ||
// 42 bytes: build githash, padded with `\0` to the right | ||
char githash[42]; | ||
// 1 byte: version, incremented on structural changes to header | ||
uint8_t version = 2; | ||
// 1 byte of flags: | ||
// * bit 0: whether persisted bignums use GMP or Lean-native encoding | ||
// * bit 1-7: reserved | ||
uint8_t flags = | ||
#ifdef LEAN_USE_GMP | ||
0b1; | ||
#else | ||
0b0; | ||
#endif | ||
// 33 bytes: Lean version string, padded with '\0' to the right | ||
// e.g. "4.12.0-nightly-2024-10-18". May not be null-terminated. | ||
char lean_version[33]; | ||
// 81b008650766442a0dfa9faa796e4588c9d7d3a1 | ||
// 40 bytes: build githash, padded with `\0` to the right | ||
char githash[40]; | ||
// address at which the beginning of the file (including header) is attempted to be mmapped | ||
size_t base_addr; | ||
// payload, a serialize Lean object graph; `size_t` has same alignment requirements as Lean objects | ||
size_t data[]; | ||
}; | ||
// make sure we don't have any padding bytes, which also ensures `data` is properly aligned | ||
static_assert(sizeof(olean_header) == 5 + 1 + 42 + sizeof(size_t), "olean_header must be packed"); | ||
static_assert(sizeof(olean_header) == 5 + 1 + 1 + 33 + 40 + sizeof(size_t), "olean_header must be packed"); | ||
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. Perhaps worth having an |
||
|
||
extern "C" LEAN_EXPORT object * lean_save_module_data(b_obj_arg fname, b_obj_arg mod, b_obj_arg mdata, object *) { | ||
std::string olean_fn(string_cstr(fname)); | ||
|
@@ -96,6 +109,7 @@ extern "C" LEAN_EXPORT object * lean_save_module_data(b_obj_arg fname, b_obj_arg | |
// see/sync with file format description above | ||
olean_header header = {}; | ||
header.base_addr = base_addr; | ||
strncpy(header.lean_version, get_short_version_string().c_str(), sizeof(header.lean_version)); | ||
strncpy(header.githash, LEAN_GITHASH, sizeof(header.githash)); | ||
out.write(reinterpret_cast<char *>(&header), sizeof(header)); | ||
out.write(static_cast<char const *>(compactor.data()), compactor.size()); | ||
|
@@ -140,16 +154,16 @@ extern "C" LEAN_EXPORT object * lean_read_module_data(object * fname, object *) | |
|
||
olean_header default_header = {}; | ||
olean_header header; | ||
if (!in.read(reinterpret_cast<char *>(&header), sizeof(header))) { | ||
if (!in.read(reinterpret_cast<char *>(&header), sizeof(header)) | ||
|| memcmp(header.marker, default_header.marker, sizeof(header.marker)) != 0) { | ||
return io_result_mk_error((sstream() << "failed to read file '" << olean_fn << "', invalid header").str()); | ||
} | ||
if (memcmp(header.marker, default_header.marker, sizeof(header.marker)) != 0 | ||
|| header.version != default_header.version | ||
if (header.version != default_header.version || header.flags != default_header.flags | ||
#ifdef LEAN_CHECK_OLEAN_VERSION | ||
|| strncmp(header.githash, LEAN_GITHASH, sizeof(header.githash)) != 0 | ||
#endif | ||
) { | ||
return io_result_mk_error((sstream() << "failed to read file '" << olean_fn << "', invalid header").str()); | ||
return io_result_mk_error((sstream() << "failed to read file '" << olean_fn << "', incompatible header").str()); | ||
} | ||
char * base_addr = reinterpret_cast<char *>(header.base_addr); | ||
char * buffer = nullptr; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
There is no padding here, right?
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.
There can be, if the githash is empty. I don't think there is anything syntactically restricting it to be exactly 40 bytes, although it will be for actual lean releases.