于 2011/7/29 18:32, PcX 写道:
Hi ,all

    I try to use PGO Optimization to build MinGW64 CRT, but in the check, it has some link stage errors.

    1) I use the configure option below:
         ./configure --prefix=/mingw --enable-lib32 --enable-wildcard --enable-tests-unicode

    2) make  CFLAGS="-pipe -O3 -fprofile-generate" \
                  CXXFLAGS="-pipe -O3 -fprofile-generate" \

    3) make install
        then update your crt with installed one

    4) make  CFLAGS="-pipe -O3 -fprofile-generate" \
                  CXXFLAGS="-pipe -O3 -fprofile-generate" \
                  LDFLAGS="-fprofile-generate" check

    then the link problem comes out:

gcc  -pipe -std=gnu99 -Wall -Wextra -Wformat -Wstrict-aliasing -Wshadow -Wpacked -Winline -Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes -pipe -O3 -fprofile-generate  -fprofile-generate -o testcases/t_ansi_io.exe testcases/t_ansi_io.o
e:/mypack/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/lib/libmingwex.a(lib32_libmingwex_a-mingw_pformat.o):mingw_pformat.c:(.text+0x174e): undefined reference to `__gcov_pow2_profiler'
e:/mypack/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/lib/libmingwex.a(lib32_libmingwex_a-mingw_pformat.o):mingw_pformat.c:(.text+0x1798): undefined reference to `__gcov_interval_profiler'
collect2: ld returned 1 exit status
make[2]: *** [testcases/t_ansi_io.exe] Error 1
make[2]: Leaving directory `/e/new/gcc/mingw-w64/build/mingw-w64-crt'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `/e/new/gcc/mingw-w64/build/mingw-w64-crt'
make: *** [check] Error 2

    All log is in the attachment.

Well, this is not the problem.
If I add the "-Wl,-v" to ldflags, I found that -lmingwex is after -lgcov, so the problem comes out.

Best Regards,