This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.2.x by this push:
     new 6d1fd01  Enables crosscompling of ATS (#7786)
6d1fd01 is described below

commit 6d1fd019726e4831da8d44a982b4408f54b35996
Author: Randall Meyer <[email protected]>
AuthorDate: Thu Oct 14 11:17:15 2021 -0700

    Enables crosscompling of ATS (#7786)
    
    These changes allow for CompileParseRules to be built and run on host
    architecture along with cleaning up automake macros that previously
    prevented crosscompliation
    
    (cherry picked from commit 852d90d37eca5c12adc8e4db8b943c91bced058e)
---
 .gitignore                 |  1 +
 build/ax_cc_for_build.m4   | 76 ++++++++++++++++++++++++++++++++++++++++++++++
 build/crypto.m4            |  7 +++--
 configure.ac               |  2 ++
 mgmt/api/Makefile.am       |  2 +-
 src/tscore/Makefile.am     |  7 ++++-
 src/tscpp/util/Makefile.am |  2 +-
 7 files changed, 92 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore
index fe0004a..3f9ff12 100644
--- a/.gitignore
+++ b/.gitignore
@@ -86,6 +86,7 @@ src/tscore/ink_autoconf.h.in
 include/tscore/ink_config.h
 include/ts/apidefs.h
 src/tscore/CompileParseRules
+src/tscore/CompileParseRules.dSYM
 src/tscore/ParseRulesCType
 src/tscore/ParseRulesCTypeToLower
 src/tscore/ParseRulesCTypeToUpper
diff --git a/build/ax_cc_for_build.m4 b/build/ax_cc_for_build.m4
new file mode 100644
index 0000000..42b0629
--- /dev/null
+++ b/build/ax_cc_for_build.m4
@@ -0,0 +1,76 @@
+# ===========================================================================
+#     https://www.gnu.org/software/autoconf-archive/ax_cc_for_build.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CC_FOR_BUILD
+#
+# DESCRIPTION
+#
+#   Find a build-time compiler. Sets CC_FOR_BUILD and EXEEXT_FOR_BUILD.
+#
+# LICENSE
+#
+#   Copyright (c) 2010 Reuben Thomas <[email protected]>
+#   Copyright (c) 1999 Richard Henderson <[email protected]>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 3
+
+dnl Get a default for CC_FOR_BUILD to put into Makefile.
+AC_DEFUN([AX_CC_FOR_BUILD],
+[# Put a plausible default for CC_FOR_BUILD in Makefile.
+if test -z "$CC_FOR_BUILD"; then
+    CC_FOR_BUILD='$(CC)'
+    CXX_FOR_BUILD='$(CXX)'
+fi
+AC_SUBST(CC_FOR_BUILD)
+AC_SUBST(CXX_FOR_BUILD)
+
+# Also set EXEEXT_FOR_BUILD.
+if test "x$cross_compiling" = "xno"; then
+  EXEEXT_FOR_BUILD='$(EXEEXT)'
+else
+  AC_CACHE_CHECK([for build system executable suffix], bfd_cv_build_exeext,
+    [rm -f conftest*
+     echo 'int main () { return 0; }' > conftest.c
+     bfd_cv_build_exeext=
+     ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
+     for file in conftest.*; do
+       case $file in
+       *.c | *.o | *.obj | *.ilk | *.pdb) ;;
+       *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
+       esac
+     done
+     rm -f conftest*
+     test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no])
+  EXEEXT_FOR_BUILD=""
+  test x"${bfd_cv_build_exeext}" != xno && 
EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
+fi
+AC_SUBST(EXEEXT_FOR_BUILD)])dnl
diff --git a/build/crypto.m4 b/build/crypto.m4
index bdac347..e9e675f 100644
--- a/build/crypto.m4
+++ b/build/crypto.m4
@@ -45,7 +45,8 @@ dnl Check OpenSSL Version
 dnl
 AC_DEFUN([TS_CHECK_CRYPTO_VERSION], [
   AC_MSG_CHECKING([OpenSSL version])
-  AC_RUN_IFELSE([AC_LANG_SOURCE([[
+  AC_RUN_IFELSE([AC_LANG_SOURCE(
+  [
 #include <openssl/opensslv.h>
 int main() {
   if (OPENSSL_VERSION_NUMBER < 0x1000200fL) {
@@ -53,7 +54,9 @@ int main() {
   }
   return 0;
 }
-]])],[AC_MSG_RESULT([ok])],[AC_MSG_FAILURE([requires OpenSSL version 1.0.2 or 
greater])],[])
+  ])],
+  [AC_MSG_RESULT([ok])], [AC_MSG_FAILURE([requires OpenSSL version 1.0.2 or 
greater])], [AC_MSG_RESULT([assuming ok])]
+  )
 ])
 
 dnl
diff --git a/configure.ac b/configure.ac
index 3531f5a..8498844 100644
--- a/configure.ac
+++ b/configure.ac
@@ -647,6 +647,8 @@ AM_PROG_AS
 
 AX_COMPILER_VENDOR
 
+AX_CC_FOR_BUILD
+
 CFLAGS="${_ts_saved_CFLAGS}"
 CXXFLAGS="${_ts_saved_CXXFLAGS}"
 
diff --git a/mgmt/api/Makefile.am b/mgmt/api/Makefile.am
index 0ddd113..40890dc 100644
--- a/mgmt/api/Makefile.am
+++ b/mgmt/api/Makefile.am
@@ -67,7 +67,7 @@ libmgmtapilocal_la_LIBADD = \
        libmgmtapi.la \
        $(top_builddir)/src/tscore/libtscore.la
 
-libtsmgmt_la_LDFLAGS = -no-undefined -version-info @TS_LIBTOOL_VERSION@
+libtsmgmt_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -version-info 
@TS_LIBTOOL_VERSION@
 libtsmgmt_la_LIBADD = @LIBOBJS@ \
        libmgmtapi.la \
        $(top_builddir)/src/tscore/libtscore.la \
diff --git a/src/tscore/Makefile.am b/src/tscore/Makefile.am
index 67550ff..f54940f 100644
--- a/src/tscore/Makefile.am
+++ b/src/tscore/Makefile.am
@@ -27,6 +27,8 @@ endif
 
 TESTS_ENVIRONMENT = 
LSAN_OPTIONS=suppressions=$(abs_top_srcdir)/ci/asan_leak_suppression/unit_tests.txt
 
+BUILT_SOURCES = ParseRules.cc
+
 TESTS = $(check_PROGRAMS)
 
 lib_LTLIBRARIES = libtscore.la
@@ -38,7 +40,7 @@ AM_CPPFLAGS += \
        $(TS_INCLUDES) \
        @YAMLCPP_INCLUDES@
 
-libtscore_la_LDFLAGS = -no-undefined -version-info @TS_LIBTOOL_VERSION@ 
@YAMLCPP_LDFLAGS@
+libtscore_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -version-info 
@TS_LIBTOOL_VERSION@ @YAMLCPP_LDFLAGS@
 libtscore_la_LIBADD = \
        $(top_builddir)/src/tscpp/util/libtscpputil.la \
        @HWLOC_LIBS@ \
@@ -206,6 +208,9 @@ freelist_benchmark_SOURCES = 
unit_tests/freelist_benchmark.cc
 
 CompileParseRules_SOURCES = CompileParseRules.cc
 
+CompileParseRules$(BUILD_EXEEXT): $(CompileParseRules_OBJECTS)
+       $(CXX_FOR_BUILD) $(AM_CXXFLAGS) -I$(top_builddir)/include 
-I$(abs_top_srcdir)/include -o $@ 
$(abs_top_srcdir)/src/tscore/CompileParseRules.cc
+
 clean-local:
        rm -f ParseRulesCType ParseRulesCTypeToLower ParseRulesCTypeToUpper
 
diff --git a/src/tscpp/util/Makefile.am b/src/tscpp/util/Makefile.am
index 07351fd..40139bf 100644
--- a/src/tscpp/util/Makefile.am
+++ b/src/tscpp/util/Makefile.am
@@ -26,7 +26,7 @@ lib_LTLIBRARIES = libtscpputil.la
 
 AM_CPPFLAGS += -I$(abs_top_srcdir)/include
 
-libtscpputil_la_LDFLAGS = -no-undefined -version-info @TS_LIBTOOL_VERSION@
+libtscpputil_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -version-info 
@TS_LIBTOOL_VERSION@
 
 libtscpputil_la_SOURCES = \
        TextView.cc

Reply via email to