wow, didn't expect such a response thanks.
every think is working as expected. I was mislead by some functions from the APDS9930 library that I was not using, but the library was using them in its init function. I solved my problem by reducing size of my code and additionally I removed some functions from the APDS9930 library.
So, bottom line. The Arduino IDE uses -fprogram-sections and -Wl,--gc-sections switches during compilation. Those switches remove the unused parts of the compiled objects from the resulting binary.