From: <sundeep.kokkonda@gmail.com>
To: "'Andrew Pinski'" <pinskia@gmail.com>
Cc: "'GCC Patches'" <gcc-patches@gcc.gnu.org>
Subject: RE: [PATCH] Fix for GCC '-MF' option cannot deal with long paths in Windows
Date: Wed, 19 Jan 2022 10:39:32 +0530 [thread overview]
Message-ID: <003501d80cf2$c1ab0820$45011860$@gmail.com> (raw)
In-Reply-To: <CA+=Sn1k1aUGnbZ5vudt2xJ_zoOtHdmJqn=vSMi5645GgUjZGEA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 975 bytes --]
Hello Andrew,
I updated the patch. Please see attached patch files and let me know your feedback.
Thanks,
Sundeep K.
-----Original Message-----
From: Andrew Pinski <pinskia@gmail.com>
Sent: Tuesday, January 18, 2022 9:22 AM
To: sundeep.kokkonda@gmail.com
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix for GCC '-MF' option cannot deal with long paths in Windows
On Mon, Jan 17, 2022 at 8:35 AM Sundeep KOKKONDA via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>
> Hello,
>
>
>
> The '-MF' option cannot deal with path size >256 characters in
> Windows. This patch is to fix this long path issue with -MF option.
>
> Let me know is it ok to commit?
I don't think this is the right place to put this.
Maybe a better way to implement this is to have a wrapper around fopen for windows and do it that way.
Does open have the same issue?
Thanks,
Andrew Pinski
>
>
>
>
>
> --
>
> Thanks,
>
> Sundeep K.
>
[-- Attachment #2: lrealpath.patch --]
[-- Type: application/octet-stream, Size: 1219 bytes --]
diff --git a/libiberty/lrealpath.c b/libiberty/lrealpath.c
index 3c7053b0b70..593b51c2d96 100644
--- a/libiberty/lrealpath.c
+++ b/libiberty/lrealpath.c
@@ -36,6 +36,8 @@ components will be simplified. The returned value will be allocated using
#include "config.h"
#include "ansidecl.h"
#include "libiberty.h"
+#include <malloc.h>
+#include "filenames.h"
#ifdef HAVE_LIMITS_H
#include <limits.h>
@@ -138,6 +140,32 @@ lrealpath (const char *filename)
{
char buf[MAX_PATH];
char* basename;
+
+ size_t filelen;
+
+ filelen = strlen (filename) + 1;
+
+ if (filelen > MAX_PATH - 1)
+ {
+ char * fullpath;
+ fullpath = (char *) malloc (filelen+8);
+
+ filelen = strlen (filename)+1;
+ strcpy(fullpath,"\\\\?\\");
+ strcat(fullpath,filename);
+
+ for (int i = 0; fullpath[i]; i++)
+ {
+ if (IS_UNIX_DIR_SEPARATOR (fullpath[i]))
+ fullpath[i] = '\\';
+ }
+
+ strcpy(filename,fullpath);
+ free(fullpath);
+
+ return (strdup(filename));
+ }
+
DWORD len = GetFullPathName (filename, MAX_PATH, buf, &basename);
if (len == 0 || len > MAX_PATH - 1)
return strdup (filename);
[-- Attachment #3: c-opts.patch --]
[-- Type: application/octet-stream, Size: 492 bytes --]
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index aa6801fa811..0f019fb1caa 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -1291,7 +1291,7 @@ c_common_finish (void)
deps_stream = stdout;
else
{
- deps_stream = fopen (deps_file, deps_append ? "a": "w");
+ deps_stream = fopen (lrealpath(deps_file), deps_append ? "a": "w");
if (!deps_stream)
fatal_error (input_location, "opening dependency file %s: %m",
deps_file);
next prev parent reply other threads:[~2022-01-19 5:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 16:32 sundeep.kokkonda
2022-01-18 3:51 ` Andrew Pinski
2022-01-19 5:09 ` sundeep.kokkonda [this message]
2022-02-04 3:59 ` sundeep.kokkonda
2022-02-22 5:21 ` sundeep.kokkonda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='003501d80cf2$c1ab0820$45011860$@gmail.com' \
--to=sundeep.kokkonda@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=pinskia@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).