On Constraints in First-Order Optimization: A View from Non-Smooth Dynamical Systems