[PATCH v3] build/ac-macros/macosx.m4: workaround AC_RUN_IFELSE

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH v3] build/ac-macros/macosx.m4: workaround AC_RUN_IFELSE

Fabrice Fontaine
[[[
Patch by: Fabrice Fontaine

The SVN_LIB_MACHO_ITERATE macro contains an AC_RUN_IFELSE test that
will raise the following build failure when cross-compiling:

checking for Mach-O dynamic module iteration functions... configure: error: in `/home/fabrice/buildroot/output/build/subversion-1.14.0':
configure: error: cannot run test program while cross compiling

To avoid this build failure, set the action-if-cross-compiling of
AC_RUN_IFELSE to a pessimistic value (no).
Moreover, encapsulate this call with AC_CACHE_CHECK as suggested by
Thomas Petazzoni to allow the user to override this value when
cross-compiling for macosx target.

Inspired by: Thomas Petazzoni
(See https://git.buildroot.net/buildroot/tree/package/subversion/0002-workaround-ac-run-ifelse.patch?h=2020.08-rc3)
]]]

Signed-off-by: Fabrice Fontaine <[hidden email]>
---
 build/ac-macros/macosx.m4 | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/build/ac-macros/macosx.m4 b/build/ac-macros/macosx.m4
index 92fa58e0bc..b131379e83 100644
--- a/build/ac-macros/macosx.m4
+++ b/build/ac-macros/macosx.m4
@@ -23,22 +23,25 @@ dnl SVN_LIB_MACHO_ITERATE
 dnl Check for _dyld_image_name and _dyld_image_header availability
 AC_DEFUN(SVN_LIB_MACHO_ITERATE,
 [
-  AC_MSG_CHECKING([for Mach-O dynamic module iteration functions])
-  AC_RUN_IFELSE([AC_LANG_PROGRAM([[
-    #include <mach-o/dyld.h>
-    #include <mach-o/loader.h>
-  ]],[[
-    const struct mach_header *header = _dyld_get_image_header(0);
-    const char *name = _dyld_get_image_name(0);
-    if (name && header) return 0;
-    return 1;
-  ]])],[
+  AC_CACHE_CHECK([for Mach-O dynamic module iteration functions],
+    [ac_cv_mach_o_dynamic_module_iteration_works], [
+    AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+      #include <mach-o/dyld.h>
+      #include <mach-o/loader.h>
+    ]],[[
+      const struct mach_header *header = _dyld_get_image_header(0);
+      const char *name = _dyld_get_image_name(0);
+      if (name && header) return 0;
+      return 1;
+    ]])],
+    [ac_cv_mach_o_dynamic_module_iteration_works=yes],
+    [ac_cv_mach_o_dynamic_module_iteration_works=no],
+    [ac_cv_mach_o_dynamic_module_iteration_works=no])
+  ])
+  if test "$ac_cv_mach_o_dynamic_module_iteration_works" = yes; then
     AC_DEFINE([SVN_HAVE_MACHO_ITERATE], [1],
               [Is Mach-O low-level _dyld API available?])
-    AC_MSG_RESULT([yes])
-  ],[
-    AC_MSG_RESULT([no])
-  ])
+  fi
 ])
 
 dnl SVN_LIB_MACOS_PLIST
--
2.28.0

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v3] build/ac-macros/macosx.m4: workaround AC_RUN_IFELSE

Nathan Hartman
On Fri, Sep 4, 2020 at 7:16 PM Fabrice Fontaine
<[hidden email]> wrote:

>
> [[[
> Patch by: Fabrice Fontaine
>
> The SVN_LIB_MACHO_ITERATE macro contains an AC_RUN_IFELSE test that
> will raise the following build failure when cross-compiling:
>
> checking for Mach-O dynamic module iteration functions... configure: error: in `/home/fabrice/buildroot/output/build/subversion-1.14.0':
> configure: error: cannot run test program while cross compiling
>
> To avoid this build failure, set the action-if-cross-compiling of
> AC_RUN_IFELSE to a pessimistic value (no).
> Moreover, encapsulate this call with AC_CACHE_CHECK as suggested by
> Thomas Petazzoni to allow the user to override this value when
> cross-compiling for macosx target.
>
> Inspired by: Thomas Petazzoni
> (See https://git.buildroot.net/buildroot/tree/package/subversion/0002-workaround-ac-run-ifelse.patch?h=2020.08-rc3)
> ]]]
>
> Signed-off-by: Fabrice Fontaine <[hidden email]>
> ---
>  build/ac-macros/macosx.m4 | 31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/build/ac-macros/macosx.m4 b/build/ac-macros/macosx.m4
> index 92fa58e0bc..b131379e83 100644
> --- a/build/ac-macros/macosx.m4
> +++ b/build/ac-macros/macosx.m4
> @@ -23,22 +23,25 @@ dnl SVN_LIB_MACHO_ITERATE
>  dnl Check for _dyld_image_name and _dyld_image_header availability
>  AC_DEFUN(SVN_LIB_MACHO_ITERATE,
>  [
> -  AC_MSG_CHECKING([for Mach-O dynamic module iteration functions])
> -  AC_RUN_IFELSE([AC_LANG_PROGRAM([[
> -    #include <mach-o/dyld.h>
> -    #include <mach-o/loader.h>
> -  ]],[[
> -    const struct mach_header *header = _dyld_get_image_header(0);
> -    const char *name = _dyld_get_image_name(0);
> -    if (name && header) return 0;
> -    return 1;
> -  ]])],[
> +  AC_CACHE_CHECK([for Mach-O dynamic module iteration functions],
> +    [ac_cv_mach_o_dynamic_module_iteration_works], [
> +    AC_RUN_IFELSE([AC_LANG_PROGRAM([[
> +      #include <mach-o/dyld.h>
> +      #include <mach-o/loader.h>
> +    ]],[[
> +      const struct mach_header *header = _dyld_get_image_header(0);
> +      const char *name = _dyld_get_image_name(0);
> +      if (name && header) return 0;
> +      return 1;
> +    ]])],
> +    [ac_cv_mach_o_dynamic_module_iteration_works=yes],
> +    [ac_cv_mach_o_dynamic_module_iteration_works=no],
> +    [ac_cv_mach_o_dynamic_module_iteration_works=no])
> +  ])
> +  if test "$ac_cv_mach_o_dynamic_module_iteration_works" = yes; then
>      AC_DEFINE([SVN_HAVE_MACHO_ITERATE], [1],
>                [Is Mach-O low-level _dyld API available?])
> -    AC_MSG_RESULT([yes])
> -  ],[
> -    AC_MSG_RESULT([no])
> -  ])
> +  fi
>  ])
>
>  dnl SVN_LIB_MACOS_PLIST
> --
> 2.28.0

Thanks for your patch.

Looks good to me.

I'll wait a bit in case others have any feedback. If not, I'll commit
soon.

I don't have the setup to test cross-compiling at this time. However,
to verify native builds on macOS are unaffected, I built with this
patch applied to latest SVN trunk (r1881514). 'configure' correctly
gives 'yes' for "checking for Mach-O dynamic module iteration
functions" on macOS 10.15 "Catalina." (I also verified it correctly
gives 'no' on Debian 10 "Buster.") I tested 'svn --version --verbose'
on macOS lists the loaded dynamic libraries as it should.

