Skip to content

[Compiler] Cygwin is identified by os(Cygwin) instead of os(Windows) #2351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

tinysun212
Copy link
Contributor

@tinysun212 tinysun212 commented Apr 30, 2016

Since MinGW, Cygwin and MSVC are definitely vary greatly in ABI and C language
level behavior, it is neccessary to distinguish each other in Swift. (In target
name, MSVC is x86_64-*-windows-msvc, Cygwin is x86_64-*-windows-cygnus)

Before change, os(Windows) was for *-*-windows-*, and now,
os(Cygwin) is for *-*-windows-cygnus, and os(Windows) is for the rest.

@gribozavr
Copy link
Contributor

@swift-ci Please test and merge

@@ -103,8 +103,7 @@ public var errno : Int32 {
get {
#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) || os(FreeBSD)
return __error().pointee
//FIXME: os(Windows) should be replaced, such as triple(Cygwin)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't pollute the meaning of "os". Cygwin is not an operating system.

Perhaps compiler() or even triple() as originally suggested in this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a discussion about using os(Cygwin) or introducing new condition env(). I agree that Cygwin is not OS nor OS emulator, but I think using os() is practically not bad for the present.

https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20160425/001853.html
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160425/015852.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with doing that "for the present" is that you break user applications if you fix it later, and then you never fix it to avoid breaking user applications, and you're stuck with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakepetroules, You have a point there. Is it will be OK if we introduce the new env() and that exactly defined by the EnvironmentType of the LLVM tripple? Or, do you have any other name and definition to suggest?

I think we need more opinions. (CC: @jckarter, @rjmccall)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think env() would make more sense.

On the other hand, LLVM does identify Android as an "environment" rather than an "OS" but I can understand that from a compiler/ABI perspective.

At least for Cygwin, using env() rather than os() is a lot more sensible. Otherwise you'd see #if os(Windows) || os(Cygwin) appearing all over the place unnecessarily.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to move to swift-evolution. Is it sufficient simply sending a mail to swift-evolution@swift.org including all participants as CC?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would recommend sending an email to swift-evolution with a subject like "#if os(Windows) and MSVC / Cygwin Compatibility". It should link to this thread and then briefly summarize it. CC'ing everybody here is a good idea, too.

For anybody to comes to this PR from swift-evolution: please keep the conceptual discussion on the mailing list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that github does not expose the email address.
@jakepetroules, @ephemer, Could you give me your address to continue this discussion in swift-evolution?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just put my email address on my profile. Spam filters are good enough these days. :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mine is an @gmail.com address starting with geojay

@tinysun212
Copy link
Contributor Author

Could anybody tell me what this test is?

ERROR: test_lldbmi_break_insert_function_pending (tools/lldb-mi/breakpoint/TestMiBreak.py)

@jckarter
Copy link
Contributor

jckarter commented May 2, 2016

cc @egranata for the lldb error.

@egranata
Copy link
Contributor

egranata commented May 2, 2016

Actually, cc @tfiala - I don't maintain the build system

@tfiala
Copy link
Contributor

tfiala commented May 3, 2016

Actually, cc @tfiala - I don't maintain the build system

@egranata, I think you mean the test system? He was asking about a test failing.

From the console output for the failed build, we see this:

======================================================================
ERROR: test_lldbmi_break_insert_function_pending (TestMiBreak.MiBreakTestCase)
   Test that 'lldb-mi --interpreter' works for pending function breakpoints.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildnode/jenkins/workspace/swift-PR-Linux/lldb/packages/Python/lldbsuite/test/decorators.py", line 329, in wrapper
    func(*args, **kwargs)
  File "/home/buildnode/jenkins/workspace/swift-PR-Linux/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py", line 39, in test_lldbmi_break_insert_function_pending
    self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
  File "/home/buildnode/jenkins/workspace/swift-PR-Linux/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py", line 54, in expect
    return self.child.expect(pattern, *args, **kwargs)
  File "/home/buildnode/jenkins/workspace/swift-PR-Linux/lldb/third_party/Python/module/pexpect-2.4/pexpect.py", line 1316, in expect
    return self.expect_list(compiled_pattern_list, timeout, searchwindowsize)
  File "/home/buildnode/jenkins/workspace/swift-PR-Linux/lldb/third_party/Python/module/pexpect-2.4/pexpect.py", line 1330, in expect_list
    return self.expect_loop(searcher_re(pattern_list), timeout, searchwindowsize)
  File "/home/buildnode/jenkins/workspace/swift-PR-Linux/lldb/third_party/Python/module/pexpect-2.4/pexpect.py", line 1414, in expect_loop
    raise TIMEOUT (str(e) + '\n' + str(self))
TIMEOUT: Timeout exceeded in read_nonblocking().
<pexpect.spawn object at 0x7f40c4f9f1d0>
version: 2.4 ($Revision: 516 $)
command: /home/buildnode/jenkins/workspace/swift-PR-Linux/buildbot_linux/lldb-linux-x86_64/bin/lldb-mi
args: ['/home/buildnode/jenkins/workspace/swift-PR-Linux/buildbot_linux/lldb-linux-x86_64/bin/lldb-mi', '--interpreter']
searcher: searcher_re:
    0: re.compile("=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="(?!0xffffffffffffffff)0x[0-9a-f]+",func=".+?",file=".+?",fullname=".+?",line="(-1|\d+)",pending=\["printf"\],times="0",original-location="printf"}")
buffer (last 100 chars): "_IO_printf",args=[],file="??",fullname="??",line="-1"},thread-id="1",stopped-threads="all"
(gdb)

before (last 100 chars): "_IO_printf",args=[],file="??",fullname="??",line="-1"},thread-id="1",stopped-threads="all"
(gdb)

