zeek / spicy

C++ parser generator for dissecting protocols & files.
https://docs.zeek.org/projects/spicy
Other
243 stars 37 forks source link

Importing a module causes emitting all the type infos for the module #1785

Closed bbannier closed 1 month ago

bbannier commented 1 month ago

Since about #1462 we seem to emit the full type infos for all types in the imported module in each file which imports it where previously we would only forward declare them. This causes us to emit much more code which can reduce compilation speed for code making (very) heavy use of modules and imports.

module f1;

public type NOPE1 = unit {};
module f2;

import f1;

public type NOPE2 = unit {};
$ spicyc -c f?.spicy | rg TypeInfo | rg NOPE | rg '\{'
    const ::hilti::rt::TypeInfo __ti_f1__NOPE1_namex2af1__NOPE1x2b = { "f1::NOPE1", "f1::NOPE1", new ::hilti::rt::type_info::Struct(std::vector<::hilti::rt::type_info::struct_::Field>({::hilti::rt::type_info::struct_::Field{ "__error", &type_info::__ti_optional_hilti__RecoverableFailure__optionalx2anamex2ahilti__RecoverableFailurex2bx2b, offsetof(f1::NOPE1, __error), true, false }})) };
    const ::hilti::rt::TypeInfo __ti_f1__NOPE1_namex2af1__NOPE1x2b = { "f1::NOPE1", "f1::NOPE1", new ::hilti::rt::type_info::Struct(std::vector<::hilti::rt::type_info::struct_::Field>({::hilti::rt::type_info::struct_::Field{ "__error", &type_info::__ti_optional_hilti__RecoverableFailure__optionalx2anamex2ahilti__RecoverableFailurex2bx2b, offsetof(f1::NOPE1, __error), true, false }})) };
    const ::hilti::rt::TypeInfo __ti_f2__NOPE2_namex2af2__NOPE2x2b = { "f2::NOPE2", "f2::NOPE2", new ::hilti::rt::type_info::Struct(std::vector<::hilti::rt::type_info::struct_::Field>({::hilti::rt::type_info::struct_::Field{ "__error", &type_info::__ti_optional_hilti__RecoverableFailure__optionalx2anamex2ahilti__RecoverableFailurex2bx2b, offsetof(f2::NOPE2, __error), true, false }})) };