[Mesa-dev] [PATCH] glsl: Autogenerate builtin_functions.cpp as part of the build process.
Kenneth Graunke
kenneth at whitecape.org
Tue Jan 11 21:52:59 PST 2011
On Tuesday, January 11, 2011 09:30:49 am José Fonseca wrote:
> This breaks cross-compilation because builtin_function.cpp needs to be
> built with the native compiler, instead of the cross compiler.
Ouch. Good point. How can we make sure it's built for the correct system?
> I see there is a python program too. Is this native program unavoidable?
>
> Jose
Both are necessary. Currently, we use the standalone compiler to transform
the prototypes (in builtins/profiles) from GLSL to IR. While this isn't
strictly necessary, it is more convenient. In the future, I'd also like to
implement most of the built-in functions in GLSL itself, rather than in hand-
coded IR. GLSL is much easier to read, and doesn't need updating when we
change the IR (or printed format).
The idea is to build a stripped down version of the compiler
(builtin_compiler), and use that to compile the built-ins into IR and use that
to generate the final compiler (libglsl.a and glsl_compiler). That way, all
the compilation/optimization costs for built-ins are done at Mesa build time.
As far as I know, this bootstrapping approach is fairly standard practice in
most compiler projects.
If possible, I'd really like to avoid keeping builtin_function.cpp in the
repository. Not only is having a 13000+ line generated file in the repo ugly,
but it makes it really hard to change the IR in small reviewable patches that
still work at each step.
Any build gurus out there? I don't think this is an insurmountable problem -
we just need the right build magic. (twice...really wish we had a single
build system...) I've never done cross-compiling so I'm not sure how to fix
it.
More information about the mesa-dev
mailing list