move build optimizations to s4-common