Does a design that links together several shader objects to create a single shader object create less optimized shaders than a design that uses string concatenation? I’d like to provide a cache of shader objects that contains useful functions for shader authors. They would call a function from their shader, and link against the appropriate shader object, instead of concatenating a string with the function.
One concern I have is the linker may not be able to perform as many optimizations as the compiler. For example, if a user calls a function to emulate depth clamping from a vertex/fragment shader when the hardware supports depth clamping, the functions would be empty and I hope optimized away.
In general, how good should I expect the GLSL optimizer to be at things like inlining, factoring out redundant computation, etc. As good as modern C++ compilers?