Cheers,
Nathan
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v3] build/ac-macros/macosx.m4: workaround AC_RUN_IFELSE

Nathan Hartman
On Sun, Sep 6, 2020 at 3:22 PM Nathan Hartman <[hidden email]> wrote:

> > Patch by: Fabrice Fontaine
> >
> > The SVN_LIB_MACHO_ITERATE macro contains an AC_RUN_IFELSE test that
> > will raise the following build failure when cross-compiling:
> >
> > checking for Mach-O dynamic module iteration functions... configure: error: in `/home/fabrice/buildroot/output/build/subversion-1.14.0':
> > configure: error: cannot run test program while cross compiling
> >
> > To avoid this build failure, set the action-if-cross-compiling of
> > AC_RUN_IFELSE to a pessimistic value (no).
> > Moreover, encapsulate this call with AC_CACHE_CHECK as suggested by
> > Thomas Petazzoni to allow the user to override this value when
> > cross-compiling for macosx target.

Committed in r1881534.

Fabrice, can we consider issue # SVN-4864 to be closed?

https://issues.apache.org/jira/browse/SVN-4864

Thanks,
Nathan
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v3] build/ac-macros/macosx.m4: workaround AC_RUN_IFELSE

Fabrice Fontaine
Hello Nathan,

Le lun. 7 sept. 2020 à 15:33, Nathan Hartman
<[hidden email]> a écrit :

>
> On Sun, Sep 6, 2020 at 3:22 PM Nathan Hartman <[hidden email]> wrote:
> > > Patch by: Fabrice Fontaine
> > >
> > > The SVN_LIB_MACHO_ITERATE macro contains an AC_RUN_IFELSE test that
> > > will raise the following build failure when cross-compiling:
> > >
> > > checking for Mach-O dynamic module iteration functions... configure: error: in `/home/fabrice/buildroot/output/build/subversion-1.14.0':
> > > configure: error: cannot run test program while cross compiling
> > >
> > > To avoid this build failure, set the action-if-cross-compiling of
> > > AC_RUN_IFELSE to a pessimistic value (no).
> > > Moreover, encapsulate this call with AC_CACHE_CHECK as suggested by
> > > Thomas Petazzoni to allow the user to override this value when
> > > cross-compiling for macosx target.
>
> Committed in r1881534.
>
> Fabrice, can we consider issue # SVN-4864 to be closed?
Yes, we can.
>
> https://issues.apache.org/jira/browse/SVN-4864
>
> Thanks,
> Nathan
Best Regards,

