Patchwork [2/4] fix build error on ARM due to wrong glibc check

login
register
mail settings
Submitter John Spencer
Date Dec. 10, 2012, 6:59 a.m.
Message ID <1355122786-29243-2-git-send-email-maillist-qemu@barfooze.de>
Download mbox | patch
Permalink /patch/204824/
State New
Headers show

Comments

John Spencer - Dec. 10, 2012, 6:59 a.m.
the test for glibc < 2 "succeeds" wrongly for any non-glibc C library,
and breaks the build on musl libc.
we must first test if __GLIBC__ is defined at all, before using it
unconditionally.

Signed-off-by: John Spencer <maillist-qemu@barfooze.de>

---
 user-exec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Stefan Weil - Dec. 10, 2012, 5:46 p.m.
Am 10.12.2012 07:59, schrieb John Spencer:
> the test for glibc<  2 "succeeds" wrongly for any non-glibc C library,
> and breaks the build on musl libc.
> we must first test if __GLIBC__ is defined at all, before using it
> unconditionally.
>
> Signed-off-by: John Spencer<maillist-qemu@barfooze.de>
>
> ---
>   user-exec.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/user-exec.c b/user-exec.c
> index ef9b172..cccc145 100644
> --- a/user-exec.c
> +++ b/user-exec.c
> @@ -442,7 +442,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>       unsigned long pc;
>       int is_write;
>
> -#if (__GLIBC__<  2 || (__GLIBC__ == 2&&  __GLIBC_MINOR__<= 3))
> +#if defined(__GLIBC__)&&  (__GLIBC__<  2 || (__GLIBC__ == 2&&  __GLIBC_MINOR__<= 3))
>       pc = uc->uc_mcontext.gregs[R15];
>   #else
>       pc = uc->uc_mcontext.arm_pc;
>    

Reviewed-by: Stefan Weil <sw@weilnetz.de>
Stefan Hajnoczi - Dec. 18, 2012, 4:23 p.m.
On Mon, Dec 10, 2012 at 07:59:44AM +0100, John Spencer wrote:
> the test for glibc < 2 "succeeds" wrongly for any non-glibc C library,
> and breaks the build on musl libc.
> we must first test if __GLIBC__ is defined at all, before using it
> unconditionally.
> 
> Signed-off-by: John Spencer <maillist-qemu@barfooze.de>
> 
> ---
>  user-exec.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Thanks, applied Patch 2 to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan

Patch

diff --git a/user-exec.c b/user-exec.c
index ef9b172..cccc145 100644
--- a/user-exec.c
+++ b/user-exec.c
@@ -442,7 +442,7 @@  int cpu_signal_handler(int host_signum, void *pinfo,
     unsigned long pc;
     int is_write;
 
-#if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3))
+#if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3))
     pc = uc->uc_mcontext.gregs[R15];
 #else
     pc = uc->uc_mcontext.arm_pc;