Bug 25534 - Failed to build pixman-0.17.2 on ARM (undefined reference to `d0') with binutils version < 2.19
Summary: Failed to build pixman-0.17.2 on ARM (undefined reference to `d0') with binut...
Status: RESOLVED FIXED
Alias: None
Product: pixman
Classification: Unclassified
Component: pixman (show other bugs)
Version: other
Hardware: ARM Linux (All)
: medium normal
Assignee: Siarhei Siamashka
QA Contact: Søren Sandmann Pedersen
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-08 22:36 UTC by Seongwon Cho
Modified: 2010-04-02 12:57 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
0001-ARM-Workaround-for-a-NEON-bug-in-assembler-from-bin.patch (2.01 KB, patch)
2009-12-26 15:29 UTC, Siarhei Siamashka
Details | Splinter Review

Description Seongwon Cho 2009-12-08 22:36:40 UTC
Hi.

While I cross compiled the new pixman-0.17.2 to arm (NEON is enabled)

I got the build break.

My MCU is Cortext A-8 and NEON is supported.

And I used "CodeSourcery Sourcery G++ Lite 2007q3-51" compiler to compile the pixman-0.17.2

This is a version information and configuration information of compiler

------------------------------------------------------------------------------
#gcc --version
sbox-arm-none-linux-gnueabi-gcc (CodeSourcery Sourcery G++ Lite 2007q3-51) 4.2.1
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
------------------------------------------------------------------------------
#gcc -v
Using built-in specs.
Reading specs from /scratchbox/compilers/cortex-linux-gnueabi/gcc.specs
rename spec cpp to old_cpp
Target: arm-none-linux-gnueabi
Configured with: /scratch/paul/lite/linux/src/gcc-4.2/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libgomp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion=CodeSourcery Sourcery G++ Lite 2007q3-51 --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/paul/lite/linux/install/arm-none-linux-gnueabi/libc --enable-poison-system-directories --with-build-time-tools=/scratch/paul/lite/linux/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/paul/lite/linux/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.2.1 (CodeSourcery Sourcery G++ Lite 2007q3-51)
------------------------------------------------------------------------------

and 

This is a error.

make[2]: Entering directory `/home/seongwon/workspace/Big_Sources/pixman-0.17.2/test'
gcc -DHAVE_CONFIG_H -I. -I.. -I../pixman -I../pixman     -g -O2 -Wall -fno-strict-aliasing -fvisibility=hidden -MT region-test.o -MD -MP -MF .deps/region-test.Tpo -c -o region-test.o region-test.c
mv -f .deps/region-test.Tpo .deps/region-test.Po
/bin/sh ../libtool --tag=CC   --mode=link gcc  -g -O2 -Wall -fno-strict-aliasing -fvisibility=hidden   -o region-test region-test.o ../pixman/libpixman-1.la 
libtool: link: gcc -g -O2 -Wall -fno-strict-aliasing -fvisibility=hidden -o .libs/region-test region-test.o  ../pixman/.libs/libpixman-1.so -lm
../pixman/.libs/libpixman-1.so: undefined reference to `d0'
../pixman/.libs/libpixman-1.so: undefined reference to `q0'
collect2: ld returned 1 exit status
make[2]: *** [region-test] Error 1
make[2]: Leaving directory `/home/seongwon/workspace/Big_Sources/pixman-0.17.2/test'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/seongwon/workspace/Big_Sources/pixman-0.17.2'
make: *** [all] Error 2
------------------------------------------------------------------------------

Finally you can get the compiler in below link.
Minor version number is updated but I think that is no problem.

http://www.codesourcery.com/sgpp/lite/arm/portal/release1039

Please let me know how can I build the pixman with NEON.

Thanks.
Comment 1 Siarhei Siamashka 2009-12-08 23:00:53 UTC
It's a known problem and it is caused by a bug in your toolchain, which makes it practically unusable for anything NEON related.

You need to either upgrade your toolchain to a newer version which has a fix for it or apply the following patch to binutils: http://sourceware.org/ml/binutils/2008-03/msg00260.html

So it's not a pixman problem, marking it as 'fixed, not our bug'.

What we could probably try is to improve checks in configure script to detect this problem and either disable NEON or provide some detailed error message. But I do not have a broken toolchain installed myself for testing this stuff. And it's also not clear how common this problem could be (hopefully you are the only one affected by it), so I'm not sure if it deserves a special treatment and extra clutter in pixman build scripts.
Comment 2 Siarhei Siamashka 2009-12-26 12:40:39 UTC
This problem is also reproducible with the standard GNU binutils 2.18 (and is fixed in 2.19) as found out by gentoo arm porting team. So it does have more serious practical impact than I initially expected, hence reopening the bug.
Comment 3 Siarhei Siamashka 2009-12-26 12:54:04 UTC
Detecting buggy binutils in configure script is problematic because it involves linking with ".so" file to be detected.

So right now the shortest path to reproduce the problem is to take the following test file:
/**********/
int main()
{
    asm volatile ("vmov d1, d0");
    return 0;
}
/**********/

And run

$ gcc -shared -fPIC -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wl,--no-undefined -o test.so test.c
$ gcc -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wl,--no-undefined test.so
test.so: undefined reference to `d0'
collect2: ld returned 1 exit status

An interesting thing here is that "-Wl,--no-undefined" does not help to detect the problem on the first step. While using a different test program we get:
/**********/
extern int d0;
int main()
{
    d0 = 0;
    return 0;
}
/**********/

$ gcc -shared -fPIC -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wl,--no-undefined -o test2.so test2.c
/tmp/ccI95UGn.o: In function `main':
test2.c:(.text+0x34): undefined reference to `d0'
collect2: ld returned 1 exit status

So looks like testing for this bug in one step from configure via something like AC_LINK_IFELSE does not look possible.

Blacklisting binutils 2.18 based on the version number is also not a good solution because patched versions of 2.18 also exist (for example it is included in maemo SDK).
Comment 4 Siarhei Siamashka 2009-12-26 15:29:04 UTC
Created attachment 32309 [details] [review]
0001-ARM-Workaround-for-a-NEON-bug-in-assembler-from-bin.patch

The following patch can be used to workaround this problem when using buggy versions of binutils.

Still it is a good idea to upgrade to binutils 2.19 or better for all armv7 users. Just because gcc can sometimes emit "vmov" instructions itself when using autovectorization or intrinsics, it's kind of "russian roulette".
Comment 5 Søren Sandmann Pedersen 2010-01-05 16:54:14 UTC
FWIW, I agree with the initial NOTOURBUG. Gentoo needs to provide a working toolchain anyway, either by patching or upgrading.
Comment 6 Siarhei Siamashka 2010-01-08 09:22:03 UTC
(In reply to comment #5)
> FWIW, I agree with the initial NOTOURBUG. Gentoo needs to provide a working
> toolchain anyway, either by patching or upgrading.

Yes, they need to. But the problem here is that the source of this build issue is not completely obvious. That's why I would like to keep this bug open for a while. So that anyone getting hit by it would be able to easily find the needed information in freedesktop.org bugzilla (if they would bother to look here of course).

Various linux distributions have started adopting new versions of pixman and this is one of the potential problems they may encounter.
Comment 7 Siarhei Siamashka 2010-04-02 12:57:44 UTC
Workaround was applied in pixman 0.18.0 -> resolved.

The reason to finally apply this patch was an attempt to reduce the likelihood of getting weird build failures. If the target system is armv6 or older, the user may not see the strict need to upgrade binutils just to fix NEON bug.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.