public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/98145] New: On Windows .exe extension is missing when searching/calling mkoffload
@ 2020-12-04 14:39 brechtsanders at users dot sourceforge.net
  2020-12-04 16:26 ` [Bug c/98145] " brechtsanders at users dot sourceforge.net
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2020-12-04 14:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98145

            Bug ID: 98145
           Summary: On Windows .exe extension is missing when
                    searching/calling mkoffload
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: brechtsanders at users dot sourceforge.net
  Target Milestone: ---

I was trying to get nvptx offloading to work on Windows/MinGW-w64, and got the
following output when testing the resulting build:

lto-wrapper.exe: fatal error: could not find accel/nvptx-none/mkoffload in
d:/prog/winlibs64-10.2.0-8.0.0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/10.2.0/;d:/prog/winlibs64-10.2.0-8.0.0/mingw64/bin/../libexec/gcc/;d:/prog/winlibs64-10.2.0-8.0.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/
(consider using '-B')
compilation terminated.

It looks to me like gcc/lto-wrapper.c needs to be fixed so it looks for
mkoffload.exe instead of just mkoffload on Windows.

Probably something like this but with some additional checks to only add the
.exe on the Windows platform:
patch -ulbf gcc/lto-wrapper.c << EOF
@@ -827,6 +827,6 @@
   char *suffix
-    = XALLOCAVEC (char, sizeof ("/accel//mkoffload") + strlen (target));
+    = XALLOCAVEC (char, sizeof ("/accel//mkoffload.exe") + strlen (target));
   strcpy (suffix, "/accel/");
   strcat (suffix, target);
-  strcat (suffix, "/mkoffload");
+  strcat (suffix, "/mkoffload.exe");

EOF

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/98145] On Windows .exe extension is missing when searching/calling mkoffload
  2020-12-04 14:39 [Bug c/98145] New: On Windows .exe extension is missing when searching/calling mkoffload brechtsanders at users dot sourceforge.net
@ 2020-12-04 16:26 ` brechtsanders at users dot sourceforge.net
  2020-12-04 22:29 ` [Bug lto/98145] gcc with nvptx offloading on Windows: lto-wrapper can't find accel/nvptx-none/mkoffload brechtsanders at users dot sourceforge.net
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2020-12-04 16:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98145

--- Comment #1 from Brecht Sanders <brechtsanders at users dot sourceforge.net> ---
Closer investigation shows the issue probably not (or not only) cause by the
.exe extension:

This is the error:
lto-wrapper.exe: fatal error: could not find accel/nvptx-none/mkoffload.exe in
d:/prog/winlibs32-10.2.0-8.0.0/mingw32/bin/../libexec/gcc/i686-w64-mingw32/10.2.0/;d:/prog/winlibs32-10.2.0-8.0.0/mingw32/bin/../libexec/gcc/;d:/prog/winlibs32-10.2.0-8.0.0/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/
(consider using '-B')
d:/prog/winlibs32-10.2.0-8.0.0/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld.exe:
error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status

But the file does exist:
ls -l
'd:/prog/winlibs32-10.2.0-8.0.0/mingw32/bin/../libexec/gcc/i686-w64-mingw32/10.2.0/accel/nvptx-none/mkoffload.exe'
-rwxr-xr-x 1 brecht None 609294 Dec  4 17:14
d:/prog/winlibs32-10.2.0-8.0.0/mingw32/bin/../libexec/gcc/i686-w64-mingw32/10.2.0/accel/nvptx-none/mkoffload.exe

So the question remains: why is lto-wrapper not able to find the file that is
obviously there where it's looking?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug lto/98145] gcc with nvptx offloading on Windows: lto-wrapper can't find accel/nvptx-none/mkoffload
  2020-12-04 14:39 [Bug c/98145] New: On Windows .exe extension is missing when searching/calling mkoffload brechtsanders at users dot sourceforge.net
  2020-12-04 16:26 ` [Bug c/98145] " brechtsanders at users dot sourceforge.net
@ 2020-12-04 22:29 ` brechtsanders at users dot sourceforge.net
  2020-12-05 12:36 ` brechtsanders at users dot sourceforge.net
  2021-01-19 11:13 ` [Bug driver/98145] " burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2020-12-04 22:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98145

--- Comment #2 from Brecht Sanders <brechtsanders at users dot sourceforge.net> ---
Did a bit more digging...
Seems COMPILER_PATH uses ';' as separator on Windows, not ':'.
So besides the .exe issue parse_env_var() also needs to separate the list by a
different separator.

Something like this:

# fix gcc/lto-wrapper.c (version >= 10.2.0)
patch -ulbf gcc/lto-wrapper.c << EOF
@@ -548,4 +548,10 @@
 /* Parse STR, saving found tokens into PVALUES and return their number.
-   Tokens are assumed to be delimited by ':'.  If APPEND is non-null,
-   append it to every token we find.  */
+   Tokens are assumed to be delimited by ':' (or ';' on Windows).
+   If APPEND is non-null, append it to every token we find.  */
+
+#ifdef _WIN32
+#define PATH_LIST_SEPARATOR ';'
+#else
+#define PATH_LIST_SEPARATOR ':'
+#endif

@@ -558,3 +564,3 @@

-  curval = strchr (str, ':');
+  curval = strchr (str, PATH_LIST_SEPARATOR);
   while (curval)
@@ -562,3 +568,3 @@
       num++;
-      curval = strchr (curval + 1, ':');
+      curval = strchr (curval + 1, PATH_LIST_SEPARATOR);
     }
@@ -567,3 +573,3 @@
   curval = str;
-  nextval = strchr (curval, ':');
+  nextval = strchr (curval, PATH_LIST_SEPARATOR);
   if (nextval == NULL)
@@ -581,3 +587,3 @@
       curval = nextval + 1;
-      nextval = strchr (curval, ':');
+      nextval = strchr (curval, PATH_LIST_SEPARATOR);
       if (nextval == NULL)
@@ -827,6 +833,6 @@
   char *suffix
-    = XALLOCAVEC (char, sizeof ("/accel//mkoffload") + strlen (target));
+    = XALLOCAVEC (char, sizeof ("/accel//mkoffload.exe") + strlen (target));
   strcpy (suffix, "/accel/");
   strcat (suffix, target);
-  strcat (suffix, "/mkoffload");
+  strcat (suffix, "/mkoffload.exe");

EOF

But still not there yet. Now my test results in:
mkoffload: fatal error: offload compiler
x86_64-w64-mingw32-accel-nvptx-none-gcc not found (consider using '-B')
compilation terminated.
lto-wrapper.exe: fatal error:
d:/prog/winlibs64-10.2.0-8.0.0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/10.2.0//accel/nvptx-none/mkoffload.exe
returned 1 exit status
compilation terminated.
d:/prog/winlibs64-10.2.0-8.0.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status

So probably mkoffload needs similar fixes...

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug lto/98145] gcc with nvptx offloading on Windows: lto-wrapper can't find accel/nvptx-none/mkoffload
  2020-12-04 14:39 [Bug c/98145] New: On Windows .exe extension is missing when searching/calling mkoffload brechtsanders at users dot sourceforge.net
  2020-12-04 16:26 ` [Bug c/98145] " brechtsanders at users dot sourceforge.net
  2020-12-04 22:29 ` [Bug lto/98145] gcc with nvptx offloading on Windows: lto-wrapper can't find accel/nvptx-none/mkoffload brechtsanders at users dot sourceforge.net
@ 2020-12-05 12:36 ` brechtsanders at users dot sourceforge.net
  2021-01-19 11:13 ` [Bug driver/98145] " burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2020-12-05 12:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98145

--- Comment #3 from Brecht Sanders <brechtsanders at users dot sourceforge.net> ---
Fixing gcc/config/nvptx/mkoffload.c got me one step further, but now the
parameters seem to be the issue:

lto1.exe: error: unrecognized command-line option '-mgomp'
lto1.exe: error: '-foffload-abi' option can be specified only for offload
compiler
mkoffload: fatal error:
D:\Prog\winlibs64-10.2.0-8.0.0\mingw64\bin/x86_64-w64-mingw32-accel-nvptx-none-gcc.exe
returned 1 exit status
compilation terminated.
lto-wrapper.exe: fatal error:
d:/prog/winlibs64-10.2.0-8.0.0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/10.2.0//accel/nvptx-none/mkoffload.exe
returned 5 exit status
compilation terminated.
d:/prog/winlibs64-10.2.0-8.0.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status


The command line being run was:

g++ -Wall -O2 -g -fno-exceptions -fopenmp testomp.cpp kernelomp.o HybridOMP.o
-o testomp

from the Makefile in https://github.com/matthiasdiener/omptest/


The patches to get up to this point (which don't break other platforms) are:

patch -ulbf gcc/lto-wrapper.c << EOF
@@ -548,4 +548,10 @@
 /* Parse STR, saving found tokens into PVALUES and return their number.
-   Tokens are assumed to be delimited by ':'.  If APPEND is non-null,
-   append it to every token we find.  */
+   Tokens are assumed to be delimited by ':' (or ';' on Windows).
+   If APPEND is non-null, append it to every token we find.  */
+
+#ifdef _WIN32
+#define PATH_LIST_SEPARATOR ';'
+#else
+#define PATH_LIST_SEPARATOR ':'
+#endif

@@ -558,3 +564,3 @@

-  curval = strchr (str, ':');
+  curval = strchr (str, PATH_LIST_SEPARATOR);
   while (curval)
@@ -562,3 +568,3 @@
       num++;
-      curval = strchr (curval + 1, ':');
+      curval = strchr (curval + 1, PATH_LIST_SEPARATOR);
     }
@@ -567,3 +573,3 @@
   curval = str;
-  nextval = strchr (curval, ':');
+  nextval = strchr (curval, PATH_LIST_SEPARATOR);
   if (nextval == NULL)
@@ -581,3 +587,3 @@
       curval = nextval + 1;
-      nextval = strchr (curval, ':');
+      nextval = strchr (curval, PATH_LIST_SEPARATOR);
       if (nextval == NULL)
@@ -816,2 +822,8 @@

+#ifdef _WIN32
+#define BIN_EXT ".exe"
+#else
+#define BIN_EXT ""
+#endif
+
 static char *
@@ -827,6 +839,6 @@
   char *suffix
-    = XALLOCAVEC (char, sizeof ("/accel//mkoffload") + strlen (target));
+    = XALLOCAVEC (char, sizeof ("/accel//mkoffload" BIN_EXT) + strlen
(target));
   strcpy (suffix, "/accel/");
   strcat (suffix, target);
-  strcat (suffix, "/mkoffload");
+  strcat (suffix, "/mkoffload" BIN_EXT);

EOF
patch -ulbf gcc/config/nvptx/mkoffload.c << EOF
@@ -160,3 +160,10 @@
 /* Parse STR, saving found tokens into PVALUES and return their number.
-   Tokens are assumed to be delimited by ':'.  */
+   Tokens are assumed to be delimited by ':' (or ';' on Windows).  */
+
+#ifdef _WIN32
+#define PATH_LIST_SEPARATOR ';'
+#else
+#define PATH_LIST_SEPARATOR ':'
+#endif
+
 static unsigned
@@ -168,3 +175,3 @@

-  curval = strchr (str, ':');
+  curval = strchr (str, PATH_LIST_SEPARATOR);
   while (curval)
@@ -172,3 +179,3 @@
       num++;
-      curval = strchr (curval + 1, ':');
+      curval = strchr (curval + 1, PATH_LIST_SEPARATOR);
     }
@@ -177,3 +184,3 @@
   curval = str;
-  nextval = strchr (curval, ':');
+  nextval = strchr (curval, PATH_LIST_SEPARATOR);
   if (nextval == NULL)
@@ -188,3 +195,3 @@
       curval = nextval + 1;
-      nextval = strchr (curval, ':');
+      nextval = strchr (curval, PATH_LIST_SEPARATOR);
       if (nextval == NULL)
@@ -393,2 +400,8 @@

+#ifdef _WIN32
+#define BIN_EXT ".exe"
+#else
+#define BIN_EXT ""
+#endif
+
 int
@@ -413,3 +426,3 @@
   size_t len = (strlen (gcc_path) + 1
-               + strlen (GCC_INSTALL_NAME)
+               + strlen (GCC_INSTALL_NAME BIN_EXT)
                + 1);
@@ -425,3 +438,3 @@
     driver_used = sprintf (driver, "%s/", gcc_path);
-  sprintf (driver + driver_used, "%s", GCC_INSTALL_NAME);
+  sprintf (driver + driver_used, "%s", GCC_INSTALL_NAME BIN_EXT);

@@ -442,5 +455,5 @@
        {
-         len = strlen (paths[i]) + 1 + strlen (GCC_INSTALL_NAME) + 1;
+         len = strlen (paths[i]) + 1 + strlen (GCC_INSTALL_NAME BIN_EXT) + 1;
          driver = XRESIZEVEC (char, driver, len);
-         sprintf (driver, "%s/%s", paths[i], GCC_INSTALL_NAME);
+         sprintf (driver, "%s/%s", paths[i], GCC_INSTALL_NAME BIN_EXT);
          if (access_check (driver, X_OK) == 0)
@@ -457,3 +470,3 @@
                 "offload compiler %s not found (consider using %<-B%>)",
-                GCC_INSTALL_NAME);
+                GCC_INSTALL_NAME BIN_EXT);

EOF

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug driver/98145] gcc with nvptx offloading on Windows: lto-wrapper can't find accel/nvptx-none/mkoffload
  2020-12-04 14:39 [Bug c/98145] New: On Windows .exe extension is missing when searching/calling mkoffload brechtsanders at users dot sourceforge.net
                   ` (2 preceding siblings ...)
  2020-12-05 12:36 ` brechtsanders at users dot sourceforge.net
@ 2021-01-19 11:13 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-01-19 11:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98145

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Regarding the .exe suffix, I think TARGET_EXECUTABLE_SUFFIX should be used
(defined at the top of that file).

And PATH_SEPARATOR should already be set (configure, system.h), but I am not
completely sure it is.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-19 11:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04 14:39 [Bug c/98145] New: On Windows .exe extension is missing when searching/calling mkoffload brechtsanders at users dot sourceforge.net
2020-12-04 16:26 ` [Bug c/98145] " brechtsanders at users dot sourceforge.net
2020-12-04 22:29 ` [Bug lto/98145] gcc with nvptx offloading on Windows: lto-wrapper can't find accel/nvptx-none/mkoffload brechtsanders at users dot sourceforge.net
2020-12-05 12:36 ` brechtsanders at users dot sourceforge.net
2021-01-19 11:13 ` [Bug driver/98145] " burnus at gcc dot gnu.org

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).