Fabrice
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v3] build/ac-macros/macosx.m4: workaround AC_RUN_IFELSE

Daniel Shahaf-2
In reply to this post by Nathan Hartman
Nathan Hartman wrote on Mon, 07 Sep 2020 09:33 -0400:

> On Sun, Sep 6, 2020 at 3:22 PM Nathan Hartman <[hidden email]> wrote:
> > > Patch by: Fabrice Fontaine
> > >
> > > The SVN_LIB_MACHO_ITERATE macro contains an AC_RUN_IFELSE test that
> > > will raise the following build failure when cross-compiling:
> > >
> > > checking for Mach-O dynamic module iteration functions... configure: error: in `/home/fabrice/buildroot/output/build/subversion-1.14.0':
> > > configure: error: cannot run test program while cross compiling
> > >
> > > To avoid this build failure, set the action-if-cross-compiling of
> > > AC_RUN_IFELSE to a pessimistic value (no).
> > > Moreover, encapsulate this call with AC_CACHE_CHECK as suggested by
> > > Thomas Petazzoni to allow the user to override this value when
> > > cross-compiling for macosx target.  
>
> Committed in r1881534.

Backport?
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v3] build/ac-macros/macosx.m4: workaround AC_RUN_IFELSE

Nathan Hartman
On Mon, Sep 7, 2020 at 6:44 PM Daniel Shahaf <[hidden email]> wrote:
Nathan Hartman wrote on Mon, 07 Sep 2020 09:33 -0400:
> On Sun, Sep 6, 2020 at 3:22 PM Nathan Hartman <[hidden email]> wrote:
> > > Patch by: Fabrice Fontaine
> > >
> > > The SVN_LIB_MACHO_ITERATE macro contains an AC_RUN_IFELSE test that
> > > will raise the following build failure when cross-compiling:
> > >
> > > checking for Mach-O dynamic module iteration functions... configure: error: in `/home/fabrice/buildroot/output/build/subversion-1.14.0':
> > > configure: error: cannot run test program while cross compiling
> > >
> > > To avoid this build failure, set the action-if-cross-compiling of
> > > AC_RUN_IFELSE to a pessimistic value (no).
> > > Moreover, encapsulate this call with AC_CACHE_CHECK as suggested by
> > > Thomas Petazzoni to allow the user to override this value when
> > > cross-compiling for macosx target. 
>
> Committed in r1881534.

Backport?

Yes. I intended to but got sidetracked. I'll nominate it soon.

Thanks,
Nathan