Discussion:
[Mingw-cross-env-list] Trying to use x86_64-w64-mingw32.static-g++ -fprofile-generate (inhibit_libc, bug 1665)
Scott Douglass
2018-04-03 21:50:20 UTC
Permalink
Hi,


I've built x86_64-w64-mingw32.static and I'm trying to use x86_64-w64-mingw32.static-g++ -fprofile-generate and I get link errors:


...

> x86_64-w64-mingw32.static-g++ -o hello -fprofile-generate hello.cpp

/tmp/cci0CedL.o:hello.cpp:(.text+0x1a): undefined reference to `__gcov_indirect_call_profiler_v2'

/tmp/cci0CedL.o:hello.cpp:(.text+0x46): undefined reference to `__gcov_time_profiler'

...


I believe this is probably the same problem as this issue: https://github.com/mxe/mxe/issues/1665


I've examined logs/gcc_x86_64-w64-mingw32.static and I see that during the building of libgcov.a

INHIBIT_LIBC_CFLAGS=-Dinhibit_libc

is being used. This causes most of libgcov to be built as stubs and is leading to the link errors.


gcc/configure winds up setting inhibit_libs=true although it looks like it tries not to:

First it notices were configuring a cross-compiler (and sets CROSS="-DCROSS_DIRECTORY_STRUCTURE"), then it notice $target matches *-*-mingw* and sets with_headers=yes and just a bit later sets target_header_dir=$with_headers (i.e. target_header_dir=yes). But 'yes' isn't a very good directory name and $target_header_dir/stdio.h (i.e. 'yes/stdio.h') doesn't exist so it sets inhibit_libc=true.


To work-around this I have tried:

1. Adding '--with-build-sysroot=<abs-path-to-mxe>' to gcc_CONFIGURE_OPTS; this doesn't change the setting of inhibit_libc=true

2. (instead) Adding '--with-sysroot=<abs-path-to-mxe>' to gcc_CONFIGURE_OPTS; now we do not get inhibit_libc set, but the build fails with the message

The directory that should contain system headers does not exist:

<abs-path-to-mxe>/mingw/include

The "/mingw/include" is coming from config.gcc which is setting native_system_header_dir=/mingw/include, but I haven't figured out why yet.

Any suggestions on how to get a build without 'inhibit_libc'? Would you expect it to work by default?

Thanks.

According to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=854368 Debian has fixed/worked-around this problem, but I don't understand what their change was.
Scott Douglass
2018-04-04 15:04:00 UTC
Permalink
I wrote:

>>

I've built x86_64-w64-mingw32.static and I'm trying to use x86_64-w64-mingw32.static-g++ -fprofile-generate and I get link errors:

...

<<

I've found that the missing option is
make ... gcc_CONFIGURE_OPTS="... --with-headers=$(pwd)/usr/$mxe_target/include"

With this I am able to cross-build an application using '-fprofile-generate'.

Should this be the default behaviour when MXE is building gcc? Thanks.
Tony Theodore
2018-04-06 03:56:44 UTC
Permalink
> On 5 Apr 2018, at 01:04, Scott Douglass <***@arm.com> wrote:
>
> I wrote:
> >>
> I've built x86_64-w64-mingw32.static and I'm trying to use x86_64-w64-mingw32.static-g++ -fprofile-generate and I get link errors:
> ...
> <<
>
> I've found that the missing option is
> make ... gcc_CONFIGURE_OPTS="... --with-headers=$(pwd)/usr/$mxe_target/include"
>
> With this I am able to cross-build an application using '-fprofile-generate'.
>
> Should this be the default behaviour when MXE is building gcc? Thanks.

Thanks for the investigation! Yes, coverage should be enabled by default,
though the `—with-headers` seems to be deprecated:

https://gcc.gnu.org/install/configure.html#Cross-Compiler-Specific-Options

and is somewhat annoying as it copies headers into a `sys-include` directory.

I’ll try to get `—with-sysroot` working.

Cheers,

Tony
Tony Theodore
2018-04-06 05:52:17 UTC
Permalink
> I’ll try to get `—with-sysroot` working.

See: https://github.com/mxe/mxe/pull/2101
Scott Douglass
2018-04-06 08:58:07 UTC
Permalink
> > I’ll try to get `—with-sysroot` working.

> See: https://github.com/mxe/mxe/pull/2101


Thanks very much. I've had a look at the patches in the pull request and they look good to me (although I'm no expert here).
Tony Theodore
2018-04-08 02:30:33 UTC
Permalink
Scott Douglass <***@arm.com> wrote:

> > > I’ll try to get `—with-sysroot` working.
>
> > See: https://github.com/mxe/mxe/pull/2101 <https://github.com/mxe/mxe/pull/2101>
>
> Thanks very much. I've had a look at the patches in the pull request and they look good to me (although I'm no expert here).

It’s merged now with the same patches applying to gcc6/7 plugins.

Cheers,

Tony
Loading...