Skip to content

Remove -mno-cygwin from distutils #56850

Closed

Description

@jonforums
mannequin
BPO 12641
Nosy @malemburg, @loewis, @doko42, @pfmoore, @pjeby, @pitrou, @tiran, @tarekziade, @jkloth, @jwilk, @ned-deily, @merwok
Files
  • pastie-2274486
  • issue12641-modernize_cygwin&mingw_compilers.tar.gz
  • 0001-MINGW-issue12641-customize-mingw-cygwin-compilers.patch: customize compilers
  • 0001-MINGW-issue12641-check-if-cygwin-mingw-compiler-supp.patch: restore -m{no-}cygwin if supported
  • 0001-MINGW-issue12641-avoid-syntax-warning.patch
  • check_mno_cywin_py27.patch
  • check_mno_cywin_py3.patch
  • test_mno_cygwin.tar.gz
  • check_mno_cywin_py34.patch
  • check_mno_cywin_py34_1.patch
  • check_mno_cywin_py3_1.patch
  • check_mno_cywin_py27_1.patch
  • check_mno_cywin_py27_2.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/pitrou'
    closed_at = <Date 2013-09-30.20:30:31.656>
    created_at = <Date 2011-07-26.17:02:30.791>
    labels = ['type-bug', 'library']
    title = 'Remove -mno-cygwin from distutils'
    updated_at = <Date 2015-03-14.01:46:04.938>
    user = 'https://bugs.python.org/jonforums'

    bugs.python.org fields:

    activity = <Date 2015-03-14.01:46:04.938>
    actor = 'ned.deily'
    assignee = 'pitrou'
    closed = True
    closed_date = <Date 2013-09-30.20:30:31.656>
    closer = 'pitrou'
    components = ['Distutils', 'Distutils2']
    creation = <Date 2011-07-26.17:02:30.791>
    creator = 'jonforums'
    dependencies = []
    files = ['22775', '29030', '29031', '29032', '29103', '30681', '30682', '30683', '30698', '30888', '30889', '30890', '31919']
    hgrepos = []
    issue_num = 12641
    keywords = ['patch']
    message_count = 86.0
    messages = ['141172', '141173', '141230', '141231', '141265', '141271', '141277', '141296', '141301', '141613', '141614', '141661', '141662', '146384', '146499', '161514', '165178', '165181', '165182', '165184', '165210', '167620', '179175', '179176', '181830', '181831', '181834', '181865', '182090', '182277', '182726', '182737', '183032', '183048', '183077', '183081', '183213', '183224', '183227', '183240', '183241', '189748', '189756', '189769', '189770', '189786', '189805', '189813', '189814', '189871', '189874', '189878', '189887', '189906', '189941', '189943', '189946', '189947', '189948', '189958', '189962', '190060', '191714', '191735', '191749', '191753', '191755', '191845', '192758', '192763', '192764', '192766', '192877', '195576', '195809', '198650', '198690', '198691', '198732', '198733', '198734', '198763', '207498', '207499', '238062', '238067']
    nosy_count = 35.0
    nosy_names = ['lemburg', 'loewis', 'doko', 'paul.moore', 'pje', 'geertj', 'pitrou', 'christian.heimes', 'schmir', 'tarek', 'jkloth', 'jwilk', 'ned.deily', 'eric.araujo', 'rpetrov', 'cmcqueen1975', 'rubenvb', 'santoso.wijaya', 'alexis', 'python-dev', 'Seppo.Yli-Olli', 'jonforums', 'RubyTuesdayDONO', 'Jeffrey.Armstrong', 'danmbox', 'Martin.Fiers', 'oscarbenjamin', 'Pete.Forman', 'fratti', 'rivy', 'gaudyallure52', 'honorableinvasi', 'stakingrainbow2', 'lewisl', 'Michael.Clerx']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue12641'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

    Activity

    1. jonforums commented on Jul 26, 2011

      jonforumsmannequin
      MannequinAuthor

      The use of -mno-cygwin at http://bit.ly/qAIsZV causes build failures with versions of MinGW GCC. For example http://bit.ly/llK3f3

      I recently ran into it trying to build a Mercurial snapshot using a MinGW GCC v4.6.2 flavor http://pastie.org/2274486

      Why is -mno-cygwin still be used, and is there any reason why it can't be removed?

      Thanks, Jon

    2. added
      buildThe build process and cross-build
      stdlibStandard Library Python modules in the Lib/ directory
      on Jul 26, 2011
    3. rubenvb commented on Jul 26, 2011

      rubenvbmannequin
      Mannequin

      I can confirm the option has been removed. For those that don't want to believe a random person's comment on a bugtracker, here's the commit:

      http://repo.or.cz/w/official-gcc.git/commit/2637551aa9314c46cf4205d435ab5e8944e9ac8a

      The changelog is a bit cryptic, but note the last two items "removing documentation from removed option".

    4. merwok commented on Jul 27, 2011

      @merwok
      Member

      Hi! Thanks for the report. This can’t be fixed in 2.5, 2.6 or 3.1, which are in security-fix only mode, but we can do something for the active branches.

      A quick web search finds reference of this deprecation/removal as far as 2007. Does anyone have more official documentation? If we can find the first gcc version that deprecates this option, then I’ll be able to make a patch with a version check (in order not to change previously working code).

      (In the future, it would be nice of you not to use URL obfuscators or pastebins. Such services offer no guarantee of continued availability of hosted resources or links, but it is useful to keep information on this bug tracker for future reference. Thank you.

      The first link is this: http://hg.python.org/cpython/file/4feb889d3bed/Lib/distutils/cygwinccompiler.py#l296
      The second: http://stackoverflow.com/questions/6034390/compiling-with-cython-and-mingw-produces-gcc-error-unrecognized-command-line-op
      The compile log from the third link is attached as a file.)

    5. assigned and unassigned on Jul 27, 2011
    6. added
      type-bugAn unexpected behavior, bug, or error
      and removed
      buildThe build process and cross-build
      on Jul 27, 2011
    7. merwok commented on Jul 27, 2011

      @merwok
      Member

      I forgot to answer this:

      Why is -mno-cygwin still be used,
      Simply because distutils had no dedicated maintainer for a long time, and because nobody was aware of this change. I don’t think any Python core developer is using Cygwin.

      and is there any reason why it can't be removed?
      For distutils, we have to work on eggshells when fixing bugs to make sure we don’t break third-party code that relies on known bugs or works around them. That’s why I propose adding a version check* instead of just removing the option.

      • i.e. removing -mno-cygwin if self.gcc_version >= some version
    8. rubenvb commented on Jul 27, 2011

      rubenvbmannequin
      Mannequin

      Does anyone have more official documentation?

      The commit I linked to has the full option removal at October 7 2010 (see the fifth item in the changelog entry). Any GCC (major) version released after that will have it completely removed.

      Deprecation happened (according to the first doc change mentioning this option as being deprecated) on 2009-03-25: http://repo.or.cz/w/official-gcc.git/commit/6609be22531f447aeddbb3f670ad7883036cb23f

      It looks like GCC 4.4 and up have this change in them, by looking at their commit logs. Anyone using GCC 4.3 on MinGW should be shot (but that's just my humble opinion, rather radical I admit ;-) )

      Note this has really nothing to do with current Cygwin or the cygwin platform; MinGW was part of the Cygwin source for a long time, and every MinGW compiler was burdened to search the Cygwin header and lib paths. These commits fixed that problem.

      MinGW(-w64) is a native compiler for Win32 just as MSVC is. Links to msvcrt.dll and has no POSIX translation/compatibility layer like the Cygwin DLL.

      May I ask for a reconsideration to commit a fix for this for Python 2.7 at least? With the version check it doesn't hurt anyone, instead it helps prevent further confusion and support requests on the MinGW side. Distutils pop up everywhere, and the projects depending on them rely on them working correctly. Thanks

    9. jonforums commented on Jul 27, 2011

      jonforumsmannequin
      MannequinAuthor

      I have confirmed on Win7 that the following 32bit MinGW flavors still recognize -mno-cygwin option and build without error:

      (4.5.2) http://tdm-gcc.tdragon.net/download

      (4.5.4) http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds/ using the mingw-w32-1.0-bin_i686-mingw_20110624.zip download

      ...by compiling with:

      [i686-w64-mingw32-]gcc -Wall -mno-cygwin -o helloworld.exe helloworld.c

      ...where helloworld.c was:

      #include <stdio.h>
      int main(int argc, char *argv[]) { printf("Hello World!\n"); return 0; }

      I have not yet checked the latest mingw.org download from the following, but I expect that it also recognizes -mno-cygwin. I will check later and report back if appropriate.

      (4.5.2) http://sourceforge.net/projects/mingw/files/

      Given Ruben's 4.4 comment, something is odd here. Looks like some gcc source spelunking as these doc links make no mention of the removal:

      http://gcc.gnu.org/gcc-4.6/changes.html
      http://gcc.gnu.org/gcc-4.5/changes.html
      http://gcc.gnu.org/gcc-4.4/changes.html

      and the gcc manual is inconsistent. This summary mentions the option

      http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Option-Summary.html#Option-Summary

      but the details sections don't mention the option

      http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/i386-and-x86_002d64-Windows-Options.html#i386-and-x86_002d64-Windows-Options

      http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options

      Ah, our good friend grep.

    10. jonforums commented on Jul 27, 2011

      jonforumsmannequin
      MannequinAuthor

      should the question be "what's the first mingw gcc version that -mno-cygwin usage unnecessary" rather than finding the first version the option was removed?

      and, does it matter whether you're building on win for win, or cross compiling for win from nix?

      sadly, i don't know gcc internals but a post to the mingw and/or mingw-w64 ml's should get the right people weighing in.

      btw, can distutils do a lightweight configure-like check for feature presence rather than going a gcc version check?

    11. merwok commented on Jul 28, 2011

      @merwok
      Member

      May I ask for a reconsideration to commit a fix for this for Python
      2.7 at least? With the version check it doesn't hurt anyone
      There’s a misunderstanding: I explained why 2.5, 2.6 and 3.1 can’t be fixed, but if you look at the versions at the top of this page, you’ll see 2.7, 3.2 and 3.3 listed. This will get fixed in these versions.

      Ah, our good friend grep.
      Thanks for the exploration. This looks complicated.

      should the question be "what's the first mingw gcc version that
      -mno-cygwin usage unnecessary" rather than finding the first version
      the option was removed?
      If removing the option in these versions causes no change (i.e. doesn’t break any code), I agree.

      and, does it matter whether you're building on win for win, or cross
      compiling for win from nix?
      I’m afraid I don’t know enough about Windows and MinGW to answer that. If we can’t be sure about versions and consequences here, I’ll go to the MinGW ML.

      btw, can distutils do a lightweight configure-like check for feature
      presence rather than going a gcc version check?
      There is a config command that’s not very used, but it would be IMO overkill to use it in the compiler code.

    12. 77 remaining items

    13. pitrou commented on Sep 29, 2013

      @pitrou
      Member

      Oscar, thanks for the patches. Two things:

      • in the 2.7 patch, could you explicitly close the popen() file object instead of relying on deallocation to do it?
      • have you signed a contributor's agreement? http://www.python.org/psf/contrib/
    14. oscarbenjamin commented on Sep 30, 2013

      oscarbenjaminmannequin
      Mannequin

      Thanks for looking at this Antoine.

      I've attached an updated patch for Python 2.7 called
      check_mno_cywin_py27_2.patch. This explicitly closes the popen object
      in the same way as the get_versions() function immediately above.

      I've just signed an electronic contributor's agreement.

    15. oscarbenjamin commented on Sep 30, 2013

      oscarbenjaminmannequin
      Mannequin

      On 30 September 2013 12:08, Oscar Benjamin <report@bugs.python.org> wrote:

      I've attached an updated patch for Python 2.7 called
      check_mno_cywin_py27_2.patch.

      To be clear: I retested this patch (using the setup described above)
      and the results are unchanged.

    16. assigned and unassigned on Sep 30, 2013
    17. python-dev commented on Sep 30, 2013

      python-devmannequin
      Mannequin

      New changeset 7d9a1aa8d95e by Antoine Pitrou in branch '2.7':
      Issue bpo-12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except when necessary.
      http://hg.python.org/cpython/rev/7d9a1aa8d95e

    18. python-dev commented on Sep 30, 2013

      python-devmannequin
      Mannequin

      New changeset 6b89176f1be5 by Antoine Pitrou in branch '3.3':
      Issue bpo-12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except when necessary.
      http://hg.python.org/cpython/rev/6b89176f1be5

      New changeset 8e180b2067e4 by Antoine Pitrou in branch 'default':
      Issue bpo-12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except when necessary.
      http://hg.python.org/cpython/rev/8e180b2067e4

    19. pitrou commented on Sep 30, 2013

      @pitrou
      Member

      Thank you Oscar! This issue can endly be fixed.

    20. oscarbenjamin commented on Oct 1, 2013

      oscarbenjaminmannequin
      Mannequin

      Thanks Antoine!

    21. lewisl commented on Jan 7, 2014

      lewislmannequin
      Mannequin

      This is broken for Python 2.7.4. Is it fixed in 2.7.6? gcc deprecated -mno-cygwin. It's not there any more. There shouldn't be a discussion. This is an incredibly poor example of how fragmentation and poor process result in poor quality open source software--in the corners, even when the overall code is excellent. Over 2 years on something this trivial. Hundreds of lines of discussion. There wasn't really any reason for this to have persisted.

    22. pitrou commented on Jan 7, 2014

      @pitrou
      Member

      This is broken for Python 2.7.4. Is it fixed in 2.7.6?

      The fix is in 2.7.6, yes.

    23. MichaelClerx commented on Mar 14, 2015

      MichaelClerxmannequin
      Mannequin

      I'm seeing this bug in 2.7.9. The reason seems to be that the version detection doesn't work...

      This snippet:

        out = os.popen(gcc_exe + ' -dumpversion', 'r')
        out_string = out.read()

      returns an empty out_string, causing gcc_version = None < '4'

      Maybe the < '4' check could be restructured to see None as "probably modern" instead of "probably very out of date" ?

    24. ned-deily commented on Mar 14, 2015

      @ned-deily
      Member

      Michael, this issue is closed and the changes have long since been released. Comments here will likely be ignored. Please open a new issue describing the problem you are seeing and under what environment, with exact steps to reproduce it.

    25. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions