Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 560492 - >=sys-apps/systemd-219_p112 failed to compile (__NR_kcmp undeclared)
Summary: >=sys-apps/systemd-219_p112 failed to compile (__NR_kcmp undeclared)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: IA64 Linux
: Normal normal (vote)
Assignee: Gentoo systemd Team
URL: http://marc.info/?l=linux-ia64&m=1442...
Whiteboard:
Keywords: REGRESSION
Depends on:
Blocks: 502144
  Show dependency tree
 
Reported: 2015-09-14 22:19 UTC by Émeric Maschino
Modified: 2021-04-08 17:55 UTC (History)
2 users (show)

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


Attachments
build.log (build.log,84.15 KB, text/x-log)
2015-09-14 22:19 UTC, Émeric Maschino
Details
environment (environment,194.86 KB, text/plain)
2015-09-14 22:20 UTC, Émeric Maschino
Details
systemd patch (0001-Add-fallback-for-kcmp-in-case-__NR_kcmp-is-undefined.patch,861 bytes, patch)
2015-09-14 23:00 UTC, Mike Gilbert
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Émeric Maschino 2015-09-14 22:19:27 UTC
Created attachment 411920 [details]
build.log

Hi,

I was asked [1] to check if =sys-apps/systemd-225 passes tests.

But it fails to emerge with compilation error:

Makefile:13316: recipe for target 'src/libsystemd/sd-bus/sd-bus.lo' failed
make[2]: *** [src/libsystemd/sd-bus/sd-bus.lo] Error 1
In file included from /var/tmp/portage/sys-apps/systemd-225/work/systemd-225/src/basic/util.h:46:0,
                 from /var/tmp/portage/sys-apps/systemd-225/work/systemd-225/src/libsystemd/sd-bus/bus-error.c:29:
/var/tmp/portage/sys-apps/systemd-225/work/systemd-225/src/basic/missing.h: In function ‘kcmp’:
/var/tmp/portage/sys-apps/systemd-225/work/systemd-225/src/basic/missing.h:1023:24: error: ‘__NR_kcmp’ undeclared (first use in this function)
/var/tmp/portage/sys-apps/systemd-225/work/systemd-225/src/basic/missing.h:1023:24: note: each undeclared identifier is reported only once for each function it appears in
Makefile:13316: recipe for target 'src/libsystemd/sd-bus/bus-error.lo' failed
make[2]: *** [src/libsystemd/sd-bus/bus-error.lo] Error 1
Makefile:17543: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
Makefile:8757: recipe for target 'all' failed
make: *** [all] Error 2

I was thus asked [2] to report this issue in a separate BR. Hence this one.

If I'm not mistaken, __NR_kcmp is defined in kernel headers. So, it seems that current ia64 stable kernel headers (=sys-kernel/linux-headers-3.18) don't define it. sys-apps/systemd thus probably misses restriction on sys-kernel/linux-headers version (which one?).

BTW, current stable ia64 kernel is =sys-kernel/gentoo-sources-4.0.5. Is it expected to have version mismatch with kernel headers (4.0.5 vs 3.18)?

     Émeric

[1] https://bugs.gentoo.org/show_bug.cgi?id=502144#c5
[2] https://bugs.gentoo.org/show_bug.cgi?id=502144#c7
Comment 1 Émeric Maschino 2015-09-14 22:20:27 UTC
Created attachment 411922 [details]
environment
Comment 2 Émeric Maschino 2015-09-14 22:21:20 UTC
emerge --info output

Portage 2.2.20.1 (python 3.4.1-final-0, default/linux/ia64/13.0/desktop/gnome/systemd, gcc-4.7.4, glibc-2.20-r2, 4.0.5-gentoo ia64)
=================================================================
System uname: Linux-4.0.5-gentoo-ia64-Madison-with-gentoo-2.2
KiB Mem:    25052544 total,  19936320 free
KiB Swap:     524224 total,    524224 free
Timestamp of repository gentoo: Mon, 14 Sep 2015 22:00:01 +0000
sh bash 4.3_p39
ld GNU ld (Gentoo 2.24 p1.4) 2.24
app-shells/bash:          4.3_p39::gentoo
dev-lang/perl:            5.20.2::gentoo
dev-lang/python:          2.7.9-r1::gentoo, 3.4.1::gentoo
dev-util/cmake:           2.8.12.2-r1::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.17::gentoo
sys-apps/sandbox:         2.6-r1::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.24-r3::gentoo
sys-devel/gcc:            4.5.4::gentoo, 4.6.4::gentoo, 4.7.4::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 3.18::gentoo (virtual/os-headers)
sys-libs/glibc:           2.20-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

