Conditional compilation and resulting binary

I have been using conditional configuration checks to import files based on the target OS. The files all contain the same methods and names but different implementations based on OS. The behaviour works as expected. However, the resulting binary ELF file contains all of the files. Based on the the behaviour, the conditional use of the files work based on the OS. However, I am not sure why they are all showing up in the ELF. Is this normal? I expected only the conditional file to show up.


How are you making the conditional imports, and how are you viewing the files in the ELF?

I am making conditional imports like so:

#[cfg(target_os = "linux")]
use crate::log::**linux**;

    not(target_os = "macos"),
    not(target_os = "linux"),
    not(target_os = "windows")
use crate:log::**default**;

where **xyz** is the conditional file:

I used the following method to inspect *.rlib

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.