#1 For a given many-electron system, the Fermi level is not estimated in first-principles calculations, but actually computed using the corresponding formula for the total number of Fermi particles (electrons) determined by the density of states and Fermi-Dirac distribution (this is where the Fermi energy enters the equation).
#2 If you do calculations for a bulk system with no vacuum region, there is no way of referring any energy (including the Fermi energy) to a vacuum level energy. It means that the electron energy is defined up to a constant.
In every first-principles code, there is some internal reference energy used to define all the energy quantities (potential energy, Fermi energy, electron energy and so on). When you compare results obtained in different codes, you should compare energy differences, not the actual energies.
#3 To have a vacuum level as a reference, you should create a vacuum region in your system. This can be achieved by cleaving your crystal, for example, to build a surface. In this case, there is a vacuum region and you can compute work function, electron affinity and ionization potential, but these quantities depend on the actual surface type, i.e. they are actually properties of a surface, not bulk material.
There is plenty of literature on this textbook topic. So, you may read some textbooks on Solid State Physics, as well as original papers, to get a better insight on this issue.