reflaxe.CPP icon indicating copy to clipboard operation
reflaxe.CPP copied to clipboard

Honour @:keep meta

Open fourst4r opened this issue 2 years ago • 4 comments

Reflaxe does not honour the @:keep meta which says

If used on a class, the class along with all fields is unaffected by DCE. If used on a field, that field is unaffected by DCE.

https://haxe.org/manual/cr-dce.html

Other targets will always generate a class that has @:keep meta regardless of if it is used or not.

fourst4r avatar Jul 23 '23 03:07 fourst4r

Yeahhh, reflaxe/C++ has its own custom DCE system (kind of like the JS target), but I completely forgot to account for @:keep. Good find!! ^^

SomeRanDev avatar Jul 31 '23 03:07 SomeRanDev

Hah, that explains why the DCE is so good, on the Lua target compiling function main() {} with --dce=full outputs about 700 lines of Lua.

Also FYI there's a @:dce meta you can apply to types as well which

Forces dead code elimination even when --dce full is not specified.

fourst4r avatar Jul 31 '23 08:07 fourst4r

@:keep should be fixed if you update Reflaxe, but leaving this open since also need to resolve @:dce 👌

SomeRanDev avatar Aug 08 '23 03:08 SomeRanDev

Aha now it make sense In my go target, I had too keep smartDCE off otherwise I was losing some importent classes, next time I will try to fine a common denominator.

neimanpinchas avatar Aug 08 '24 18:08 neimanpinchas