Bug 327151 - MIPS: compilation hangs
Summary: MIPS: compilation hangs
Status: RESOLVED WORKSFORME
Alias: None
Product: valgrind
Classification: Developer tools
Component: drd (other bugs)
Version First Reported In: 3.9.0.SVN
Platform: unspecified Linux
: NOR grave
Target Milestone: ---
Assignee: Bart Van Assche
URL:
Keywords:
: 327155 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-11-05 00:15 UTC by Carl
Modified: 2014-05-09 12:21 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
changes Makefile.am and Makefile.in in drd directory to use -O1 instead of -O2 (1.04 KB, patch)
2013-11-19 01:57 UTC, Carl
Details
optimzation level set in drd directory Makefile.am is set to -O1 since Makefile.in is removed and recreated (412 bytes, patch)
2013-11-19 19:49 UTC, Carl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carl 2013-11-05 00:15:08 UTC
I am using the toolchain:

mips-4.3-51-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2

When I go to compile valgrind using this toolchain, when it enters the drd directory, it stops compiling on the file drd_clientreq.c

Reproducible: Always

Steps to Reproduce:
1.  Configure valgrind:
# CFLAGS="-mips32r2" \
./configure --host=mipsel-linux-uclibc --prefix=/usr --enable-only32bit
2.  Run Make
# make

Actual Results:  
make[3]: Entering directory `/root/mips/valgrind/valgrind-3.9.0/drd'
Making all in .
make[4]: Entering directory `/root/mips/valgrind/valgrind-3.9.0/drd'
mipsel-linux-uclibc-gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../include -I../VEX/pub -DVGA_mips32=1 -DVGO_linux=1 -DVGP_mips32_linux=1 -DVGPV_mips32_linux_vanilla=1  -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wno-format-zero-length -fno-strict-aliasing -fno-builtin -mips32 --param inline-unit-growth=900 -O2 -Wextra -Wformat-nonliteral -Wno-inline -Wno-unused-parameter -Wno-long-long -mips32r2 -Wwrite-strings -fno-stack-protector -MT drd_mips32_linux-drd_barrier.o -MD -MP -MF .deps/drd_mips32_linux-drd_barrier.Tpo -c -o drd_mips32_linux-drd_barrier.o `test -f 'drd_barrier.c' || echo './'`drd_barrier.c
mv -f .deps/drd_mips32_linux-drd_barrier.Tpo .deps/drd_mips32_linux-drd_barrier.Po
mipsel-linux-uclibc-gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../include -I../VEX/pub -DVGA_mips32=1 -DVGO_linux=1 -DVGP_mips32_linux=1 -DVGPV_mips32_linux_vanilla=1  -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wno-format-zero-length -fno-strict-aliasing -fno-builtin -mips32 --param inline-unit-growth=900 -O2 -Wextra -Wformat-nonliteral -Wno-inline -Wno-unused-parameter -Wno-long-long -mips32r2 -Wwrite-strings -fno-stack-protector -MT drd_mips32_linux-drd_clientobj.o -MD -MP -MF .deps/drd_mips32_linux-drd_clientobj.Tpo -c -o drd_mips32_linux-drd_clientobj.o `test -f 'drd_clientobj.c' || echo './'`drd_clientobj.c
mv -f .deps/drd_mips32_linux-drd_clientobj.Tpo .deps/drd_mips32_linux-drd_clientobj.Po
mipsel-linux-uclibc-gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../include -I../VEX/pub -DVGA_mips32=1 -DVGO_linux=1 -DVGP_mips32_linux=1 -DVGPV_mips32_linux_vanilla=1  -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wno-format-zero-length -fno-strict-aliasing -fno-builtin -mips32 --param inline-unit-growth=900 -O2 -Wextra -Wformat-nonliteral -Wno-inline -Wno-unused-parameter -Wno-long-long -mips32r2 -Wwrite-strings -fno-stack-protector -MT drd_mips32_linux-drd_clientreq.o -MD -MP -MF .deps/drd_mips32_linux-drd_clientreq.Tpo -c -o drd_mips32_linux-drd_clientreq.o `test -f 'drd_clientreq.c' || echo './'`drd_clientreq.c
drd_clientreq.c:79: warning: 'optimize' attribute directive ignored


