Profiling problem with newlib
Jeff Johnston
jjohnstn@redhat.com
Mon Nov 30 21:30:00 GMT 2009
On 25/11/09 02:25 PM, Joel Nygren wrote:
> Hello, I have some problems with profiling. I have compiled and
> installed newlib.
>
> cd objdir/
> ../newlib-1.17.0/configure --disable-multilib --with-newlib
> --prefix=<installdir>
> make
> make install
>
> Then I compile my programs with:
>
> /opt/gcc-4.4.1/lib/gcc -nostdlib
> <installdir>/i686-pc-linux-gnu/lib/crt0.o HelloWorld.c -I
> <installdir>/i686-pc-linux-gnu/include -L
> <installdir>/i686-pc-linux-gnu/lib -lc -lm -o Helloworld
>
> So far everything works fine. But when I add the parameter
> -fprofile-arcs to gcc, I get this error:
>
> /opt/gcc-4.4.1/lib/gcc/i686-pc-linux-gnu/4.4.1/libgcov.a(_gcov.o): In
> function `gcov_version':
> <gccSrcDir>/libgcc/../gcc/libgcov.c:141: undefined reference to `stderr'
> /opt/gcc-4.4.1/lib/gcc/i686-pc-linux-gnu/4.4.1/libgcov.a(_gcov.o): In
> function `__gcov_open':
> <gccSrcDir>/libgcc/../gcc/gcov-io.c:92: undefined reference to
> `__errno_location'
> /opt/gcc-4.4.1/lib/gcc/i686-pc-linux-gnu/4.4.1/libgcov.a(_gcov.o): In
> function `fstat':
> /usr/include/sys/stat.h:467: undefined reference to `__fxstat'
> /opt/gcc-4.4.1/lib/gcc/i686-pc-linux-gnu/4.4.1/libgcov.a(_gcov.o): In
> function `gcov_exit':
> <gccSrcDir>/libgcc/../gcc/libgcov.c:461: undefined reference to `stderr'
> <gccSrcDir>/libgcc/../gcc/libgcov.c:323: undefined reference to `stderr'
> <gccSrcDir>/libgcc/../gcc/libgcov.c:524: undefined reference to `stderr'
> /opt/gcc-4.4.1/lib/gcc/i686-pc-linux-gnu/4.4.1/libgcov.a(_gcov.o): In
> function `create_file_directory':
> <gccSrcDir>/libgcc/../gcc/libgcov.c:111: undefined reference to
> `__errno_location'
> <gccSrcDir>/libgcc/../gcc/libgcov.c:113: undefined reference to `stderr'
> /opt/gcc-4.4.1/lib/gcc/i686-pc-linux-gnu/4.4.1/libgcov.a(_gcov.o): In
> function `gcov_exit':
> <gccSrcDir>/libgcc/../gcc/libgcov.c:312: undefined reference to `stderr'
> /opt/gcc-4.4.1/lib/gcc/i686-pc-linux-gnu/4.4.1/libgcov.a(_gcov.o): In
> function `gcov_version':
> <gccSrcDir>/libgcc/../gcc/libgcov.c:141: undefined reference to `stderr'
> collect2: ld returned 1 exit status
>
> It's like libgcov.a uses libc, but libc in newlib doesn't contain these
> references. But I know that stderr is in libc, because I have used it in
> my program and it works fine. I get the same errors when I use my built
> in gcc, so I haven't done anything special with my gcc. Is there anyway
> to use fprofile-arcs with newlib?
>
The problem is that libgcov.a has been built using the system glibc
headers and you are running with newlib which won't work.
You need to build your libgcov.a with newlib headers which can be done
by putting newlib into your gcc source tree and configuring
--with-newlib (basically link libgloss and newlib as siblings of gcc in
the top-level src directory). You might also need to specify
--with-headers=xxxx where xxxx is the path to newlib's libc/include
directory.
-- Jeff J.
More information about the Newlib
mailing list