How to disable auto-optimization for GLSL

If I define a uniform variable in GLSL and do not use it in the main function, then at runtime there will be an error message saying "no such uniform named XXX". How to disable this kind of auto-optimization.