g++ with -fprofile-dir flag has a bug (backslash instead of forward-slash issue)
John Selbie
jselbie@gmail.com
Sun Apr 12 10:59:20 GMT 2020
Sure, but this bug is unique to cygwin. Why would that be there bug?
On Sun, Apr 12, 2020 at 2:57 AM JonY via Cygwin <cygwin@cygwin.com> wrote:
> On 4/12/20 7:27 AM, John Selbie via Cygwin wrote:
> > TLDR: With gcc/g++ 9.2.0 and 9.30 on Cygwin, when you use
> > -fprofile-generate and -fprofile-dir together, the target path for the
> > .gcda file is corrupted with a backslash instead of having a forward
> slash
> > used.
> >
> > Here's a sample run where profile guided optimization is getting enabled
> > for a simple little C++ program:
> >
> > jselbie@IRONMAIDEN ~/bench
> > $ g++ bench.cpp -o bench -fprofile-generate
> > -fprofile-dir=/home/jselbie/bench/profile -O3
> >
> > jselbie@IRONMAIDEN ~/bench
> > $ ./bench.exe
> >
> > profiling:/home/jselbie/bench/profile/#home#jselbie#bench\bench.gcda:Skip
> >
> > That "profiling...Skip" line is an error indicating that the profiling
> > library can't save the gcda file. If you look closely,there's backslash
> > between the encoded path and the filename (bench.gcda).
> >
> > Doing a strings search on the binary reveals the same thing:
> >
> > jselbie@IRONMAIDEN ~/bench
> > $ strings bench.exe | grep jselbie
> > /home/jselbie/bench/profile/#home#jselbie#bench\bench.gcda
> >
> > If I switch back to Linux and do the same steps, it not only works, but
> you
> > can see there is no backslash embedded into the binary either
> >
> > jselbie@IRONMAIDEN:~/bench$ g++ bench.cpp -o bench
> -fprofile-generate
> > -fprofile-dir=/home/jselbie/bench/profile -O3
> >
> > jselbie@IRONMAIDEN:~/bench$ ./bench
> >
> > jselbie@IRONMAIDEN:~/bench$ ls profile/
> > bench.gcda
> >
> > jselbie@IRONMAIDEN:~/bench$ strings bench | grep jselbie
> > /home/jselbie/bench/profile/bench.gcda
> >
> >
> > The workaround is to just skip the -fprofile-dir flag altogether.
> >
> > Seems like there is a bug in Cygwin's build of gcc/g++ that puts the
> wrong
> > path separator into the executable
> >
> > Can this be fixed? Or a place where I can file a bug?
> >
>
> Try filing the issue on https://gcc.gnu.org/bugzilla/, include a minimal
> test case that shows the problem, thanks.
>
>
> --
> Problem reports: https://cygwin.com/problems.html
> FAQ: https://cygwin.com/faq/
> Documentation: https://cygwin.com/docs.html
> Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
>
More information about the Cygwin
mailing list