build: improved exception handling for systems without rpath