What happens when you can't make something code-legal?
Depending on the circumstances, the Permit Issuing Authority will either forbid the construction or grant a written "variance" from the rule. Sometimes a variance will have stipulations.

As an example, in my area the electrical service for a new or remodeled residence must be buried. In my case, the nearest available power service was on a pole that already had the maximum number of underground feeds. I received a "variance" in the form of a stamp on my blueprints from the city inspector.