From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D66F4385BF83; Sun, 12 Apr 2020 21:02:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D66F4385BF83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586725365; bh=PQvOAZMdApDJNK/mSrz2eDSeB7zpYlokFMS6G4JGszU=; h=From:To:Subject:Date:From; b=oa8c17uQ9KDu2DNFFAwxy8Fjnecdr+kVMmzPVkje/H8xTPYUOLTnQG0iF6rWN+8Sm DEEwY4QdXFpv748A7Tigb/HAF4dhSp7f1oky/xLlJlu/w6Fz3LtzzTa8XIKWj95aaX ZFPch6Y33V09tWU2edlc4i6RpE7kUe5898s/r+mc= From: "john at selbie dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug gcov-profile/94570] New: -fprofile-dir is broken on Cygwin Date: Sun, 12 Apr 2020 21:02:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: gcov-profile X-Bugzilla-Version: 9.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: john at selbie dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2020 21:02:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94570 Bug ID: 94570 Summary: -fprofile-dir is broken on Cygwin Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: john at selbie dot com CC: marxin at gcc dot gnu.org Target Milestone: --- The following bug is unique to gcc and g++ running on Cygwin. I can repro = this on both gcc 9.2 and 9.3. Using almost any source file, execute the following to start the first phas= e of a profile guided optimization on Cygwin with a target directory to store .g= cda files: $ g++ anyprogram.cpp -o anyprogram -fprofile-generate -fprofile-dir=3Dprofi= ledata Then run the compiled code to start the program: $ ./anyprogram.exe After the program completes, the following output is revealed to show that = the coverage code couldn't save the gcda file: profiling:profiledata/#home#jselbie\anyprogram.gcda:Skip The .gcda file is not crated. You can even see the mangled string it in the resulting binary: $ strings anyprogram.exe | grep jselbie profiledata/#home#jselbie\anyprogram.gcda I see two possible issues that's causing this. First, the anyprogram.gcda string is getting appended with a back slash ins= tead of a forward slash A quick cursory glace of GCC sources would suggest the issue is in \gcc\coverage.c. Looking at the code for coverage_init inside gcc/converage= .c reveals the following: if (profile_data_prefix) { #if HAVE_DOS_BASED_FILE_SYSTEM const char *separator =3D "\\"; #else const char *separator =3D "/"; #endif filename =3D concat (getpwd (), separator, filename, NULL); filename =3D mangle_path (filename); len =3D strlen (filename); } Another cursory search of gcc sources suggest HAVE_DOS_BASED_FILE_SYSTEM is defined by this preprocessor stuff: #if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__) # ifndef HAVE_DOS_BASED_FILE_SYSTEM # define HAVE_DOS_BASED_FILE_SYSTEM 1 # endif Because HAVE_DOS_BASED_FILE_SYSTEM is getting defined for Cygwin, then coverage_init is going to use a backslash separator as well. Whether CYGWIN should be considered a DOS based file system or a special exception needs t= o be made in coverage_init, well, I'm not sure. The second issue is with the way the path gets mangled with # chars. That's not consistent with the Linux build (at least with g++ 7.5 that I have goin= g). The workaround for now is to skip using the -fprofile-dir flag and allow default save behavior for the gcda flag.=