Extract std::libc to its own crate

Rebasing of #12526 with a very obscure bug fixed on windows.