after: <class 'pexpect.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 16528
child_fd: 5
closed: False
timeout: 30
delimiter: <class 'pexpect.EOF'>
logfile: None
logfile_read: <open file 'child.log', mode 'w' at 0x7f40c4f8e300>
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
Config=x86_64-/home/buildnode/jenkins/workspace/swift-PR-Linux/buildbot_linux/llvm-linux-x86_64/bin/clang-3.9
----------------------------------------------------------------------

It failed twice in the same spot, so this test is behaving as if test expectations are no longer being met.

The file lives in LLDB's repo (swift-lldb) at:
packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py

The lldb-mi tests are actually all written up at LLVM.org LLDB. I'm not sure who is maintaining those these days, but pinging lldb-dev@llvm.org is probably a good place to start.

You can run the test by hand after doing a build that includes lldb, you'd want to do this:

{path-to-lldb-source}/test/dotest.py --executable /path/to/your/just-built/lldb --no-multiprocess -v -p TestMiBreak.py

(You can add 'python' before that if needed, and use python 2.x rather than python 3.x).

Since MinGW, Cygwin and MSVC are definitely vary greatly in ABI and C language
level behavior, it is neccessary to distinguish each other in Swift. (In target
name, MSVC is x86_64-*-windows-msvc, Cygwin is x86_64-*-windows-cygnus)

Before change, os(Windows) was *-*-windows-*, and now,
os(Cygwin) is for *-*-windows-cygnus, and os(Windows) is for the rest.
@tinysun212
Copy link
Contributor Author

I rebased this PR. Many part was duplicated with #3886, so I removed the stdlib part.
See the hiden conversation for stdlib/public/Platform/Platform.swift. In fact, it is related to the lib/Basic/LangOptions.cpp.
I know the discussion in swift-evolution was not concluded to use this macro. But I think it is worthwhile to keep this patch.

@CodaFi CodaFi added the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Aug 14, 2016
@slavapestov slavapestov self-assigned this Jan 17, 2017
@slavapestov
Copy link
Contributor

@CodaFi What was the outcome of the swift-evolution discussion?

@CodaFi
Copy link
Contributor

CodaFi commented Jan 22, 2017

My impression was the opposite from @tinysun212's back in August. @lattner made an excellent point about their distinctness, and Jordan's (modulo concerns about overlap) that this wouldn't really hurt things and could always be reclassified if we discover a better taxonomy for these things in the future.

We could bring this up one more time to get fresh opinions.

@CodaFi
Copy link
Contributor

CodaFi commented Jan 22, 2017

Also, to answer the question on prior art: DLang considers this (and MinGW and Windows) as separate platform conditionals (environments, technically, but their static condition system doesn't make a syntactic distinction).

@CodaFi
Copy link
Contributor

CodaFi commented Jun 29, 2017

Subsumed by the merge of #10359

Thank you for holding out so long @tinysun212

@CodaFi CodaFi closed this Jun 29, 2017
@AnthonyLatsis AnthonyLatsis removed the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.