[MacPorts] #61784: pv is broken in Apple Silicon

MacPorts noreply at macports.org
Wed Jan 27 11:12:55 UTC 2021


#61784: pv is broken in Apple Silicon
----------------------+-------------------------------------
  Reporter:  hpux735  |      Owner:  eborisch
      Type:  defect   |     Status:  assigned
  Priority:  Normal   |  Milestone:
 Component:  ports    |    Version:  2.6.4
Resolution:           |   Keywords:  bigsur, arm64, upstream
      Port:  pv       |
----------------------+-------------------------------------

Comment (by mhberger):

 I have done a bit of digging and have come up with something, but not
 necessarily the ideal soluton.

 Basically autoconf takes `autoconf/configure.in` and creates `configure`,
 which
 then tests for availability of certain functions and then creates
 `#defines`
 indicating availability of certain functions.

 e.g. the autoconf function `AC_CHECK_FUNCS(stat64)` generates bash code
 in configure which tests for availability of stat64 and if function
 is available writes `#define HAVE_STAT64 1`.

 This code does this by creating a C program and then compiles, links and
 runs it.

 This C program does not check for the presence of the symbol at compile
 time,
 but only at link time. See the code sample below. Changing all occurrences
 of
 `stat64` to `joe` and the compiling using `gcc -S sample.c` works. However
 `gcc sample.c -o sample` will fail with a linking error.

 On the systems tested, `stat64` is defined as a symbol in

 {{{
 xxd /usr/lib/dyld | grep stat64
 }}}

 So the test always return true.

 On the Intel Mac, compiling code generates deprecation warnings, but still
 compiles and runs.

 On the Silicon Mac, compiling generates a compile warning.

 The code in the pv include `ifndef HAVE_STAT64` does not actually
 evaluate to true, so the redefinition of `stat64` to `stat` does not
 happen
 here. Instead it is being catered for in one of the Apple libraries, but
 generates deprecation warnings.

 However, this compile definition is now not working on the Silicon Mac.

 So we have to explicitly add a test in for this i.e. `# if __arm64__`.

 == Test code generated by configure
 {{{
 /* confdefs.h */
 #define PACKAGE_NAME ""
 #define PACKAGE_TARNAME ""
 #define PACKAGE_VERSION ""
 #define PACKAGE_STRING ""
 #define PACKAGE_BUGREPORT ""
 #define PACKAGE_URL ""
 /* end confdefs.h.  */
 /* Define stat64 to an innocuous variant, in case <limits.h> declares
 stat64.
    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
 #define stat64 innocuous_stat64

 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char stat64 (); below.
     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
     <limits.h> exists even on freestanding compilers.  */

 #ifdef __STDC__
 # include <limits.h>
 #else
 # include <assert.h>
 #endif

 #undef stat64

 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
 #ifdef __cplusplus
 extern "C"
 #endif
 char stat64 ();
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined __stub_stat64 || defined __stub___stat64
 choke me
 #endif

 int
 main ()
 {
 return stat64 ();
   ;
   return 0;
 }
 }}}

-- 
Ticket URL: <https://trac.macports.org/ticket/61784#comment:4>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list