forward port libdir preservation patch