mark globals as internal when not building a library

Closes #9494