linux-user: fix build error against older glibcs
cover linux-user: fix build error against older glibcs
This series fixes the following build error on older glibc versions (on my case, version 2.5-34 from RHEL-5).
LINK x86_64-linux-user/qemu-x86_64
syscall.o: In function `sys_utimensat':
/home/ehabkost/code/qemu/qemu/linux-user/syscall.c:419: undefined reference to `utimensat'
collect2: ld returned 1 exit status
make[1]: *** [qemu-x86_64] Error 1
make: *** [subdir-x86_64-linux-user] Error 2
This happens because the older glibc has most xxxat() functions available, but not utimensat(). utimensat() needs a separate test on configure.
---
Eduardo Habkost (2):
linux-user/syscall.c: define _ATFILE_SOURCE
check for utimensat() availability on configure
configure | 24 ++++++++++++++++++++++++ linux-user/syscall.c | 26 ++++++++++++++++++-------- 2 files changed, 42 insertions(+), 8 deletions(-)
Signature · 1 line
Eduardo
PATCH 1/2 linux-user/syscall.c: define _ATFILE_SOURCE
Needed to make sure the xxxat() functions are available.
--- linux-user/syscall.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
linux-user/syscall.c +1 -0
@@ -18,6 +18,7 @@* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, * MA 02110-1301, USA. */ +#define _ATFILE_SOURCE#include <stdlib.h> #include <stdio.h> #include <stdarg.h>
Signature · 1 line
1.6.3.rc4.29.g8146
PATCH 2/2 check for utimensat() availability on configure
In reply to Eduardo HabkostSome glibc versions don't have utimensat() available, but have other xxxat() functions. Make a separated check for utimensat() to make sure we can compile linux-user against some older glibc versions.
--- configure | 24 ++++++++++++++++++++++++ linux-user/syscall.c | 25 +++++++++++++++++-------- 2 files changed, 41 insertions(+), 8 deletions(-)
configure +24 -0
@@ -1254,6 +1254,27 @@ EOF fi fi +# Check for utimensat() separatedly, because some glibc versions +# have unlinkat() but not utimensat() available +utimensat=no +if [ "$linux_user" = "yes" -a "$atfile" = "yes" ] ; then + cat > $TMPC << EOF +#define _ATFILE_SOURCE +#include <sys/stat.h> +#include <fcntl.h> + +int +main(void) +{ + struct timespec times[2]; + return (utimensat(AT_FDCWD, "nonexistent_file", times, 0)); +} +EOF + if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then + utimensat=yes + fi +fi + # Check for inotify functions when we are building linux-user # emulator. This is done because older glibc versions don't # have syscall stubs for these implemented. In that case we
@@ -1673,6 +1694,9 @@ fi if test "$atfile" = "yes" ; then echo "#define CONFIG_ATFILE 1" >> $config_h fi +if test "$utimensat" = "yes" ; then + echo "#define CONFIG_UTIMENSAT 1" >> $config_h +fi if test "$inotify" = "yes" ; then echo "#define CONFIG_INOTIFY 1" >> $config_h fi
linux-user/syscall.c +17 -8
@@ -413,13 +413,6 @@ static int sys_unlinkat(int dirfd, const char *pathname, int flags) return (unlinkat(dirfd, pathname, flags)); }#endif -#ifdef TARGET_NR_utimensat -static int sys_utimensat (int dirfd,const char *pathname, -const struct timespec times[2 ],int flags) -{ -return (utimensat (dirfd, pathname, times, flags)); -} -#endif #else /* !CONFIG_ATFILE */ /*
@@ -478,12 +471,28 @@ _syscall3(int,sys_symlinkat,const char *,oldpath,#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat) _syscall3(int,sys_unlinkat,int,dirfd,const char *,pathname,int,flags)#endif + +#endif /* CONFIG_ATFILE */ + + +#ifdef CONFIG_UTIMENSAT + +#ifdef TARGET_NR_utimensat +static int sys_utimensat (int dirfd,const char *pathname, +const struct timespec times[2 ],int flags) +{ +return (utimensat (dirfd, pathname, times, flags)); +} +#endif + +#else /* !CONFIG_UTIMENSAT */ #if defined(TARGET_NR_utimensat) && defined(__NR_utimensat) _syscall4(int,sys_utimensat,int,dirfd,const char *,pathname, const struct timespec *,tsp,int,flags)#endif -#endif /* CONFIG_ATFILE */ +#endif /* CONFIG_UTIMENSAT */ +#ifdef CONFIG_INOTIFY #include <sys/inotify.h>
Signature · 1 line
1.6.3.rc4.29.g8146
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
Eduardo Habkost <[email protected]> writes:
Hi Eduardo,
Quoted 3 lines
Some glibc versions don't have
utimensat()available, but have otherxxxat()functions. Make a separated check forutimensat()to make sure we can compile linux-user against some older glibc versions.
Why didn't you take the patches available in this thread
http://lists.gnu.org/archive/html/qemu-devel/2009-04/msg01290.html ?
afaik, they can also be found in maemo's qemu git tree (and sent again later to the mailing list)
[...]
linux-user/syscall.c _syscall3(int,sys_symlinkat,const char *,oldpath, · line 485
Quoted 8 lines
linux-user/syscall.c +8
-0+#ifdef CONFIG_UTIMENSAT + +#ifdef TARGET_NR_utimensat +static int sys_utimensat (int dirfd,const char *pathname, +const struct timespec times[2 ],int flags) +{ +return (utimensat (dirfd, pathname, times, flags)); +}
As you'll see when reading the thread I mentionned, this is broken.
Regards,
Arnaud
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
Quoted 10 lines · Arnaud Patard
Eduardo Habkost <[email protected]> writes:
Hi Eduardo,
Quoted 3 lines
Some glibc versions don't have
utimensat()available, but have otherxxxat()functions. Make a separated check forutimensat()to make sure we can compile linux-user against some older glibc versions.Why didn't you take the patches available in this thread
http://lists.gnu.org/archive/html/qemu-devel/2009-04/msg01290.html ?
Because it is not included on the qemu tree.
Quoted 3 lines
afaik, they can also be found in maemo's qemu git tree (and sent again later to the mailing list)
Why is it not included, if it is a better fix?
Quoted 13 lines
[...]
linux-user/syscall.c _syscall3(int,sys_symlinkat,const char *,oldpath, · line 485
Quoted 8 lines
linux-user/syscall.c +8
-0+#ifdef CONFIG_UTIMENSAT + +#ifdef TARGET_NR_utimensat +static int sys_utimensat (int dirfd,const char *pathname, +const struct timespec times[2 ],int flags) +{ +return (utimensat (dirfd, pathname, times, flags)); +}As you'll see when reading the thread I mentionned, this is broken.
I don't see why it is broken, unless current qemu code is broken too. I just changed it to use the !CONFIG_ATFILE sys_utimensat() implementation (that was already present on the code) if glibc doesn't provide utimensat(). What do you suggest instead?
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
Eduardo Habkost <[email protected]> writes:
Hi,
Quoted 12 lines · Arnaud Patard
Quoted 10 lines
Eduardo Habkost <[email protected]> writes:
Hi Eduardo,
Quoted 3 lines
Some glibc versions don't have
utimensat()available, but have otherxxxat()functions. Make a separated check forutimensat()to make sure we can compile linux-user against some older glibc versions.Why didn't you take the patches available in this thread
http://lists.gnu.org/archive/html/qemu-devel/2009-04/msg01290.html ?
Quoted 7 lines
Because it is not included on the qemu tree.
Quoted 3 lines
afaik, they can also be found in maemo's qemu git tree (and sent again later to the mailing list)
Why is it not included, if it is a better fix?
I don't have the reason, only guesses. It looks like linux-user is getting a lot less attention than full system emulation, which makes patches living in the mailing list waiting for someone to merge them. I hope I'm wrong on that and that such fixes will be committed soon :)
Quoted 15 lines
Quoted 4 lines
[...]
Quoted 10 lines
linux-user/syscall.c _syscall3(int,sys_symlinkat,const char *,oldpath, · line 485
Quoted 8 lines
linux-user/syscall.c +8
-0+#ifdef CONFIG_UTIMENSAT + +#ifdef TARGET_NR_utimensat +static int sys_utimensat (int dirfd,const char *pathname, +const struct timespec times[2 ],int flags) +{ +return (utimensat (dirfd, pathname, times, flags)); +}As you'll see when reading the thread I mentionned, this is broken.
Quoted 2 lines
I don't see why it is broken, unless current qemu code is broken too. I
current qemu code is broken too.
Quoted 3 lines
just changed it to use the !CONFIG_ATFILE
sys_utimensat()implementation (that was already present on the code) if glibc doesn't provideutimensat(). What do you suggest instead?
glibc utimensat is not exactly the syscall, a test on some parameters has been added. There's code to handle this in the patch I was talking about.
Arnaud
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Arnaud Patard (Rtp)Quoted 8 lines · Arnaud Patard
Eduardo Habkost <[email protected]> writes:
Hi Eduardo,
Quoted 3 lines
Some glibc versions don't have
utimensat()available, but have otherxxxat()functions. Make a separated check forutimensat()to make sure we can compile linux-user against some older glibc versions.
Quoted 5 lines
Why didn't you take the patches available in this thread
http://lists.gnu.org/archive/html/qemu-devel/2009-04/msg01290.html ?afaik, they can also be found in maemo's qemu git tree (and sent again later to the mailing list)
out of curiosity, what are the kind of things that lives in that tree? What prevents it to be included in mainstream qemu?
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Eduardo HabkostQuoted 4 lines · Eduardo Habkost
Quoted 2 lines
afaik, they can also be found in maemo's qemu git tree (and sent again later to the mailing list)
Why is it not included, if it is a better fix?
because mainline qemu is lacking a linux-user maintainer.
The maemo tree's linux-user-for-upstream branch hasn't been updated either for a while, I'll do so tonight.
Quoted 6 lines
Quoted 1 line
As you'll see when reading the thread I mentionned, this is broken.
I don't see why it is broken, unless current qemu code is broken too. I just changed it to use the !CONFIG_ATFILE
sys_utimensat()implementation (that was already present on the code) if glibc doesn't provideutimensat(). What do you suggest instead?
As can be deduced from the thread, yes the current qemu code is broken.
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
Quoted 7 lines · Riku Voipio
Quoted 4 lines · Eduardo Habkost
Quoted 2 lines
afaik, they can also be found in maemo's qemu git tree (and sent again later to the mailing list)
Why is it not included, if it is a better fix?
because mainline qemu is lacking a linux-user maintainer.
I believe if you can guarantee (through proper testing) the stability of maemo tree, and poke for review the specific parts that may affect the rest ot the world, then it should be fine to just pull it.
That's what git allows for, we don't need an "official" maintainer in the commit access sense. Just a trustworthy tree we can pull from.
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
Quoted 11 lines · Glauber Costa
Quoted 7 lines · Riku Voipio
Quoted 4 lines · Eduardo Habkost
Quoted 2 lines
afaik, they can also be found in maemo's qemu git tree (and sent again later to the mailing list)
Why is it not included, if it is a better fix?
because mainline qemu is lacking a linux-user maintainer.
I believe if you can guarantee (through proper testing) the stability of maemo tree, and poke for review the specific parts that may affect the rest ot the world, then it should be fine to just pull it.
At least, this would be better than what we have currently. Please note also that "proper testing" is hard imho. It depends also on host/guest systems used to test.
Quoted 3 lines
That's what git allows for, we don't need an "official" maintainer in the commit access sense. Just a trustworthy tree we can pull from.
Having an "official" maintainer means having someone being able to give his final word if people disagree on how to fix a bug.
Arnaud
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
Quoted 9 lines · Arnaud Patard
Quoted 7 lines · Glauber Costa
Quoted 6 lines · Riku Voipio
Quoted 4 lines · Eduardo Habkost
Quoted 2 lines
afaik, they can also be found in maemo's qemu git tree (and sent again later to the mailing list)
Why is it not included, if it is a better fix?
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
because mainline qemu is lacking a linux-user maintainer.
I believe if you can guarantee (through proper testing) the stability of maemo tree, and poke for review the specific parts that may affect the rest ot the world, then it should be fine to just pull it.
At least, this would be better than what we have currently. Please note also that "proper testing" is hard imho. It depends also on host/guest systems used to test.
it is hard for everybody, not just qemu user. Since you guys are the main user of it, if you are happy with the state of things, and it is isolated enough from the rest of qemu not to break it very frequently, we should be fine.
Quoted 7 lines
Quoted 4 lines
That's what git allows for, we don't need an "official" maintainer in the commit access sense. Just a trustworthy tree we can pull from.
Having an "official" maintainer means having someone being able to give his final word if people disagree on how to fix a bug.
One of you should step up and do it.
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Arnaud Patard (Rtp)Excerpts from Arnaud Patard (Rtp)'s message of Wed Jun 10 11:39:25 -0300 2009:
Quoted 1 line
Eduardo Habkost <[email protected]> writes:
<snip>
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
afaik, they can also be found in maemo's qemu git tree (and sent again later to the mailing list)
Why is it not included, if it is a better fix?
I don't have the reason, only guesses. It looks like linux-user is getting a lot less attention than full system emulation, which makes patches living in the mailing list waiting for someone to merge them. I hope I'm wrong on that and that such fixes will be committed soon :)
I hope so. :)
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
[...]
linux-user/syscall.c _syscall3(int,sys_symlinkat,const char *,oldpath, · line 485
Quoted 8 lines
linux-user/syscall.c +8
-0+#ifdef CONFIG_UTIMENSAT + +#ifdef TARGET_NR_utimensat +static int sys_utimensat (int dirfd,const char *pathname, +const struct timespec times[2 ],int flags) +{ +return (utimensat (dirfd, pathname, times, flags)); +}As you'll see when reading the thread I mentionned, this is broken.
Quoted 4 lines
Quoted 2 lines
I don't see why it is broken, unless current qemu code is broken too. I
current qemu code is broken too.
Now this makes sense.
Quoted 8 lines
Quoted 4 lines
just changed it to use the !CONFIG_ATFILE
sys_utimensat()implementation (that was already present on the code) if glibc doesn't provideutimensat(). What do you suggest instead?glibc utimensat is not exactly the syscall, a test on some parameters has been added. There's code to handle this in the patch I was talking about.
Understood. However, my patch addresses a different issue, that is the case where the host system doesn't have utimensat() available. The point here is to disable the code that uses utimensat() (be it broken or not) on that case.
And the first patch is unrelated to that question: it is just a correctness issue to make sure the xxxat() availability matches the situation detected by ./configure (whose test code has #define _ATFILE_SOURCE).
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
Quoted 9 lines · Eduardo Habkost
Quoted 3 lines
glibc utimensat is not exactly the syscall, a test on some parameters has been added. There's code to handle this in the patch I was talking about.
Understood. However, my patch addresses a different issue, that is the case where the host system doesn't have
utimensat()available. The point here is to disable the code that usesutimensat()(be it broken or not) on that case.
Quoted 4 lines
And the first patch is unrelated to that question: it is just a correctness issue to make sure the
xxxat()availability matches the situation detected by ./configure (whose test code has #define_ATFILE_SOURCE).
You mean like this, in the same thread? :)
http://lists.gnu.org/archive/html/qemu-devel/2009-04/msg01324.html
However your other patch was useful, _ATFILE_SOURCE should be used in syscall.c to. thanks, applied to the maemo tree.
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Glauber CostaQuoted 6 lines · Glauber Costa
Quoted 2 lines · Arnaud Patard
afaik, they can also be found in maemo's qemu git tree (and sent again later to the mailing list)
out of curiosity, what are the kind of things that lives in that tree? What prevents it to be included in mainstream qemu?
This is the linux-user stuff just refreshed:
https://git.maemo.org/projects/qemu/gitweb?p=qemu;a=shortlog;h=refs/heads/linux-user-for-upstream
The master branch includes other stuff, such as omap3/beagleboard emulation and some scratchbox hacks unwanted for upstream.
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Glauber CostaQuoted 5 lines · Glauber Costa
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
because mainline qemu is lacking a linux-user maintainer.
I believe if you can guarantee (through proper testing) the stability of maemo tree, and poke for review the specific parts that may affect the rest ot the world, then it should be fine to just pull it.
Quoted 7 lines
Quoted 3 lines
At least, this would be better than what we have currently. Please note also that "proper testing" is hard imho. It depends also on host/guest systems used to test.
it is hard for everybody, not just qemu user. Since you guys are the main user of it, if you are happy with the state of things, and it is isolated enough from the rest of qemu not to break it very frequently, we should be fine.
Generally we use tests from ltp testsuite since they have nice tests for most syscalls. However, the testing is not quite systematic, an particularry combinations of host/target glibc appear to create a mess..
That said, the changes are highly contained under linux-user/, in the current tree there is only one patch (GUEST_BASE support) that touches outside parts.
Quoted 4 lines
Quoted 2 lines
Having an "official" maintainer means having someone being able to give his final word if people disagree on how to fix a bug.
One of you should step up and do it.
If nobody objects, I can.
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Riku VoipioExcerpts from Riku Voipio's message of Wed Jun 10 18:48:26 -0300 2009:
Quoted 10 lines · Eduardo Habkost
Quoted 8 lines
Quoted 3 lines
glibc utimensat is not exactly the syscall, a test on some parameters has been added. There's code to handle this in the patch I was talking about.
Understood. However, my patch addresses a different issue, that is the case where the host system doesn't have
utimensat()available. The point here is to disable the code that usesutimensat()(be it broken or not) on that case.
Quoted 8 lines
Quoted 4 lines
And the first patch is unrelated to that question: it is just a correctness issue to make sure the
xxxat()availability matches the situation detected by ./configure (whose test code has #define_ATFILE_SOURCE).You mean like this, in the same thread? :)
http://lists.gnu.org/archive/html/qemu-devel/2009-04/msg01324.html
Yes. :)
I saw the futimens() part, but I didn't see it was adding a new configure test including utimensat(), on the first look.
Quoted 4 lines
However your other patch was useful,
_ATFILE_SOURCEshould be used insyscall.cto.
thanks, applied to the maemo tree.
Cool. :)
Now, we really need to get the fixes from the maemo tree merged on the master repository. How much have the trees diverged?
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Riku VoipioRiku Voipio <[email protected]> writes:
Hi,
Quoted 10 lines · Glauber Costa
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
because mainline qemu is lacking a linux-user maintainer.
I believe if you can guarantee (through proper testing) the stability of maemo tree, and poke for review the specific parts that may affect the rest ot the world, then it should be fine to just pull it.
At least, this would be better than what we have currently. Please note also that "proper testing" is hard imho. It depends also on host/guest systems used to test.
Quoted 7 lines
Quoted 3 lines
it is hard for everybody, not just qemu user. Since you guys are the main user of it, if you are happy with the state of things, and it is isolated enough from the rest of qemu not to break it very frequently, we should be fine.
Generally we use tests from ltp testsuite since they have nice tests for most syscalls. However, the testing is not quite systematic, an particularry combinations of host/target glibc appear to create a mess..
Do you have a list of the syscalls/ltp testcases you're testing ? I've made a list, only wants to compare :)
Quoted 10 lines
That said, the changes are highly contained under linux-user/, in the current tree there is only one patch (
GUEST_BASEsupport) that touches outside parts.Quoted 4 lines
Quoted 2 lines
Having an "official" maintainer means having someone being able to give his final word if people disagree on how to fix a bug.
One of you should step up and do it.
If nobody objects, I can.
I bet you have more time than me to work on qemu so that's fine. Nevertheless, I can provide help if needed.
Arnaud
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Riku Voipiohi,
Quoted 10 lines
That said, the changes are highly contained under linux-user/, in the current tree there is only one patch (
GUEST_BASEsupport) that touches outside parts.Quoted 4 lines
Quoted 2 lines
Having an "official" maintainer means having someone being able to give his final word if people disagree on how to fix a bug.
One of you should step up and do it.
If nobody objects, I can.
yes ,that i fine.
Thanks & Regards
vibi sreenivasan
Quoted 4 lines
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Arnaud Patard (Rtp)Quoted 6 lines
Quoted 3 lines
Generally we use tests from ltp testsuite since they have nice tests for most syscalls. However, the testing is not quite systematic, an particularry combinations of host/target glibc appear to create a mess..
Do you have a list of the syscalls/ltp testcases you're testing ? I've made a list, only wants to compare :)
The ltp tests realated syscalls being added/modified in a patch. As said, there is no systematic "these tests must get through" list used at the moment. perhaps we can use your list as starters?
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Eduardo HabkostQuoted 4 lines · Eduardo Habkost
Cool. :)
Now, we really need to get the fixes from the maemo tree merged on the master repository. How much have the trees diverged?
The trees haven't really diverged, there is little development happening in mainline linux-user/ code. The only problem I got when rebasing yesterday was that microblaze port was added and the coredump support adding patch broke building microblaze. Thus coredump patch needed slight adjusting.
ltp vs linux-user (was: Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure)
In reply to Riku VoipioRiku Voipio <[email protected]> writes:
Hi,
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
Generally we use tests from ltp testsuite since they have nice tests for most syscalls. However, the testing is not quite systematic, an particularry combinations of host/target glibc appear to create a mess..
Do you have a list of the syscalls/ltp testcases you're testing ? I've made a list, only wants to compare :)
The ltp tests realated syscalls being added/modified in a patch. As said, there is no systematic "these tests must get through" list used at the moment. perhaps we can use your list as starters?
Here is my list of syscalls tested. It's the same list as in runtest/syscalls with the following tests disabled :
- clone*
- msgctl07
- profil101
- syslog*
- times03
- waitpid*
I've disabled them because they were blocking except for syslog ones. The syslog ones were disabled because I didn't have any syslog daemon in my chroot. I didn't look at the other tests but this can be due to emulation bug or host bug. I need to run the same tests on the host to be able to detect what's really due to qemu emulation. (Please note that I was testing arm-linux-user on x86 host. I hope to I'll find some time to do more tests).
Arnaud
Re: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure
In reply to Riku VoipioQuoted 7 lines
Quoted 5 lines
Quoted 3 lines
Having an "official" maintainer means having someone being able to give his final word if people disagree on how to fix a bug.
One of you should step up and do it.
If nobody objects, I can.
please inform(CC) this to current maintainers & to the authors of file you are going to maintain.
Thanks & Regards
vibi sreenivasan