On Sat, 2009-10-31 at 09:25 +0100, Nicolas Chauvet wrote:
2009/10/31 Bruno Wolff III <bruno(a)wolff.to>:
> I am working on packaging pagedgeometry and I noticed that when building
> on gcc it passes -msse which I am guessing says to use sse instructions.
> I think that even in F12 we can't assume these instructions are available.
> The package may gain a lot of benefit from using those instructions.
> (I haven't tested that yet as I am still pretty early in the process.)
> Is there some relatively standard way to handle something like this?
-msse is fine for x86_64 and ia64 by default (but not for non-intel arches).
The only way to have sse enabled on ix86 is for a library to be built
twice, the provides the sse version in %{_libdir}/sse2. The linker
will then enable the appropriate library at runtime.
Strictly, this is not true. Newer binutils has a feature called
"indirect functions" that lets you do (logically, this is not what the
syntax actually looks like):
typedef void *(*memcpy_func)(void *, void *, size_t);
static void *_mmx_memcpy(void *d, void *s, size_t n) { ... }
static void *_sse_memcpy(void *d, void *s, size_t n) { ... }
/* ... */
__attribute__((indirect)) memcpy_func *memcpy()
{
if (has_mmx())
return _mmx_memcpy;
if (has_sse())
return _sse_memcpy;
/* ... */
}
The indirect function is called at symbol resolution time instead of the
normal lookup rules, so you can build a single object with support for
multiple ISA extensions, without the runtime lookup penalty.
- ajax