Closed Bug 1612025 Opened 4 years ago Closed 4 years ago

Build failure with musl libc -- error: use of undeclared identifier '__NR_pread'

Categories

(Toolkit :: Crash Reporting, defect)

72 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: mforney, Assigned: mforney)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0

Steps to reproduce:

Attempt to build firefox with musl libc.

Actual results:

A build error occurred:

In file included from /src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/common/linux/elfutils.cc:30:
In file included from /src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/common/linux/elfutils.h:40:
In file included from /src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/common/memory_allocator.h:50:
/src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h:4340:7: error: use of undeclared identifier '__NR_pread'
      LSS_BODY(4, ssize_t, pread64, LSS_SYSCALL_ARG(f), LSS_SYSCALL_ARG(b),
      ^
/src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h:2237:7: note: expanded from macro 'LSS_BODY'
      _LSS_BODY(nr, type, name, uintptr_t, ## args)
      ^
/src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h:2232:20: note: expanded from macro '_LSS_BODY'
            : "0" (__NR_##name) LSS_BODY_ARG##nr(__VA_ARGS__)                 \
                   ^
<scratch space>:187:1: note: expanded from here
__NR_pread
^
In file included from /src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/common/linux/elfutils.cc:30:
In file included from /src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/common/linux/elfutils.h:40:
In file included from /src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/common/memory_allocator.h:50:
/src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h:4346:7: error: use of undeclared identifier '__NR_pwrite'
      LSS_BODY(4, ssize_t, pwrite64, LSS_SYSCALL_ARG(f), LSS_SYSCALL_ARG(b),
      ^
/src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h:2237:7: note: expanded from macro 'LSS_BODY'
      _LSS_BODY(nr, type, name, uintptr_t, ## args)
      ^
/src/pkgsrc/www/firefox/work/firefox-72.0.2/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h:2232:20: note: expanded from macro '_LSS_BODY'
            : "0" (__NR_##name) LSS_BODY_ARG##nr(__VA_ARGS__)                 \
                   ^
<scratch space>:192:1: note: expanded from here
__NR_pwrite
^
2 errors generated.

This is because musl defines the LFS64 functions pread64 and pwrite64 to pread and pwrite respectively, since its off_t is always 64-bit. This causes unintended macro replacement of pread64 and pwrite64 during expansion of the LSS_NAME and LSS_BODY macros when defining the sys_pread64 and sys_pwrite64 wrapper functions.

This issue was reported and fixed upstream in linux-syscall-support:
https://chromium.googlesource.com/linux-syscall-support/+/f70e2f1641e280e777edfdad7f73a2cfa38139c7%5E%21/

Expected results:

The build should have completed successfully.

musl libc defines these to pread and pwrite respectively, since its
off_t is always 64-bit. This causes unintended macro replacement
when defining the pread64/pwrite64 wrappers.

To prevent this, save the macro definitions at the start of the
header and restore them at the end. This is what is already done
to work around the same issue on Android NDK.

This is a cherry-pick of the following upstream change:
https://chromium.googlesource.com/linux-syscall-support/+/f70e2f1641e280e777edfdad7f73a2cfa38139c7%5E%21/

This change was also applied to google-breakpad here:
https://chromium.googlesource.com/breakpad/breakpad/+/647158232ba153d33c984f201b0ee35384e684cc%5E%21/

Assignee: nobody → mforney
Status: UNCONFIRMED → ASSIGNED
Component: General → Crash Reporting
Ever confirmed: true
Product: Core → Toolkit
Pushed by gsvelto@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/660da1ec99c0
Avoid conflict with pread64/pwrite64 defined by libc r=gsvelto
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.