my_ebuilds
    location: /var/lib/layman/my_ebuilds
    masters: gentoo
    priority: 0

ACCEPT_KEYWORDS="ia64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="ia64-unknown-linux-gnu"
CFLAGS="-O2 -pipe -mtune=itanium2"
CHOST="ia64-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -mtune=itanium2"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe -mtune=itanium2"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe -mtune=itanium2"
GENTOO_MIRRORS="ftp://mirrors.linuxant.fr/distfiles.gentoo.org/"
LANG="fr_FR.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi alsa berkdb branding bzip2 cairo cdda cdr cli colord cracklib crypt cups cxx dbus dri dts dvdr eds encode evo exif fam firefox flac fortran gdbm gif glamor gnome gnome-keyring gnome-online-accounts gpm gstreamer gtk ia64 iconv introspection ipv6 jpeg lcms ldap libnotify libsecret mad mng modules mp3 mp4 mpeg nautilus ncurses nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds pulseaudio qt3support qt4 readline sdl session spell ssl startup-notification svg systemd tcpd tiff tracker truetype udev udisks unicode upower usb vorbis wxwidgets xcb xml xv xvid zlib" ALSA_CARDS="fm801" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="fr" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby20 ruby21" USERLAND="GNU" VIDEO_CARDS="fbdev modesetting radeon" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 3 Émeric Maschino 2015-09-14 22:30:22 UTC
emerge -pqv output:

[ebuild     U ] sys-apps/systemd-225 [218-r3] USE="acl kdbus* kmod lz4 pam policykit ssl (-apparmor) -audit -cryptsetup -curl -elfutils -gcrypt -gnuefi% -http -idn -importd% -lzma -nat% -qrcode (-seccomp) (-selinux) -sysv-utils {-test} -vanilla (-xkb) (-doc%) (-gudev%*) (-introspection%*) (-python%) (-terminal%)" PYTHON_SINGLE_TARGET="(-python2_7%*) (-python3_3%) (-python3_4%)" PYTHON_TARGETS="(-python2_7%*) (-python3_3%) (-python3_4%*)"
Comment 4 Mike Gilbert gentoo-dev 2015-09-14 22:35:14 UTC
Do you also experience this failure with the latest ~ia64 kernel headers?

As of this writing, that would be sys-kernel/linux-headers-4.2.
Comment 5 Émeric Maschino 2015-09-14 22:37:38 UTC
(In reply to Mike Gilbert from comment #4)
> Do you also experience this failure with the latest ~ia64 kernel headers?
> 
> As of this writing, that would be sys-kernel/linux-headers-4.2.

I'll look at this, but if Linux Cross Reference is right, __NR_kcmp simply doesn't exist in ia64 [1].

     Émeric


[1] http://lxr.free-electrons.com/ident?i=__NR_kcmp
Comment 6 Mike Gilbert gentoo-dev 2015-09-14 22:44:20 UTC
(In reply to Émeric Maschino from comment #5)
> I'll look at this, but if Linux Cross Reference is right, __NR_kcmp simply
> doesn't exist in ia64 [1].

Right. I didn't see in arch/ia64 either, but I'm not sure if ia64 just uses the asm-generic version.
Comment 7 Émeric Maschino 2015-09-14 22:46:34 UTC
(In reply to Mike Gilbert from comment #6)
> (In reply to Émeric Maschino from comment #5)
> > I'll look at this, but if Linux Cross Reference is right, __NR_kcmp simply
> > doesn't exist in ia64 [1].
> 
> Right. I didn't see in arch/ia64 either, but I'm not sure if ia64 just uses
> the asm-generic version.

Dunno. Will thus try more recent kernel headers.

     Émeric
Comment 8 Mike Gilbert gentoo-dev 2015-09-14 23:00:01 UTC
Created attachment 411924 [details, diff]
systemd patch

Here's a patch for systemd if you would like to test it as well.
Comment 9 Émeric Maschino 2015-09-21 18:24:35 UTC
So, I've checked systemd-219_p112, 224-r1, 225 and 226: they're all failing the same, even with updated kernel headers. The problem thus probably lies in systemd source code itself. This sounds reasonable as (i) __NR_kcmp syscall is there for a very long time (since the beginning?) and (ii) looking at Linux Cross Reference [1], other architectures (including widespread x86 and x86_64) rely on generic implementation too without a problem.

I didn't have time to look at diff between systemd-218-r3 and 219_p112 yet.

    Émeric

[1] http://lxr.free-electrons.com/ident?i=__NR_kcmp
Comment 10 Émeric Maschino 2015-09-21 18:41:43 UTC
(In reply to Émeric Maschino from comment #9)
> 
> I didn't have time to look at diff between systemd-218-r3 and 219_p112 yet.

OK, the problem is now obvious: kcmp bits were introduced in systemd-219, hence the compilation error with > systemd-218:


#if !HAVE_DECL_KCMP
static inline int kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) {
        return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2);
}
#endif

#ifndef KCMP_FILE
#define KCMP_FILE 0
#endif


     Émeric

[1] https://github.com/systemd/systemd/blob/v219/src/shared/missing.h
Comment 11 Mike Gilbert gentoo-dev 2015-09-21 19:20:16 UTC
Can you please test my patch from comment 8?
Comment 12 Émeric Maschino 2015-09-21 19:48:04 UTC
(In reply to Mike Gilbert from comment #11)
> Can you please test my patch from comment 8?

I was in the process of doing so, but if I correctly understand your patch, it's "only silencing" the build failure, right?

[BTW, isn't src/shared rather than src/basic the correct path for missing.h in your patch? src-basic simply doesn't exist in my systemd repository]

Shouldn't we rather fix some missing include somewhere? How are x86 and x86_64 compiling systemd without your patch? Indeed, as ia64, these arches don't define __NR_kcmp syscall beyond the "generic" one in asm-generic/unistd.h. 

[Could it be an issue with ia64 kernel/glibc, similarly to bug #480218?]

     Émeric
Comment 13 Mike Gilbert gentoo-dev 2015-09-21 19:57:52 UTC
(In reply to Émeric Maschino from comment #12)
> (In reply to Mike Gilbert from comment #11)
> > Can you please test my patch from comment 8?
> 
> I was in the process of doing so, but if I correctly understand your patch,
> it's "only silencing" the build failure, right?

No; it defines a fallback stub function that prevents the build failure when an arch does not define __NR_kcmp.

The stub function sets errno = ENOSYS and returns -1. This causes systemd to use a different method for comparing file descriptors at run time.
Comment 14 Mike Gilbert gentoo-dev 2015-09-21 20:00:03 UTC
Adding ia64 so they can comment on the missing kcmp syscall.
Comment 15 Émeric Maschino 2015-09-21 20:18:33 UTC
(In reply to Mike Gilbert from comment #13)
> 
> No; it defines a fallback stub function that prevents the build failure when
> an arch does not define __NR_kcmp.
> 
> The stub function sets errno = ENOSYS and returns -1. This causes systemd to
> use a different method for comparing file descriptors at run time.

I don't get the point: how is it that e.g. x86 and x86_64 that don't define __NR_kcmp either can successfully compile (*) systemd without defining a stub function as in your patch?

     Émeric


(*) Well, I imagine: I don't own such hardware to test
Comment 16 Matthias Maier gentoo-dev 2015-09-21 20:28:39 UTC
> I don't get the point: how is it that e.g. x86 and x86_64 that don't define
> __NR_kcmp either

But they define __NR_kcmp:

#test jackdaw / # grep __NR_kcmp /usr/include/asm*/*
/usr/include/asm-generic/unistd.h:#define __NR_kcmp 272
/usr/include/asm-generic/unistd.h:__SYSCALL(__NR_kcmp, sys_kcmp)
/usr/include/asm/unistd_32.h:#define __NR_kcmp 349
/usr/include/asm/unistd_64.h:#define __NR_kcmp 312
/usr/include/asm/unistd_x32.h:#define __NR_kcmp (__X32_SYSCALL_BIT + 312)

and this gets included by /usr/include/sys/syscall.h
Comment 17 SpanKY gentoo-dev 2015-09-21 21:03:56 UTC
the kcmp syscall hasn't been wired up for the ia64 arch.  a patch needs to be sent upstream to lkml to make it happen.  otherwise it will continue to fail.
Comment 18 Mike Gilbert gentoo-dev 2015-09-21 21:53:16 UTC
(In reply to SpanKY from comment #17)

Thank you for confirming that.

Émeric: My patch for systemd is basically a workaround to fix the build failure until the kernel gets updated. spanky (aka. vapier) almost certainly knows more about that than I do.
Comment 19 Mike Gilbert gentoo-dev 2015-09-21 21:58:19 UTC
(In reply to Émeric Maschino from comment #12)
> [BTW, isn't src/shared rather than src/basic the correct path for missing.h
> in your patch? src-basic simply doesn't exist in my systemd repository]

The file lives in a different directory depending on the systemd version. It moved from src/shared to src/basic in systemd-221.
Comment 20 Émeric Maschino 2015-09-22 08:18:35 UTC
(In reply to Matthias Maier from comment #16)
> > I don't get the point: how is it that e.g. x86 and x86_64 that don't define
> > __NR_kcmp either
> 
> But they define __NR_kcmp:
> 
> #test jackdaw / # grep __NR_kcmp /usr/include/asm*/*
> /usr/include/asm-generic/unistd.h:#define __NR_kcmp 272
> /usr/include/asm-generic/unistd.h:__SYSCALL(__NR_kcmp, sys_kcmp)
> /usr/include/asm/unistd_32.h:#define __NR_kcmp 349
> /usr/include/asm/unistd_64.h:#define __NR_kcmp 312
> /usr/include/asm/unistd_x32.h:#define __NR_kcmp (__X32_SYSCALL_BIT + 312)
> 
> and this gets included by /usr/include/sys/syscall.h

Well, how is it that they're not listed by LXR [1]?

     Émeric


[1] http://lxr.free-electrons.com/ident?i=__NR_kcmp
Comment 21 Émeric Maschino 2015-09-22 08:21:38 UTC
(In reply to SpanKY from comment #17)
> the kcmp syscall hasn't been wired up for the ia64 arch.  a patch needs to
> be sent upstream to lkml to make it happen.  otherwise it will continue to
> fail.

OK, I'll work on this.

Besides wiring up sys_kcmp for ia64, what's also required? Patching glibc? Rebuilding glibc and/or linux-headers?

     Émeric
Comment 22 SpanKY gentoo-dev 2015-09-22 13:18:28 UTC
(In reply to Émeric Maschino from comment #20)

because many arches generate things.  x86's syscall tables:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/entry/syscalls/?id=v4.2
Comment 23 Émeric Maschino 2015-09-23 06:18:37 UTC
(In reply to SpanKY from comment #17)
> the kcmp syscall hasn't been wired up for the ia64 arch.  a patch needs to
> be sent upstream to lkml to make it happen.  otherwise it will continue to
> fail.

Patch sent: http://marc.info/?l=linux-ia64&m=144295913607910

How then update Gentoo's sys-kernel/linux-headers so that they include __NR_kcmp declaration?

     Émeric
Comment 24 Mike Gilbert gentoo-dev 2015-09-23 12:31:26 UTC
(In reply to Émeric Maschino from comment #23)
> (In reply to SpanKY from comment #17)
> > the kcmp syscall hasn't been wired up for the ia64 arch.  a patch needs to
> > be sent upstream to lkml to make it happen.  otherwise it will continue to
> > fail.
> 
> Patch sent: http://marc.info/?l=linux-ia64&m=144295913607910
> 
> How then update Gentoo's sys-kernel/linux-headers so that they include
> __NR_kcmp declaration?

We wait until the patch has been merged in Linus' tree, and he cuts a release. The linux-headers package will then get it in a normal version bump.
Comment 25 SpanKY gentoo-dev 2015-09-23 15:34:33 UTC
(In reply to Émeric Maschino from comment #23)

having it in the kernel headers only fixes the build error.  it still won't run correctly until a newer/patched kernel is used.
Comment 26 Mike Gilbert gentoo-dev 2015-09-23 18:39:24 UTC
(In reply to SpanKY from comment #25)
> (In reply to Émeric Maschino from comment #23)
> 
> having it in the kernel headers only fixes the build error.  it still won't
> run correctly until a newer/patched kernel is used.

systemd has some fallback code that uses fstat instead of kcmp if it gets ENOSYS from the kernel. So this should be "resolved" once we get newer headers.
Comment 27 Mike Gilbert gentoo-dev 2015-09-24 00:03:23 UTC
My workaround was merged upstream; if you want a backport, let me know.

https://github.com/systemd/systemd/pull/1365
Comment 28 Émeric Maschino 2015-09-24 08:12:51 UTC
(In reply to Mike Gilbert from comment #27)
> My workaround was merged upstream; if you want a backport, let me know.
> 
> https://github.com/systemd/systemd/pull/1365

Thanks.

I don't need a backport... unless Gentoo stabilizes systemd > 218 before updated stable sys-kernel/linux-headers declaring __NR_kcmp on ia64 enter the portage tree ;-)

     Émeric
Comment 29 Mike Gilbert gentoo-dev 2015-12-12 15:17:31 UTC
commit ab855566294f01bf4fedf03d1cf12035c5c4b923
Author: Mike Gilbert <floppym@gentoo.org>
Date:   Sat Dec 12 10:16:23 2015 -0500

    sys-apps/systemd: Backport build fix for IA64
    
    Bug: https://bugs.gentoo.org/560492
    
    Package-Manager: portage-2.2.26_p25

 sys-apps/systemd/files/226-kcmp.patch  | 31 +++++++++++++++++++++++++++++++
 sys-apps/systemd/systemd-226-r2.ebuild |  1 +
 2 files changed, 32 insertions(+)