public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug driver/108350] New: Windows: invoking gcc via symlink does not work
@ 2023-01-10  9:47 gnu.org at billz dot fastmail.fm
  2023-01-10 10:40 ` [Bug driver/108350] " i.nixman at autistici dot org
                   ` (37 more replies)
  0 siblings, 38 replies; 39+ messages in thread
From: gnu.org at billz dot fastmail.fm @ 2023-01-10  9:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108350
           Summary: Windows: invoking gcc via symlink does not work
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gnu.org at billz dot fastmail.fm
  Target Milestone: ---

PROBLEM

On Windows if I invoke gcc via a symlink, then it is unable to work. This
appears to happen because it computes the wrong prefix.

The steps to reproduce are:

- Install mingw gcc from https://github.com/niXman/mingw-builds

- Open a powershell prompt.

- Execute: `cmd /c mklink gcc.exe <GCC-INSTALL-PATH>\gcc.exe`. This command
creates a symlink on Windows, which requires Administrator or Developer mode to
be enabled.

- Execute: `ni a.c`. This command creates an empty file `a.c`.

- Execute: `.\gcc.exe a.c`. This command fails with "fatal error: cannot
execute 'cc1': CreateProcess: No such file or directory".

- Execute: `.\gcc.exe -print-search-dirs`. This command prints directories
relative to the location of the symlink, rather than the gcc installation path.

The expected behavior is for `gcc` to work regardless of whether it is invoked
via a symlink or not, because I did not supply the `-no-canonical-prefixes`
option.

This problem was originally reported against the mingw-builds repository, but
investigation showed that the problem is likely with gcc.


INVESTIGATION

Investigation showed that gcc prefixes are handled in `process_command`
(gcc/gcc.cc). When the `-no-canonical-prefixes` option is not supplied prefix
resolution happens in `make_relative_prefix` (libiberty/make-relative-prefix.c)
which calls `lrealpath` (libiberty/lrealpath.c).

On Windows `lrealpath` calls `GetFullPathName` which unfortunately does *not*
do symlink resolution.


FIX

The most straightforward fix is to change `lrealpath` to use
`GetFinalPathNameByHandle` instead of `GetFullPathName`.


For the original issue report and an alternative view of this issue please see
here: https://github.com/niXman/mingw-builds/issues/633

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

end of thread, other threads:[~2023-02-11  8:51 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10  9:47 [Bug driver/108350] New: Windows: invoking gcc via symlink does not work gnu.org at billz dot fastmail.fm
2023-01-10 10:40 ` [Bug driver/108350] " i.nixman at autistici dot org
2023-01-10 12:27 ` gnu.org at billz dot fastmail.fm
2023-01-10 12:29 ` i.nixman at autistici dot org
2023-01-10 12:37 ` i.nixman at autistici dot org
2023-01-10 13:20 ` gnu.org at billz dot fastmail.fm
2023-01-10 13:22 ` i.nixman at autistici dot org
2023-01-10 13:25 ` gnu.org at billz dot fastmail.fm
2023-01-10 13:49 ` i.nixman at autistici dot org
2023-01-10 14:54 ` gnu.org at billz dot fastmail.fm
2023-01-10 18:57 ` i.nixman at autistici dot org
2023-01-10 20:52 ` i.nixman at autistici dot org
2023-01-10 21:31 ` gnu.org at billz dot fastmail.fm
2023-01-12 19:24 ` i.nixman at autistici dot org
2023-01-13 10:28 ` gnu.org at billz dot fastmail.fm
2023-01-13 10:32 ` i.nixman at autistici dot org
2023-01-13 10:34 ` i.nixman at autistici dot org
2023-01-13 10:43 ` gnu.org at billz dot fastmail.fm
2023-01-13 10:43 ` gnu.org at billz dot fastmail.fm
2023-01-13 11:04 ` gnu.org at billz dot fastmail.fm
2023-01-13 11:19 ` gnu.org at billz dot fastmail.fm
2023-01-16  8:51 ` i.nixman at autistici dot org
2023-01-16 13:42 ` gnu.org at billz dot fastmail.fm
2023-01-16 13:52 ` i.nixman at autistici dot org
2023-01-16 14:22 ` i.nixman at autistici dot org
2023-01-16 17:07 ` i.nixman at autistici dot org
2023-01-16 17:27 ` gnu.org at billz dot fastmail.fm
2023-01-16 17:30 ` i.nixman at autistici dot org
2023-01-16 18:08 ` i.nixman at autistici dot org
2023-01-16 19:31 ` i.nixman at autistici dot org
2023-01-18 19:58 ` gnu.org at billz dot fastmail.fm
2023-01-18 20:08 ` gnu.org at billz dot fastmail.fm
2023-01-18 20:24 ` i.nixman at autistici dot org
2023-01-23 11:44 ` gnu.org at billz dot fastmail.fm
2023-01-23 11:50 ` i.nixman at autistici dot org
2023-01-23 11:51 ` i.nixman at autistici dot org
2023-01-24  0:02 ` gnu.org at billz dot fastmail.fm
2023-02-11  8:36 ` 10walls at gmail dot com
2023-02-11  8:51 ` gerald at pfeifer dot com

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