Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 766833 - sys-apps/systemd-tmpfiles-246 - ../systemd-246/src/basic/alloc-util.h:100:35: error: static declaration of 'reallocarray' follows non-static declaration (on musl)
Summary: sys-apps/systemd-tmpfiles-246 - ../systemd-246/src/basic/alloc-util.h:100:35:...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Georgy Yakovlev
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks: musl-porting
  Show dependency tree
 
Reported: 2021-01-24 11:51 UTC by ernsteiswuerfel
Modified: 2021-06-28 18:59 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (systemd-tmpfiles-246:20210124-112932.log,47.73 KB, text/plain)
2021-01-24 11:51 UTC, ernsteiswuerfel
Details
emerge --info (file_766833.txt,6.78 KB, text/plain)
2021-01-24 11:51 UTC, ernsteiswuerfel
Details
reallocarray.patch (reallocarray.patch,656 bytes, patch)
2021-02-08 11:48 UTC, ernsteiswuerfel
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ernsteiswuerfel archtester 2021-01-24 11:51:00 UTC
Created attachment 684366 [details]
build.log

[...]
FAILED: systemd-tmpfiles.standalone.p/src_tmpfiles_tmpfiles.c.o 
x86_64-gentoo-linux-musl-gcc -Isystemd-tmpfiles.standalone.p -I. -I../systemd-246 -Isrc/basic -I../systemd-246/src/basic -Isrc/boot -I../systemd-246/src/boot -Isrc/home -I../systemd-246/src/home -Isrc/shared -I../systemd-246/src/shared -Isrc/systemd -I../systemd-246/src/systemd -Isrc/journal -I../systemd-246/src/journal -Isrc/journal-remote -I../systemd-246/src/journal-remote -Isrc/nspawn -I../systemd-246/src/nspawn -Isrc/resolve -I../systemd-246/src/resolve -Isrc/timesync -I../systemd-246/src/timesync -I../systemd-246/src/time-wait-sync -Isrc/login -I../systemd-246/src/login -Isrc/udev -I../systemd-246/src/udev -Isrc/libudev -I../systemd-246/src/libudev -Isrc/core -I../systemd-246/src/core -Isrc/shutdown -I../systemd-246/src/shutdown -I../systemd-246/src/xdg-autostart-generator -I../systemd-246/src/libsystemd/sd-bus -I../systemd-246/src/libsystemd/sd-device -I../systemd-246/src/libsystemd/sd-event -I../systemd-246/src/libsystemd/sd-hwdb -I../systemd-246/src/libsystemd/sd-id128 -I../systemd-246/src/libsystemd/sd-netlink -I../systemd-246/src/libsystemd/sd-network -I../systemd-246/src/libsystemd/sd-resolve -Isrc/libsystemd-network -I../systemd-246/src/libsystemd-network -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -std=gnu99 -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Werror=undef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noreturn -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time -Wnested-externs -Wno-maybe-uninitialized -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -ffunction-sections -fdata-sections -Werror=shadow -include config.h -Os -march=x86-64 -msse3 -mtune=athlon64-sse3 -MD -MQ systemd-tmpfiles.standalone.p/src_tmpfiles_tmpfiles.c.o -MF systemd-tmpfiles.standalone.p/src_tmpfiles_tmpfiles.c.o.d -o systemd-tmpfiles.standalone.p/src_tmpfiles_tmpfiles.c.o -c ../systemd-246/src/tmpfiles/tmpfiles.c
In file included from ../systemd-246/src/tmpfiles/tmpfiles.c:21:
../systemd-246/src/basic/alloc-util.h:100:35: error: static declaration of 'reallocarray' follows non-static declaration
  100 | _alloc_(2, 3) static inline void *reallocarray(void *p, size_t need, size_t size) {
      |                                   ^~~~~~~~~~~~
In file included from ../systemd-246/src/tmpfiles/tmpfiles.c:11:
/usr/include/stdlib.h:148:7: note: previous declaration of 'reallocarray' was here
  148 | void *reallocarray (void *, size_t, size_t);
      |       ^~~~~~~~~~~~
In file included from ../systemd-246/src/basic/fileio.h:9,
                 from ../systemd-246/src/tmpfiles/tmpfiles.c:31:
/usr/include/sys/fcntl.h:1:2: warning: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Wcpp]
    1 | #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
      |  ^~~~~~~
