Fix "make check" failure to build on Ubuntu 14.04 LTS

Message ID CALoOobPf=6Lc=1=ZTRK3SuRnfhQw1HChGg96MF_yWx=_iB7zLw@mail.gmail.com
State New, archived
Headers

Commit Message

Paul Pluzhnikov Jan. 18, 2016, 8:40 p.m. UTC
  On Mon, Dec 7, 2015 at 10:13 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Mon, 7 Dec 2015, Paul Pluzhnikov wrote:
>
>> Testing with (gcc-4.8 Ubuntu 4.8.4-2ubuntu1~14.04) 4:4.8.2-1ubuntu6
>> fails for apparently unrelated reasons:
>>
>> build/math/test-double-vlen2-wrappers.o: In function `cos_vlen2':
>> /glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:24:
>> undefined reference to `_ZGVbN2v_cos'
>> /glibc-git/build-system-gcc/math/test-double-vlen2-wrappers.o: In
>> function `sin_vlen2':
>> /glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:25:
>> undefined reference to `_ZGVbN2v_sin'
>> ... etc.
>
> You should raise that with Andrew Senkevich, including details of whether
> libmvec got built, what symbols it exports, the command line used for that
> link, etc.

This continues to fail.

mkdir /tmp/build; cd /tmp/build;
~/Archive/glibc-git/configure --prefix=/usr
make -j40 && make check
...
gcc -nostdlib -nostartfiles -o /tmp/glibc-build/math/test-double-vlen2
   -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both
/tmp/glibc-build/csu/crt1.o /tmp/glibc-build/csu/crti.o `gcc
--print-file-name=crtbegin.o`
/tmp/glibc-build/math/test-double-vlen2.o
/tmp/glibc-build/math/libm.so.6 /tmp/glibc-build/mathvec/libmvec.so.1
/tmp/glibc-build/math/test-double-vlen2-wrappers.o
-Wl,-dynamic-linker=/lib64/ld-linux-x86-64.so.2
-Wl,-rpath-link=/tmp/glibc-build:/tmp/glibc-build/math:/tmp/glibc-build/elf:/tmp/glibc-build/dlfcn:/tmp/glibc-build/nss:/tmp/glibc-build/nis:/tmp/glibc-build/rt:/tmp/glibc-build/resolv:/tmp/glibc-build/crypt:/tmp/glibc-build/mathvec:/tmp/glibc-build/nptl
/tmp/glibc-build/libc.so.6 /tmp/glibc-build/libc_nonshared.a
-Wl,--as-needed /tmp/glibc-build/elf/ld.so -Wl,--no-as-needed -lgcc
-Wl,--as-needed -lgcc_s  -Wl,--no-as-needed `gcc
--print-file-name=crtend.o` /tmp/glibc-build/csu/crtn.o
/tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `cos_vlen2':
/Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:24:
undefined reference to `_ZGVbN2v_cos'
/tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `sin_vlen2':
/Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:25:
undefined reference to `_ZGVbN2v_sin'
/tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `sincos_vlen2':
/Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:26:
undefined reference to `_ZGVbN2vvv_sincos'
/tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `log_vlen2':
/Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:27:
undefined reference to `_ZGVbN2v_log'
/tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `exp_vlen2':
/Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:28:
undefined reference to `_ZGVbN2v_exp'
/tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `pow_vlen2':
/Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:29:
undefined reference to `_ZGVbN2vv_pow'
collect2: error: ld returned 1 exit status
../Rules:154: recipe for target '/tmp/glibc-build/math/test-double-vlen2' failed
make[2]: *** [/tmp/glibc-build/math/test-double-vlen2] Error 1
make[2]: Leaving directory '/Archive/glibc-git/math'
Makefile:214: recipe for target 'math/tests' failed
make[1]: *** [math/tests] Error 2
make[1]: Leaving directory '/Archive/glibc-git'
Makefile:9: recipe for target 'check' failed
make: *** [check] Error 2

$ readelf -Ws  /tmp/glibc-build/mathvec/libmvec.so.1 | grep _ZGVbN2vvv_sincos
    26: 0000000000001ec0    35 IFUNC   GLOBAL DEFAULT   13
_ZGVbN2vvv_sincos@@GLIBC_2.22
    54: 0000000000001ec0    35 IFUNC   LOCAL  DEFAULT   13
__GI__ZGVbN2vvv_sincos
   105: 0000000000001ef0   109 FUNC    LOCAL  DEFAULT   13
_ZGVbN2vvv_sincos_sse2
   108: 0000000000003f40   874 FUNC    LOCAL  DEFAULT   13
_ZGVbN2vvv_sincos_sse4
   196: 0000000000001ec0    35 IFUNC   GLOBAL DEFAULT   13 _ZGVbN2vvv_sincos


The problem appears to be that test-double-vlen2-wrappers.o is on the
link line after libmvec.so.1, and indeed if I move libmvec.so.1 after
test-double-vlen2-wrappers.o, the link succeeds.

Attached patch fixes the problem. Ok for trunk?

Thanks,



2016-01-18  Paul Pluzhnikov  <ppluzhnikov@google.com>

        * math/Makefile (libm-vec-tests): Move libraries after wrappers.o
  

Comments

Adhemerval Zanella Jan. 18, 2016, 9:13 p.m. UTC | #1
On 18-01-2016 18:40, Paul Pluzhnikov wrote:
> On Mon, Dec 7, 2015 at 10:13 AM, Joseph Myers <joseph@codesourcery.com> wrote:
>> On Mon, 7 Dec 2015, Paul Pluzhnikov wrote:
>>
>>> Testing with (gcc-4.8 Ubuntu 4.8.4-2ubuntu1~14.04) 4:4.8.2-1ubuntu6
>>> fails for apparently unrelated reasons:
>>>
>>> build/math/test-double-vlen2-wrappers.o: In function `cos_vlen2':
>>> /glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:24:
>>> undefined reference to `_ZGVbN2v_cos'
>>> /glibc-git/build-system-gcc/math/test-double-vlen2-wrappers.o: In
>>> function `sin_vlen2':
>>> /glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:25:
>>> undefined reference to `_ZGVbN2v_sin'
>>> ... etc.
>>
>> You should raise that with Andrew Senkevich, including details of whether
>> libmvec got built, what symbols it exports, the command line used for that
>> link, etc.
> 
> This continues to fail.
> 
> mkdir /tmp/build; cd /tmp/build;
> ~/Archive/glibc-git/configure --prefix=/usr
> make -j40 && make check
> ...
> gcc -nostdlib -nostartfiles -o /tmp/glibc-build/math/test-double-vlen2
>    -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both
> /tmp/glibc-build/csu/crt1.o /tmp/glibc-build/csu/crti.o `gcc
> --print-file-name=crtbegin.o`
> /tmp/glibc-build/math/test-double-vlen2.o
> /tmp/glibc-build/math/libm.so.6 /tmp/glibc-build/mathvec/libmvec.so.1
> /tmp/glibc-build/math/test-double-vlen2-wrappers.o
> -Wl,-dynamic-linker=/lib64/ld-linux-x86-64.so.2
> -Wl,-rpath-link=/tmp/glibc-build:/tmp/glibc-build/math:/tmp/glibc-build/elf:/tmp/glibc-build/dlfcn:/tmp/glibc-build/nss:/tmp/glibc-build/nis:/tmp/glibc-build/rt:/tmp/glibc-build/resolv:/tmp/glibc-build/crypt:/tmp/glibc-build/mathvec:/tmp/glibc-build/nptl
> /tmp/glibc-build/libc.so.6 /tmp/glibc-build/libc_nonshared.a
> -Wl,--as-needed /tmp/glibc-build/elf/ld.so -Wl,--no-as-needed -lgcc
> -Wl,--as-needed -lgcc_s  -Wl,--no-as-needed `gcc
> --print-file-name=crtend.o` /tmp/glibc-build/csu/crtn.o
> /tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `cos_vlen2':
> /Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:24:
> undefined reference to `_ZGVbN2v_cos'
> /tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `sin_vlen2':
> /Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:25:
> undefined reference to `_ZGVbN2v_sin'
> /tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `sincos_vlen2':
> /Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:26:
> undefined reference to `_ZGVbN2vvv_sincos'
> /tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `log_vlen2':
> /Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:27:
> undefined reference to `_ZGVbN2v_log'
> /tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `exp_vlen2':
> /Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:28:
> undefined reference to `_ZGVbN2v_exp'
> /tmp/glibc-build/math/test-double-vlen2-wrappers.o: In function `pow_vlen2':
> /Archive/glibc-git/math/../sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c:29:
> undefined reference to `_ZGVbN2vv_pow'
> collect2: error: ld returned 1 exit status
> ../Rules:154: recipe for target '/tmp/glibc-build/math/test-double-vlen2' failed
> make[2]: *** [/tmp/glibc-build/math/test-double-vlen2] Error 1
> make[2]: Leaving directory '/Archive/glibc-git/math'
> Makefile:214: recipe for target 'math/tests' failed
> make[1]: *** [math/tests] Error 2
> make[1]: Leaving directory '/Archive/glibc-git'
> Makefile:9: recipe for target 'check' failed
> make: *** [check] Error 2
> 
> $ readelf -Ws  /tmp/glibc-build/mathvec/libmvec.so.1 | grep _ZGVbN2vvv_sincos
>     26: 0000000000001ec0    35 IFUNC   GLOBAL DEFAULT   13
> _ZGVbN2vvv_sincos@@GLIBC_2.22
>     54: 0000000000001ec0    35 IFUNC   LOCAL  DEFAULT   13
> __GI__ZGVbN2vvv_sincos
>    105: 0000000000001ef0   109 FUNC    LOCAL  DEFAULT   13
> _ZGVbN2vvv_sincos_sse2
>    108: 0000000000003f40   874 FUNC    LOCAL  DEFAULT   13
> _ZGVbN2vvv_sincos_sse4
>    196: 0000000000001ec0    35 IFUNC   GLOBAL DEFAULT   13 _ZGVbN2vvv_sincos
> 
> 
> The problem appears to be that test-double-vlen2-wrappers.o is on the
> link line after libmvec.so.1, and indeed if I move libmvec.so.1 after
> test-double-vlen2-wrappers.o, the link succeeds.
> 
> Attached patch fixes the problem. Ok for trunk?
> 
> Thanks,

