From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41463 invoked by alias); 11 Sep 2018 10:13:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 41451 invoked by uid 89); 11 Sep 2018 10:13:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=no version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Sep 2018 10:13:51 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFD59400C3C0; Tue, 11 Sep 2018 10:13:49 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1EE01102E31; Tue, 11 Sep 2018 10:13:46 +0000 (UTC) Subject: Re: [Buildroot] [PATCH 2/2] package/gdb: use stat() privided by the system To: Sergio Durigan Junior , Rich Felker References: <20180909163750.14196-1-romain.naour@gmail.com> <20180909163750.14196-2-romain.naour@gmail.com> <20180910174900.0b9f4133@windsurf> <20180910224128.GT1878@brightrain.aerifal.cx> <87lg88oolv.fsf@redhat.com> Cc: Romain Naour , Thomas Petazzoni , Romain Naour , buildroot@buildroot.org, gdb-patches@sourceware.org From: Pedro Alves Message-ID: <1b73e625-c2bf-31e1-daee-61baad348ec2@redhat.com> Date: Tue, 11 Sep 2018 10:13:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <87lg88oolv.fsf@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-09/txt/msg00316.txt.bz2 On 09/11/2018 01:38 AM, Sergio Durigan Junior wrote: > I'm thinking here that this is similar to a problem we had recently, > which existed when cross-compiling GDB. Basically, in this scenario, > gnulib's mechanism to detect cross-compilation was poor and lead to the > unneeded replacement of 'getcwd' in some systems that did have a working > 'getcwd', and that was causing problems when running the cross GDB. > The > bug is here: > > https://sourceware.org/bugzilla/show_bug.cgi?id=23558 > > and the fix was to improve gnulib's machinery and make it a bit smarter > when detecting cross-compilation scenarios. Just to add a bit more color here: for some cases, gnulib needs to be able to run things on the target in order to detect whether the function being checked needs replacement: ./m4/getcwd-abort-bug.m4: AC_RUN_IFELSE( ./m4/getcwd.m4: [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ ./m4/getcwd-path-max.m4: AC_RUN_IFELSE( If you're cross compiling, then obviously you can't run things on the target. So all you can do, is take a guess, and if you don't know anything about the system, the best is to take a conservative guess of "needs fixing/replacing". The gnulib fix pointed out is simply adding a few targets to a whitelist of systems that don't need the fix/replacement, so that when cross compiling for those systems, gnulib doesn't take the default conservative approach. Seems like the stat checks in gnulib also rely on running code, and thus this could indeed be a similar case: ./m4/fstatat.m4: [AC_RUN_IFELSE( ./m4/lstat.m4: AC_RUN_IFELSE( ./m4/stat.m4: AC_RUN_IFELSE( Though from a quick peek, if the target triplet include "linux" or "gnu", it should guess OK: [case "$host_os" in # Guess yes on Linux systems. linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;; # Guess yes on glibc systems. *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_stat_file_slash="guessing no" ;; esac So there might well be some other reason gnulib determines that stat must be replaced on musl. The ideal would be if no replacement were necessary at all. Thanks, Pedro Alves