public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: <sten.kristian.ivarsson@gmail.com>
To: "'Ken Brown'" <kbrown@cornell.edu>, <moss@cs.umass.edu>,
	"'Jonathan Yong'" <10walls@gmail.com>,
	"'The Cygwin Mailing List'" <cygwin@cygwin.com>
Subject: Sv: Sv: Sv: Sv: Sv: Sv: g++ and c++17 filesystem
Date: Wed, 25 Nov 2020 09:30:48 +0100	[thread overview]
Message-ID: <002001d6c305$475e8d40$d61ba7c0$@gmail.com> (raw)
In-Reply-To: <11a20f55-46db-c9b4-1f30-d2181a3aeb9e@cornell.edu>

Thanx for the insightful thoughts Ken

See more below

> >>> all the std::filesystem implementations I've seen for Windows
> >>
> >> The implementation on top of Cygwin is not "for Windows", it's "for
> >> Cygwin", i.e., "for Posix".  And for Cygwin that's the right thing to
> do.
> >> And that's where we keep talking at cross purposes.
> >
> >
> > Maybe it is the right thing to do, but what is your take of why it must
> be so (all the way) ?
> >
> > I also do understand that it have several advantages in the
> > implementation of std::filesystem but it also imply an extra layer of
> > abstraction to the underlaying platform, but to just remove the
> > _CYGWIN_ macro when building it would make std::filesystem to not
> > understand /cygdrive at all (and I guess that would confuse other
> > users;-) so I guess it would require some more sophisticated
> > implementation (or extend the number of exceptions already existing in
> > the underlaying Cygwin-Posix-implementation)
> 
> I'd like to try to make this discussion more concrete by looking at what's
> actually going on in the test program main.cpp that you posted at the
> beginning of that thread.  (I ran it under strace and gdb to see this for
> myself.)
> 
> First, your program calls std::filesystem::exists, which ultimately calls
> stat(2) in the Cygwin DLL.  The work for this is done in the
> path_conv::check function and various functions that it calls.  These
> functions have code that recognizes Win32 paths like C:\Temp, and
> std::filesystem::exists therefore reports "true".  This is consistent with
> the statement at
> https://cygwin.com/cygwin-ug-net/using.html#pathnames-win32 about how the
> Cygwin DLL treats Win32 paths.
> 
> Next, your program calls std::filesystem::canonical.  This calls
> std::filesystem::absolute, which reports that C:\Temp is not an absolute
> path.
> It therefore tries to treat it as a relative path and fails with "No such
> file or directory" because <current directory>/C:\Temp does not exist.
> Note that the Cygwin DLL never sees the original path C:\Temp in this
> case.  Again, this is consistent with the statement in the documentation
> that Cygwin applications do not necessarily recognize Win32 paths.
> 
> You say this is a bug, because first you're told that C:\Temp exists and
> then you're told it doesn't.  But I think it just illustrates the hazards
> of using
> Win32 paths in Cygwin, which tries hard to emulate Posix.  Sometimes you
> can get away with using Win32 paths and sometimes you can't, depending on
> how and when the Cygwin DLL is involved.

Well, to call it a bug in this context was maybe wrong, but in a
ISO-standard perspective it would be considered a bug ;-)

> I don't see a good way to avoid this inconsistency.  We could change
> Cygwin so that it rigidly recognizes only Posix paths.  Cygwin would then
> be consistent, but we would be removing a feature that many users have
> become accustomed to

I guess so too, but they are already there for some reason

I don't expect that the posix-functions should accept any non-posix-paths
but it would be nice to have the platform independent std::filesystem to
work transparently but I guess, since the cygstdc++-library uses the
underlaying posix-functions the only reasonable way to accomplish this is to
extend the list of features that already exists

The sole reason for std::filesystem was to avoid platform dependent code

So I guess in practical, it is up to the community of how well motivated
they are to extend those Posix-functions but my take in this thread is that
many rather would like it to become more ... like an emulator 

> And it wouldn't help you.  Or we could ask all Cygwin package maintainers
> to try to patch their packages so that they recognize Win32 paths, but
> that's simply not feasible, nor would many package maintainers be willing
> to invest the required time.

I'm not sure what package maintainers you're referring to here now ?
Applications ? Cygwin ? GCC ?

> I tried it once with emacs, which I maintain, in response to a user
> request.  I failed miserably.  Every change I made broke something else,
> and I finally gave up.
> 
> I don't think g++ will be any easier than emacs, and I don't think you can
> expect the g++ maintainer to work on this.

Yeah, I noticed that the _CYGWIN_ macro actually was a part of the real
libstdc++-distro

Thanx Ken and keep up the good work

Kristian

> Ken


  parent reply	other threads:[~2020-11-25  8:30 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17 15:15 sten.kristian.ivarsson
2020-11-17 16:45 ` René Berber
2020-11-18  9:00   ` Sv: " sten.kristian.ivarsson
2020-11-18 16:24     ` René Berber
2020-11-18 16:31       ` Eliot Moss
2020-11-18 20:46       ` Kristian Ivarsson
2020-11-18 20:56         ` Eliot Moss
2020-11-18 21:18           ` Kristian Ivarsson
2020-11-18 23:47             ` Eliot Moss
2020-11-19  8:10               ` Sv: " sten.kristian.ivarsson
2020-11-18 21:45         ` Norton Allen
2020-11-19  0:08         ` Doug Henderson
2020-11-19  6:23           ` Brian Inglis
2020-11-19 10:03         ` Sv: " sten.kristian.ivarsson
2020-11-19 15:27           ` Brian Inglis
2020-11-20  9:37             ` Sv: " sten.kristian.ivarsson
2020-11-20 15:29               ` Brian Inglis
2020-11-20 16:11                 ` Sv: " sten.kristian.ivarsson
2020-11-19 15:36           ` Eliot Moss
2020-11-20  8:31             ` Sv: " sten.kristian.ivarsson
2020-11-20 18:28               ` Jonathan Yong
     [not found]                 ` <000601d6c173$aa55d540$ff017fc0$@gmail.com>
2020-11-23 11:09                   ` Sv: " Jonathan Yong
2020-11-24  9:32                     ` Sv: " sten.kristian.ivarsson
2020-11-24 10:24                       ` Jonathan Yong
2020-11-24 11:35                         ` Sv: " sten.kristian.ivarsson
2020-11-24 12:33                           ` Jonathan Yong
2020-11-24 14:01                             ` Sv: " sten.kristian.ivarsson
2020-11-25  2:25                               ` Jonathan Yong
2020-11-24 13:22                       ` Eliot Moss
2020-11-24 14:31                         ` Sv: " sten.kristian.ivarsson
2020-11-24 20:06                           ` Ken Brown
2020-11-24 20:39                             ` Eliot Moss
2020-11-25  8:02                               ` Sv: " sten.kristian.ivarsson
2020-11-25  8:30                             ` sten.kristian.ivarsson [this message]
2020-11-25  0:23                           ` Brian Inglis
2020-11-25  9:00                             ` Sv: " sten.kristian.ivarsson

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='002001d6c305$475e8d40$d61ba7c0$@gmail.com' \
    --to=sten.kristian.ivarsson@gmail.com \
    --cc=10walls@gmail.com \
    --cc=cygwin@cygwin.com \
    --cc=kbrown@cornell.edu \
    --cc=moss@cs.umass.edu \
    /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).