Expected Results:  
It should continue compiling

The toolchain I am using is precompiled.  You can download it from here:

http://www.codesourcery.com/sgpp/lite/mips/portal/package3545/public/mips-linux-gnu/mips-4.3-51-mips-linux-gnu.src.tar.bz2

Running on Ubuntu 10.04.3 32-bit with 512 MB of ram.
Comment 1 Jurasic 2013-11-08 02:30:53 UTC
Hi,

try to change optimization level in drd/Makefile form O2 into O1 and it works fine.
Comment 2 Carl 2013-11-08 03:09:21 UTC
I did notice, it also is settings the -O option twice.  Even though it sets it to -O2, so when it's told to set it to -O1 in the code, since there is 2 of them, it can't.

I will try it with setting it to -O1.
Comment 3 Bart Van Assche 2013-11-08 15:38:01 UTC
*** Bug 327155 has been marked as a duplicate of this bug. ***
Comment 4 Carl 2013-11-19 01:57:24 UTC
Created attachment 83628 [details]
changes Makefile.am and Makefile.in in drd directory to use -O1 instead of -O2
Comment 5 Bart Van Assche 2013-11-19 08:01:19 UTC
The attached patch will reduce performance on x86 and amd64 systems. The changes in drd/Makefile.am should be such that the optimization level is changed for the MIPS platform only.
Comment 6 Carl 2013-11-19 18:49:47 UTC
Well since Makefile.in is generated by Makefile.am, then only Makefile.am only needs to be patched.  But why is -O2 set twice in Makefile.am then?  I think that's why it can't compile that one file.  The warning says it can't change it:

drd_clientreq.c:79: warning: 'optimize' attribute directive ignored

And so it then hangs.
Comment 7 Carl 2013-11-19 19:49:48 UTC
Created attachment 83643 [details]
optimzation level set in drd directory Makefile.am is set to -O1 since Makefile.in is removed and recreated

I now remove all Makefile.in files so that they are recreated
Comment 8 Carl 2013-11-19 19:51:06 UTC
Latest patch I uploaded now just is applied against Makefile.am because I remove all Makefile.in and run ./autogen.sh
Comment 9 Bart Van Assche 2013-11-20 08:05:23 UTC
That second patch also changes the optimization level for all architectures instead of only for MIPS and hence is not acceptable - sorry. Have you considered to lower the optimization level only for the function(s) that causes the compiler to hang, e.g. by inserting code like the following above each function that causes the compiler to hang ?

#if defined(VGP_mips32_linux) || defined(VGP_mips64_linux)
 /* Avoid that this function triggers a bug in the MIPS compiler that causes gcc to hang. */
 __attribute__((optimize("O1")))
#endif
Comment 10 Carl 2013-11-20 20:18:40 UTC
That has already been added to drd_clientreq.c as you can see and is part of the release of valgrind.  And when it attempts to do that, generates this warning where it doesn't lower it:

drd_clientreq.c:79: warning: 'optimize' attribute directive ignored
Comment 11 Petar Jovanovic 2014-02-25 11:47:44 UTC
(In reply to comment #10)
> That has already been added to drd_clientreq.c as you can see and is part of
> the release of valgrind.  And when it attempts to do that, generates this
> warning where it doesn't lower it:
> 
> drd_clientreq.c:79: warning: 'optimize' attribute directive ignored

Can you try to use any recent version of GCC?
Working around issues in old versions of compilers may be endless job.
Comment 12 Carl 2014-02-25 19:13:18 UTC
I can't change the toolchain I'm using because the system I'm using only supports that version.  It is precompiled for me already.
Comment 13 Petar Jovanovic 2014-02-25 23:23:17 UTC
(In reply to comment #12)
> I can't change the toolchain I'm using because the system I'm using only
> supports that version.  It is precompiled for me already.

I understand. Still, I do not think we should be putting workarounds in
Valgrind for the issues with pre 4.5 GCC toolchains unless there is a
really good reason to do it.

Are you fine with having a local patch applied to Valgrind?
Comment 14 Carl 2014-02-26 01:40:45 UTC
Yes I'm fine with that.  Thank you.