This is something I tried to read up on years ago. I seem to remember there were some basic provisions for this in the emc2 software, but forget the details, and might be wrong.
I know it is not very common in industry, but sometimes a highly accurate measurement system, and there are various kinds, but I am thinking the hypothetical ideal is basically a cmm attached to where the tool in the cnc machine usually is.
They usually describe the errors a machine has with a small number of parameters to indicate the angle between the axis (I.e. How far from exactly orthogonal they are), and other basic means, which assume the axis are still straight, etc.
It occurs to me that another approach may be to use a large table, correlating the actual position with the commanded position. During run time, the software simply consults the table in reverse, and extrapolates between the known points, with some smoothing. That would handle even random errors that might occur when employing cheap linear bearings.
So ultimately, or could greatly reduce the requirement to make the parts highly accurate. Just make it solid, with good repeatability, then compensate extensively by using a cmm for an hour.
For larger machines, finding acmm that size night be impossible. But for smaller machines.