This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Buildroot] [PATCH 2/2] package/gdb: use stat() privided by the system


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]