From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.137]) by sourceware.org (Postfix) with ESMTPS id 34C5B384385B for ; Fri, 5 Mar 2021 18:58:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 34C5B384385B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=SystematicSw.ab.ca Authentication-Results: sourceware.org; spf=none smtp.mailfrom=brian.inglis@systematicsw.ab.ca Received: from [192.168.1.104] ([68.147.0.90]) by shaw.ca with ESMTP id IFf3lE2FmnRGtIFf4l3Yez; Fri, 05 Mar 2021 11:58:54 -0700 X-Authority-Analysis: v=2.4 cv=cagXElPM c=1 sm=1 tr=0 ts=60427f6e a=T+ovY1NZ+FAi/xYICV7Bgg==:117 a=T+ovY1NZ+FAi/xYICV7Bgg==:17 a=IkcTkHD0fZMA:10 a=uYT-Tk0qkVT609LjNaIA:9 a=QEXdDO2ut3YA:10 Reply-To: cygwin@cygwin.com To: cygwin@cygwin.com References: <6eded5d3-93f3-7c98-5055-ee5ac2566bc8@gmail.com> From: Brian Inglis Organization: Systematic Software Subject: Re: stack grow direction wrongly detected Message-ID: Date: Fri, 5 Mar 2021 11:58:53 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <6eded5d3-93f3-7c98-5055-ee5ac2566bc8@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-CA Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfPdtX2aeyQOiBZTe8fsOM5V3oxZ11cdM6ZtigTMA9g2KlnqpIIlZi88wPCCNcYLJRY7lA5lcgsrsfLC1i5k91mD3lZs8NufqkHnSbODrAclEi75ldruj 7FvvBZpaGiae5wSVK2StKmvnA+Sg9OBfIwhhcWHdtd2o5SiL9QRr2GLMinL6dA8Hn2xhZiIP0JMSBo9+p1x/kbrLGTtxLqZSJFo= X-Spam-Status: No, score=2.7 required=5.0 tests=BAYES_00, BODY_8BITS, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Mar 2021 18:58:56 -0000 On 2021-03-05 05:18, Marco Atzeri via Cygwin wrote: > Hi Guys, > noted trying to rebuild guile 1.8.8. > > The following piece of code in the past > was setting SCM_I_GSC_STACK_GROWS_UP=0 > and now produces SCM_I_GSC_STACK_GROWS_UP=1 > > I assume some change in the gcc compiler is causing the issue. > I presume most of the programs and libraries do not care, > but some special one like guile crashes during build for this issue, > so be aware. > > Regards > Marco > > > #-------------------------------------------------------------------- > # > # Which way does the stack grow? > # > # Following code comes from Autoconf 2.61's internal _AC_LIBOBJ_ALLOCA > # macro (/usr/share/autoconf/autoconf/functions.m4).  Gnulib has > # very similar code, so in future we could look at using that. > # > # An important detail is that the code involves find_stack_direction > # calling _itself_ - which means that find_stack_direction (or at > # least the second find_stack_direction() call) cannot be inlined. > # If the code could be inlined, that might cause the test to give > # an incorrect answer. > #-------------------------------------------------------------------- > > SCM_I_GSC_STACK_GROWS_UP=0 > AC_RUN_IFELSE([AC_LANG_SOURCE( > [AC_INCLUDES_DEFAULT > int > find_stack_direction () > { >   static char *addr = 0; >   auto char dummy; >   if (addr == 0) >     { >       addr = &dummy; >       return find_stack_direction (); >     } >   else >     return (&dummy > addr) ? 1 : -1; > } > > int > main () > { >   return find_stack_direction () < 0; > }])], >                [SCM_I_GSC_STACK_GROWS_UP=1], >                [], >                [AC_MSG_WARN(Guessing that stack grows down -- see scmconfig.h)]) Report it upstream to guile and [better] autoconf for correction - suggest a patch or not as you feel appropriate. It's an issue that the code does not assume --push and pop++ as that is the common implementation -- then do adequate due diligence to inhibit optimizations that avoid stack usage, eliminate tail recursion, and generate inline code, to prove the opposite. Some implementations (used to?) not natively support or use stacks and emulated them with dynamically allocated memory blocks. I am surprised that this has not occurred previously, and wonder if someone recently replaced, eliminated, or "optimized" code, or some necessary settings, that allow such autoconf tests to do their jobs properly. We all love the advantage such transformations provide our code at large compile time and space costs, but most are unaware of the effort that detection code like the above now has to go thru to avoid being rendered useless. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. [Data in binary units and prefixes, physical quantities in SI.]