Linking mips .o files compiled with different -march= settings

Matt Turner mattst88@gmail.com
Sun Sep 16 18:38:00 GMT 2012


I've written some SIMD-optimized code for pixman
(http://cgit.freedesktop.org/pixman/) that works on the Loongson MIPS
CPU. There are different (mutually incompatible) revisions of the CPU:
2E and 2F. gcc provides no -m<flag> to turn on just the vectorization
instructions like -msse or -mmmx on x86, so the only way to enable
them is with -march=loongson2{e,f}.

I'd like to compile my single source file with different -march=
settings, provide different function entry-points, and link the
resulting .o files into the main library which can do runtime
selection to pick which code to use.

It seems as if ld cannot link object code files that have been
compiled with -march=loongson2e and -march=loongson2f together though.
See the attached test case.

cc -O2 -march=loongson2e -c ls2e.c -o ls2e.o
cc -O2 -march=loongson2f -c ls2f.c -o ls2f.o
cc -shared ls2e.o ls2f.o -o test.so
/usr/lib/gcc/mips64el-unknown-linux-gnu/4.6.2/../../../../mips64el-unknown-linux-gnu/bin/ld:
ls2e.o: linking mips:loongson_2e module with previous mips:loongson_2f
modules
/usr/lib/gcc/mips64el-unknown-linux-gnu/4.6.2/../../../../mips64el-unknown-linux-gnu/bin/ld:
failed to merge target specific data of file ls2e.o
collect2: ld returned 1 exit status
make: *** [test.so] Error 1

I'm using gcc-4.6.2 and binutils-2.22.

Is there a reason why what I planned to do with pixman wouldn't work
-- is there a real problem that binutils is preventing me from running
into by rejecting the link?

My pixman build system patch is available here:
http://lists.freedesktop.org/archives/pixman/2012-September/002249.html

Thanks,
Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.patch
Type: application/octet-stream
Size: 690 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20120916/15f3fd7f/attachment.obj>


More information about the Binutils mailing list