Extract cxxflags method from cflags method
Pass optimization and arch flags during configure

Closes #24106.
cairo: no longer require stdenv when building universal
erlang: remove superenv workaround