emscripten-core / emscripten-core/emscripten
Why linker strips about 90% of used files / classes?
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Hello,
I'm currently working on the project which is using proto buffers, which register descriptors globally this way:
```
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::std::false_type
_static_init2_ PROTOBUF_UNUSED =
(::_pbi::AddDescriptors(&descriptor_table_mediapipe_2fcalculators_2ftensor_2ftensors_5fto_5fsegmentation_5fcalculator_2eproto),
::_pbi::ExtensionSet::RegisterMessageExtension(
&::mediapipe::CalculatorOptions::default_instance(), 374311106, 11,
false, false, &::mediapipe::TensorsToSegmentationCalculatorOptions::default_instance(),
nullptr, ::_pbi::LazyAnnotation::kUndefined),
::std::false_type{});
```
Here ::_pbi::AddDescriptors - just registeres the class in the global factory.
There are over 100 such .proto files / classes.
But during parsing .pbtxt files parser throws lot of errors regarding missing extensions.
It turns out linker just strips majority of my classes with self registration.
Currently i log all the registered descriptors and I was surprized that over 90% of my classes just stripped away.
Why linker strips the code which is potentially used in the final executable?
I checked generated ninja file and those .o files are linked to the static library libmediaPipe.a which is linked to final executable. So those classes should not be stripped.
Contributor guide
Assessment
This issue has not been assessed yet.