Is this tied to an specific make/binutils/gcc version that only shows itself
on Ubuntu 14.04?

> 
> 
> 
> 2016-01-18  Paul Pluzhnikov  <ppluzhnikov@google.com>
> 
>         * math/Makefile (libm-vec-tests): Move libraries after wrappers.o
>
  
Paul Pluzhnikov Jan. 18, 2016, 9:24 p.m. UTC | #2
On Mon, Jan 18, 2016 at 1:13 PM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:

> Is this tied to an specific make/binutils/gcc version that only shows itself
> on Ubuntu 14.04?

That seems likely, as nobody else appears to be affected (or this
would have probably been fixed many months ago).

For the record:
gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
GNU ld (GNU Binutils for Ubuntu) 2.24 (2.24-5ubuntu14)

My understanding is that the order of shared libraries on command line
shouldn't matter, but somehow does in this particular configuration.

This is trivially reproduced with:

echo "int foo() { return 0; }" | gcc -fPIC -shared -o foo.so -xc -
cat > t.c <<EOF
int main() { return foo(); }
EOF

gcc t.c ./foo.so
# success

gcc ./foo.so t.c
/tmp/ccKY0qMa.o: In function `main':
t.c:(.text+0xa): undefined reference to `foo'
collect2: error: ld returned 1 exit status
  
Paul Pluzhnikov Jan. 18, 2016, 9:41 p.m. UTC | #3
On Mon, Jan 18, 2016 at 1:24 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
> On Mon, Jan 18, 2016 at 1:13 PM, Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>
>> Is this tied to an specific make/binutils/gcc version that only shows itself
>> on Ubuntu 14.04?
>
> That seems likely

I looked some more. What's happening is that this gcc driver adds
'--as-needed' at the beginning of the link command line. With that
--as-needed there, the problem reproduces with current trunk  binutils
(and probably any other version of binutils).

You should be able to reproduce this as well with:

  gcc -Wl,--as-needed ./foo.so t.c

P.S. To be clear, I don't care if this patch goes in after the hard
freeze is lifted, though it's trivially correct and may help anyone
with similarly configured GCC.
  
Carlos O'Donell Jan. 18, 2016, 10:16 p.m. UTC | #4
On 01/18/2016 03:40 PM, Paul Pluzhnikov wrote:
> 2016-01-18  Paul Pluzhnikov  <ppluzhnikov@google.com>
> 
>         * math/Makefile (libm-vec-tests): Move libraries after wrappers.o

As you identified this is a search order issue.

In practice we should follow:
- Object files.
- Archive files.
- Shared objects.

This results in the most compatible search order possible on all possible
systems and allows archive symbols to override shared objects.

I think your fix is correct. Please check this in to fix Ubuntu.

