We address the question of whether geometric conditions on the given data can be preserved by a solution in (1) the Whitney extension problem, and (2) the Brenner-Fefferman-Hochster-Kollar problem, both for $mathcal C^m$ functions. Our results involve a certain loss of differentiability. Problem (2) concerns the solution of a system of linear equations $A(x)G(x)=F(x)$, where $A$ is a matrix of functions on $mathbb R^n$, and $F$, $G$ are vector-valued functions. Suppose the entries of $A(x)$ are semialgebraic (or, more generally, definable in a suitable o-minimal structure). Then we find $r=r(m)$ such that, if $F(x)$ is definable and the system admits a $mathcal C^r$ solution $G(x)$, then there is a $mathcal C^m$ definable solution. Likewise in problem (1), given a closed definable subset $X$ of $mathbb R^n$, we find $r=r(m)$ such that if $g:Xtomathbb R$ is definable and extends to a $mathcal C^r$ function on $mathbb R^n$, then there is a $mathcal C^m$ definable extension.