ninja: build stopped: subcommand failed.
Comment 1 ernsteiswuerfel archtester 2021-01-24 11:51:34 UTC
Created attachment 684369 [details]
emerge --info
Comment 2 ernsteiswuerfel archtester 2021-01-24 11:53:59 UTC
Building systemd-tmpfiles-246 seems an issue since I upgraded to musl-1.2.2-r1 and re-emerged world.
Comment 3 Ionen Wolkens gentoo-dev 2021-01-24 12:04:41 UTC
I don't think it's entirely musl-specific given looks a lot like bug #764041, seems varied options/tools may trigger it.
Comment 4 ernsteiswuerfel archtester 2021-01-24 12:13:20 UTC
Hmm... interesting! I thought it was musl-specific as I hit 2 very similar issues there:
https://github.com/gentoo/musl/issues/372
https://github.com/gentoo/musl/issues/373

Posted these 2 on the musl issue tracker as they were ::musl ebuilds.
Comment 5 ernsteiswuerfel archtester 2021-01-25 23:30:36 UTC
Had a quick look on the source. musl-1.2.2 has *reallocarray defined in /usr/include/stdlib.h:

[...]
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#include <alloca.h>
char *mktemp (char *);
int mkstemps (char *, int);
int mkostemps (char *, int, int);
void *valloc (size_t);
void *memalign(size_t, size_t);
int getloadavg(double *, int);
int clearenv(void);
#define WCOREDUMP(s) ((s) & 0x80)
#define WIFCONTINUED(s) ((s) == 0xffff)
void *reallocarray (void *, size_t, size_t);
#endif
[...]

So for musl-1.2.2 .../systemd-246/src/basic/alloc-util.h defines *reallocarray via stdlib.h but afterwards tries to redefine it as a static variable:

[...]
#if !HAVE_REALLOCARRAY
_alloc_(2, 3) static inline void *reallocarray(void *p, size_t need, size_t size) {
        if (size_multiply_overflow(size, need))
                return NULL;

        return realloc(p, size * need ?: 1);
}
#endif
[...]

So at least on musl-1.2.2 it is clear why the build fails. On musl-1.2.1 no *reallocarray in stdlib.h so no problem.
Comment 6 ernsteiswuerfel archtester 2021-02-08 11:48:16 UTC
Created attachment 686037 [details, diff]
reallocarray.patch

Based on Anarchy's musl-patch for networkmanager (https://github.com/gentoo/musl/commit/424c11684631ac417069214602b73a064524898d).

Fixes build on musl-1.2.2-r1.
Comment 7 Larry the Git Cow gentoo-dev 2021-02-17 18:50:44 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fad8143675dd45c9f725c02bd94bf8fe815851e3

commit fad8143675dd45c9f725c02bd94bf8fe815851e3
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2021-02-17 18:49:11 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2021-02-17 18:49:29 +0000

    sys-apps/systemd-tmpfiles: fix build on recent musl
    
    Thanks-to: ernsteiswuerfel <erhard_f@mailbox.org>
    Closes: https://bugs.gentoo.org/766833
    Package-Manager: Portage-3.0.14, Repoman-3.0.2
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 sys-apps/systemd-tmpfiles/files/musl-1.2.2.patch      | 14 ++++++++++++++
 sys-apps/systemd-tmpfiles/systemd-tmpfiles-246.ebuild |  1 +
 2 files changed, 15 insertions(+)
Comment 8 Georgy Yakovlev gentoo-dev 2021-02-17 18:51:17 UTC
thanks!
seems to build fine, but I left patch conditional just in case, for musl systems only.
Comment 9 Jory A. Pratt gentoo-dev 2021-02-18 01:17:55 UTC
(In reply to Georgy Yakovlev from comment #8)
> thanks!
> seems to build fine, but I left patch conditional just in case, for musl
> systems only.

no need to make it conditional, it is just gonna check both headers to find the support, it will not break on glibc systems as it will find it in malloc.h
Comment 10 Georgy Yakovlev gentoo-dev 2021-06-28 18:59:44 UTC
I already have conditional block for musl, because big musl patchset significantly changes some internals and we can't apply it on glibc systems at all. so no big loss to apply extra patch conditionally.
normally I'd be against conditional patching ofc, but it's a special case.
new versions do not need that patch at all.