Skip to content

Build error when cross-compiling: implicit declaration of function 'memrchr' #23528

@someplaceguy

Description

@someplaceguy

Module:

Description

When cross-compiling to a different architecture with the musl libc, building the perl 5.40.0 interpreter fails with:

op.c: In function 'Perl_newATTRSUB_x':
perl.h:2399:25: error: implicit declaration of function 'memrchr'; did you mean 'memchr'? [-Wimplicit-function-declaration]
 2399 | #    define my_memrchr  memrchr
      |                         ^~~~~~~
op.c:10752:34: note: in expansion of macro 'my_memrchr'
10752 |         const char *s = (char *) my_memrchr(name, ':', namlen);
      |                                  ^~~~~~~~~~
op.c:10752:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
10752 |         const char *s = (char *) my_memrchr(name, ':', namlen);

This seems related to #16807. It appears that that issue has not been fixed completely, at least not when cross-compiling to a different architecture.
The build does appear to succeed when building against musl on the same architecture, though.

Steps to Reproduce

Install Nix on an x64-64 machine and do:

nix-build '<nixpkgs>' -A pkgsCross.aarch64-multiplatform-musl.perl

Alternatively, install Nix on an aarch64 machine and do:

nix-build '<nixpkgs>' -A pkgsCross.musl64.perl

Expected behavior

I expected the build to succeed.

Perl version

5.40.0

Full build log

perl-build-log.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions