Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 425006 - sys-libs/uclibc: SYS_utime is defined for EABI targets when __NR_utime does not exist
Summary: sys-libs/uclibc: SYS_utime is defined for EABI targets when __NR_utime does n...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Sandbox (show other bugs)
Hardware: ARM Linux
: Normal minor (vote)
Assignee: Embedded Gentoo Team
URL:
Whiteboard:
Keywords:
: 427816 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-07-06 03:40 UTC by Kiichiro
Modified: 2013-01-28 11:52 UTC (History)
2 users (show)

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


Attachments
generated trace_syscalls.h (trace_syscalls.h,2.31 KB, text/plain)
2012-07-06 03:42 UTC, Kiichiro
Details
build.log (build.log,16.16 KB, text/plain)
2012-07-06 03:43 UTC, Kiichiro
Details
Remove utime syscall tracing in sandbox (sandbox-2.6-arm-sys-utime.patch,1.39 KB, patch)
2012-12-03 19:10 UTC, Anthony Basile
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kiichiro 2012-07-06 03:40:46 UTC
In cross compiler sandbox-2.5 fail to build with error "./trace_syscalls.h:64:1: error: '__NR_utime' undeclared here (not in a function)".

But "unistd.h" have "__NR_utime" define

find /usr/armv6z-rpi-linux-uclibceabi/usr/include/ -exec grep -i -H -n "__NR_utime" "{}" \;
/usr/armv6z-rpi-linux-uclibceabi/usr/include/asm/unistd.h:58:#define __NR_utime                 (__NR_SYSCALL_BASE+ 30)


Reproducible: Always

Steps to Reproduce:
1. export EXTRA_ECONF="--with-cpu=arm1176jzf-s --with-float=hard --with-abi=aapcs-linux"
export UCLIBC_CPU="ARM1176JZF_S"
export UCLIBC_EXTRA_CFLAGS="-marm -mcpu=arm1176jzf-s"

2. crossdev -t armv6z-rpi-linux-uclibceabi -S

3. rm /usr/armv6z-rpi-linux-uclibceabi/etc/make.profile
ln -s /usr/portage/profiles/default/linux/arm/10.0 /usr/armv6z-rpi-linux-uclibceabi/etc/make.profile

4. PORTAGE_CONFIGROOT=/usr/armv6z-rpi-linux-uclibceabi armv6z-rpi-linux-uclibceabi-emerge -av1 sandbox

Actual Results:  
in "./trace_syscalls.h" everything calls generated correctly expect the "SB_SYS_UTIME".


Expected Results:  
in "trace_syscalls.h" must be "#define SB_SYS_UTIME (0 + 30)" instead of "#define SB_SYS_UTIME __NR_utime"


Portage 2.1.10.49 (default/linux/arm/10.0, gcc-4.5.3, unavailable, 3.4.4-2-ARCH x86_64)
=================================================================
System uname: Linux-3.4.4-2-ARCH-x86_64-Intel-R-_Core-TM-_i5-2500_CPU_@_3.30GHz-with-gentoo-2.1
Timestamp of tree: Fri, 06 Jul 2012 01:45:01 +0000
app-shells/bash:          4.2_p20
dev-lang/python:          2.7.3-r2, 3.2.3
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.9.8.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.68
sys-devel/automake:       1.11.1
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.5.3-r2
sys-devel/gcc-config:     1.6
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 3.1 (virtual/os-headers)
sys-libs/glibc:           2.14.1-r3
Repositories: gentoo x-portage
ACCEPT_KEYWORDS="arm"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-Os -pipe -mabi=aapcs-linux -mfloat-abi=hard -mcpu=arm1176jzf-s -I/usr/armv6z-rpi-linux-uclibceabi/usr/include/ -I/usr/armv6z-rpi-linux-uclibceabi/include/"
CHOST="armv6z-rpi-linux-uclibceabi"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CTARGET="armv6z-rpi-linux-uclibceabi"
CXXFLAGS="-Os -pipe -mabi=aapcs-linux -mfloat-abi=hard -mcpu=arm1176jzf-s -I/usr/armv6z-rpi-linux-uclibceabi/usr/include/ -I/usr/armv6z-rpi-linux-uclibceabi/include/"
DISTDIR="/var/cache/distfiles"
FCFLAGS="-O2"
FEATURES="assume-digests binpkg-logs buildpkg distlocks ebuild-locks fixlafiles news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS="-O2"
GENTOO_MIRRORS="http://mirror.yandex.ru/gentoo-distfiles/"
LANG="ru_RU.UTF-8"
LDFLAGS="-L/usr/armv6z-rpi-linux-uclibceabi/lib -L/usr/armv6z-rpi-linux-uclibceabi/usr/lib"
LINGUAS="en ru"
MAKEOPTS="-j5"
PKGDIR="/usr/armv6z-rpi-linux-uclibceabi/packages/"
PORTAGE_CONFIGROOT="/usr/armv6z-rpi-linux-uclibceabi/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/usr/armv6z-rpi-linux-uclibceabi/tmp/"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync2.ru.gentoo.org/gentoo-portage"
USE="acl arm berkdb bzip2 cli cracklib crypt cups cxx fortran gdbm gpm iconv ipv6 modules mudflap ncurses nptl openmp pam pcre pppd readline session ssl tcpd unicode xorg zlib" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="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" 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 ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en ru" PHP_TARGETS="php5-3" PYTHON_TARGETS="python2_7" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="fbdev omapfb dummy v4l" 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:  CPPFLAGS, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 Kiichiro 2012-07-06 03:42:58 UTC
Created attachment 317384 [details]
generated trace_syscalls.h
Comment 2 Kiichiro 2012-07-06 03:43:37 UTC
Created attachment 317386 [details]
build.log
Comment 3 SpanKY gentoo-dev 2012-07-24 15:28:15 UTC
*** Bug 427816 has been marked as a duplicate of this bug. ***
Comment 4 Anthony Basile gentoo-dev 2012-12-03 19:09:45 UTC
This bug has bugged me long enough!  I keep hitting it during a catalyst build of  arm uclibc.  Here's what's going on.  In bits/sysnum.h (included by sys/syscalls.h) there are a few syscalls which are not implemented.  They are "defined" as follows:

#define __NR_time __NR_time
#define __NR_umount __NR_umount
#define __NR_stime __NR_stime
#define __NR_alarm __NR_alarm
#define __NR_utime __NR_utime
#define __NR_getrlimit __NR_getrlimit
#define __NR_select __NR_select
#define __NR_readdir __NR_readdir
#define __NR_mmap __NR_mmap
#define __NR_socketcall __NR_socketcall
#define __NR_syscall __NR_syscall
#define __NR_ipc __NR_ipc

Compare this to the usual, eg SYS_write:

#define __NR_write (0 + 4)

Of these "undefined defines", only __NR_utime is in sandbox's libsandbox/symbols.h.in and gets brought into the build via scripts/gen_trace_header.awk, etc. When building, this leads to the undeclared in trace_syscalls.h

The easiest thing to do is just patch all utime stuff out.  The better thing would be to implement utime in arm-uclibc.  You could probably just take this out of glibc, but I haven't looked.

I'll attach the "lazy" patch in my next post.
Comment 5 Anthony Basile gentoo-dev 2012-12-03 19:10:26 UTC
Created attachment 331338 [details, diff]
Remove utime syscall tracing in sandbox
Comment 6 Anthony Basile gentoo-dev 2012-12-03 19:13:52 UTC
(In reply to comment #3)
> *** Bug 427816 has been marked as a duplicate of this bug. ***

Oh wow, I just looked at the dup and I already did this like 5 months ago but have no recollection of having opened that bug!

Sorry for the spam.
Comment 7 SpanKY gentoo-dev 2012-12-11 03:01:59 UTC
(In reply to comment #4)

i think you misunderstand the syscall stuff.  the C library can't "implement" syscalls that the kernel omits.

the issue is that uClibc is defining SYS_xxx stuff that it shouldn't.  in this case, there is no __NR_utime, but it is still exporting SYS_utime.

simple workaround:
  sed -i '/SYS_utime __NR_utime$/d' /usr/include/bits/sysnum.h
Comment 8 Anthony Basile gentoo-dev 2012-12-11 17:14:16 UTC
(In reply to comment #7)
> (In reply to comment #4)
> 
> i think you misunderstand the syscall stuff.  the C library can't
> "implement" syscalls that the kernel omits.
> 
> the issue is that uClibc is defining SYS_xxx stuff that it shouldn't.  in
> this case, there is no __NR_utime, but it is still exporting SYS_utime.
> 
> simple workaround:
>   sed -i '/SYS_utime __NR_utime$/d' /usr/include/bits/sysnum.h

When I wrote that I forgot arm eabi dropped utime and thought the kernel provided it but uclibc just didn't have the syscall wrapper (like dup3 recently), or that it was a stub or something.

There clearly is something wrong because `readelf -s /lib/libc.so.0  | grep utime` gives

   217: 00010c5c    56 FUNC    GLOBAL DEFAULT    8 utime
   749: 000119a8   152 FUNC    GLOBAL DEFAULT    8 lutimes
   949: 00013264    52 FUNC    GLOBAL DEFAULT    8 utimes
  1001: 0001147c    52 FUNC    GLOBAL DEFAULT    8 utimensat
  1009: 000120f0    52 FUNC    GLOBAL DEFAULT    8 futimesat
  1243: 000130d4    16 FUNC    GLOBAL DEFAULT    8 futimens

which is why gen_symbol_header.awk spits it into symbols.h.  Let me see if I can figure out why uclibc is exporting utime().
Comment 9 SpanKY gentoo-dev 2012-12-11 23:12:42 UTC
(In reply to comment #8)

the ABI provided by the C library is not restricted by the ABI provided by the kernel.  as an example, with newer ports, the kernel only provides the *at style funcs.  so openat, fstatat, etc...  but uClibc still must provide the full API as dictated by POSIX.  so it implements open() by calling openat(), stat() by calling fstatat(), etc...

utime() is part of POSIX, thus uClibc provides it:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/utime.html

the kernel ABI has no such restrictions -- it merely needs to provide enough so that some userland ABI can fully implement POSIX.
Comment 10 Anthony Basile gentoo-dev 2012-12-12 11:43:55 UTC
(In reply to comment #9)
> (In reply to comment #8)
> 
> the ABI provided by the C library is not restricted by the ABI provided by
> the kernel.  as an example, with newer ports, the kernel only provides the
> *at style funcs.  so openat, fstatat, etc...  but uClibc still must provide
> the full API as dictated by POSIX.  so it implements open() by calling
> openat(), stat() by calling fstatat(), etc...
> 
> utime() is part of POSIX, thus uClibc provides it:
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/utime.html
> 
> the kernel ABI has no such restrictions -- it merely needs to provide enough
> so that some userland ABI can fully implement POSIX.

ligh bulb goes off!  so what if we provide utime by calling utimes, which is there.  we have to convert a struct utimbuf to a struct timeval which seems like the only hard part, and make sure the return value and errno are properly set.
Comment 11 SpanKY gentoo-dev 2012-12-13 06:53:39 UTC
(In reply to comment #10)

i'm not sure if you were asking a question, but in case you were, sandbox has to wrap utime() (both at the C and kernel level if it exists) since it modifies things via pathname.  we can't wrap just utimes().

as a short term fix, the trace logic can probably be refactored slightly so that we don't even include trace_syscalls.h when SB_NO_TRACE_OS is defined (which it currently is for arm targets).  that won't help though when i get around to implementing the arm/ptrace layer ...
Comment 12 SpanKY gentoo-dev 2013-01-26 19:07:26 UTC
looks like it happens to a bunch of syscalls:
#define __NR_time __NR_time
#define __NR_umount __NR_umount
#define __NR_stime __NR_stime
#define __NR_alarm __NR_alarm
#define __NR_utime __NR_utime
#define __NR_getrlimit __NR_getrlimit
#define __NR_select __NR_select
#define __NR_readdir __NR_readdir
#define __NR_mmap __NR_mmap
#define __NR_socketcall __NR_socketcall
#define __NR_syscall __NR_syscall
#define __NR_ipc __NR_ipc
Comment 13 SpanKY gentoo-dev 2013-01-26 19:19:05 UTC
should be all set now in the tree; thanks for the report!

Commit message: Add fix from upstream for cleaning up undefined syscalls.
http://sources.gentoo.org/sys-libs/uclibc/uclibc-0.9.33.2-r3.ebuild?r1=1.1&r2=1.2
Comment 14 Anthony Basile gentoo-dev 2013-01-28 11:52:34 UTC
(In reply to comment #13)
> should be all set now in the tree; thanks for the report!
> 
> Commit message: Add fix from upstream for cleaning up undefined syscalls.
> http://sources.gentoo.org/sys-libs/uclibc/uclibc-0.9.33.2-r3.ebuild?r1=1.
> 1&r2=1.2

Thanks I'll be testing this soon as I do another catalyst round of arm-uclibc images.  (Which I'm crunching on the sambsung arm chromebook that someone told me about :)  I'm pushing those images to the tree under /experimental/arm/uclibc.