Cheers,
Carlos.
 
> diff --git a/math/Makefile b/math/Makefile
> index 8bedef7..222ee6b 100644
> --- a/math/Makefile
> +++ b/math/Makefile
> @@ -295,8 +295,8 @@ $(objpfx)libieee.a: $(objpfx)ieee-math.o
>  
>  $(addprefix $(objpfx),$(filter-out $(tests-static) $(libm-vec-tests),$(tests))): $(libm)
>  $(addprefix $(objpfx),$(tests-static)): $(objpfx)libm.a
> -$(addprefix $(objpfx), $(libm-vec-tests)): $(objpfx)%: $(libm) $(libmvec) \
> -					   $(objpfx)%-wrappers.o
> +$(addprefix $(objpfx), $(libm-vec-tests)): $(objpfx)%: $(objpfx)%-wrappers.o $(libm) \
> +					   $(libmvec)
>  
>  gmp-objs = $(patsubst %,$(common-objpfx)stdlib/%.o,\
>  		      add_n sub_n cmp addmul_1 mul_1 mul_n divmod_1 \
  
Carlos O'Donell Jan. 18, 2016, 10:16 p.m. UTC | #5
On 01/18/2016 04:41 PM, Paul Pluzhnikov wrote:
> On Mon, Jan 18, 2016 at 1:24 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
>> On Mon, Jan 18, 2016 at 1:13 PM, Adhemerval Zanella
>> <adhemerval.zanella@linaro.org> wrote:
>>
>>> Is this tied to an specific make/binutils/gcc version that only shows itself
>>> on Ubuntu 14.04?
>>
>> That seems likely
> 
> I looked some more. What's happening is that this gcc driver adds
> '--as-needed' at the beginning of the link command line. With that
> --as-needed there, the problem reproduces with current trunk  binutils
> (and probably any other version of binutils).
> 
> You should be able to reproduce this as well with:
> 
>   gcc -Wl,--as-needed ./foo.so t.c
> 
> P.S. To be clear, I don't care if this patch goes in after the hard
> freeze is lifted, though it's trivially correct and may help anyone
> with similarly configured GCC.

This should go in now.

Cheers,
Carlos.
  
Joseph Myers Jan. 18, 2016, 10:30 p.m. UTC | #6
On Mon, 18 Jan 2016, Paul Pluzhnikov wrote:

> The problem appears to be that test-double-vlen2-wrappers.o is on the
> link line after libmvec.so.1, and indeed if I move libmvec.so.1 after
> test-double-vlen2-wrappers.o, the link succeeds.
> 
> Attached patch fixes the problem. Ok for trunk?

If this is bug 19451 then you should include that bug number in the 
ChangeLog entry and change that bug to FIXED with the appropriate 
milestone set.
  
Paul Pluzhnikov Jan. 18, 2016, 10:40 p.m. UTC | #7
On Mon, Jan 18, 2016 at 2:30 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Mon, 18 Jan 2016, Paul Pluzhnikov wrote:
>
>> The problem appears to be that test-double-vlen2-wrappers.o is on the
>> link line after libmvec.so.1, and indeed if I move libmvec.so.1 after
>> test-double-vlen2-wrappers.o, the link succeeds.
>>
>> Attached patch fixes the problem. Ok for trunk?
>
> If this is bug 19451 then you should include that bug number in the
> ChangeLog entry and change that bug to FIXED with the appropriate
> milestone set.

It is; done; done.

Thanks.
  

Patch

diff --git a/math/Makefile b/math/Makefile
index 8bedef7..222ee6b 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -295,8 +295,8 @@  $(objpfx)libieee.a: $(objpfx)ieee-math.o
 
 $(addprefix $(objpfx),$(filter-out $(tests-static) $(libm-vec-tests),$(tests))): $(libm)
 $(addprefix $(objpfx),$(tests-static)): $(objpfx)libm.a
-$(addprefix $(objpfx), $(libm-vec-tests)): $(objpfx)%: $(libm) $(libmvec) \
-					   $(objpfx)%-wrappers.o
+$(addprefix $(objpfx), $(libm-vec-tests)): $(objpfx)%: $(objpfx)%-wrappers.o $(libm) \
+					   $(libmvec)
 
 gmp-objs = $(patsubst %,$(common-objpfx)stdlib/%.o,\
 		      add_n sub_n cmp addmul_1 mul_1 mul_n divmod_1 \