| From dd0a55ea479a4ffb3839e1a0348fc6ae4588c449 Mon Sep 17 00:00:00 2001 |
| From: Ke Wu <mikewu@google.com> |
| Date: Tue, 19 Jul 2022 13:41:49 -0700 |
| Subject: [PATCH] Add cross-compiling to fluent-bit |
| |
| --- |
| CMakeLists.txt | 4 ++-- |
| cmake/luajit.cmake | 2 +- |
| cmake/onigmo.cmake | 4 ++-- |
| lib/luajit-2.1.0-1e66d0f/src/Makefile | 4 +++- |
| lib/onigmo/configure | 6 ++++-- |
| 5 files changed, 12 insertions(+), 8 deletions(-) |
| |
| diff --git a/CMakeLists.txt b/CMakeLists.txt |
| index ed3d0cea0..3d837c500 100644 |
| --- a/CMakeLists.txt |
| +++ b/CMakeLists.txt |
| @@ -799,7 +799,7 @@ if(FLB_JEMALLOC AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
| # Link to Jemalloc as an external dependency |
| ExternalProject_Add(jemalloc |
| SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/jemalloc-5.2.1 |
| - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/jemalloc-5.2.1/configure ${AUTOCONF_HOST_OPT} "${FLB_JEMALLOC_OPTIONS_LIST}" --prefix=<INSTALL_DIR> |
| + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/jemalloc-5.2.1/configure ${AUTOCONF_HOST_OPT} --host=${HOST} "${FLB_JEMALLOC_OPTIONS_LIST}" --prefix=<INSTALL_DIR> |
| CFLAGS=-std=gnu99\ -Wall\ -pipe\ -g3\ -O3\ -funroll-loops |
| BUILD_COMMAND $(MAKE) |
| INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/ |
| @@ -825,7 +825,7 @@ if(FLB_BACKTRACE) |
| endif() |
| ExternalProject_Add(backtrace |
| SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbacktrace-2446c66/ |
| - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbacktrace-2446c66/configure ${AUTOCONF_HOST_OPT} --prefix=<INSTALL_DIR> --enable-shared=no --enable-static=yes |
| + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbacktrace-2446c66/configure ${AUTOCONF_HOST_OPT} --host=${HOST} --prefix=<INSTALL_DIR> --enable-shared=no --enable-static=yes |
| BUILD_COMMAND $(MAKE) |
| INSTALL_COMMAND $(MAKE) DESTDIR= install |
| ) |
| diff --git a/cmake/luajit.cmake b/cmake/luajit.cmake |
| index 7741805a9..3984e84d3 100644 |
| --- a/cmake/luajit.cmake |
| +++ b/cmake/luajit.cmake |
| @@ -37,7 +37,7 @@ ExternalProject_Add(luajit |
| EXCLUDE_FROM_ALL TRUE |
| SOURCE_DIR ${LUAJIT_SRC} |
| CONFIGURE_COMMAND ./configure |
| - BUILD_COMMAND $(MAKE) CC=${CMAKE_C_COMPILER} ${DEPLOYMENT_TARGET} CFLAGS=${CFLAGS} BUILDMODE=static "XCFLAGS=-fPIC" |
| + BUILD_COMMAND $(MAKE) CC=${CC} CROSS=${CROSS_PREFIX} HOST_CC=${BUILD_CC} STRIP=${STRIP} ${DEPLOYMENT_TARGET} CFLAGS=${CFLAGS} BUILDMODE=static "XCFLAGS=-fPIC" |
| INSTALL_COMMAND cp src/libluajit.a "${LUAJIT_DEST}/lib/libluajit.a") |
| |
| # luajit (Windows) |
| diff --git a/cmake/onigmo.cmake b/cmake/onigmo.cmake |
| index dd9cb3119..d38f526fe 100644 |
| --- a/cmake/onigmo.cmake |
| +++ b/cmake/onigmo.cmake |
| @@ -33,7 +33,7 @@ ExternalProject_Add(onigmo |
| EXCLUDE_FROM_ALL TRUE |
| SOURCE_DIR ${ONIGMO_SRC} |
| INSTALL_DIR ${ONIGMO_DEST} |
| - CONFIGURE_COMMAND ./configure ${AUTOCONF_HOST_OPT} --with-pic --disable-shared --enable-static --prefix=${ONIGMO_DEST} |
| + CONFIGURE_COMMAND ./configure ${AUTOCONF_HOST_OPT} --host=${HOST} --with-pic --disable-shared --enable-static --prefix=${ONIGMO_DEST} |
| CFLAGS=-std=gnu99\ -Wall\ -pipe\ -Os\ -g0\ -s\ -fno-stack-protector\ -fomit-frame-pointer\ -DNDEBUG\ -U_FORTIFY_SOURCE |
| BUILD_COMMAND $(MAKE) |
| INSTALL_COMMAND $(MAKE) DESTDIR= install) |
| @@ -43,7 +43,7 @@ ExternalProject_Add(onigmo |
| EXCLUDE_FROM_ALL TRUE |
| SOURCE_DIR ${ONIGMO_SRC} |
| INSTALL_DIR ${ONIGMO_DEST} |
| - CONFIGURE_COMMAND ./configure ${AUTOCONF_HOST_OPT} --with-pic --disable-shared --enable-static --prefix=${ONIGMO_DEST} |
| + CONFIGURE_COMMAND ./configure ${AUTOCONF_HOST_OPT} --host=${HOST} --with-pic --disable-shared --enable-static --prefix=${ONIGMO_DEST} |
| CFLAGS=-std=gnu99\ -Wall\ -pipe\ -g3\ -O3\ -funroll-loops |
| BUILD_COMMAND $(MAKE) |
| INSTALL_COMMAND $(MAKE) DESTDIR= install) |
| diff --git a/lib/luajit-2.1.0-1e66d0f/src/Makefile b/lib/luajit-2.1.0-1e66d0f/src/Makefile |
| index 2e1a28885..952885414 100644 |
| --- a/lib/luajit-2.1.0-1e66d0f/src/Makefile |
| +++ b/lib/luajit-2.1.0-1e66d0f/src/Makefile |
| @@ -212,7 +212,8 @@ TARGET_STCC= $(STATIC_CC) |
| TARGET_DYNCC= $(DYNAMIC_CC) |
| TARGET_LD= $(CROSS)$(CC) |
| TARGET_AR= $(CROSS)ar rcus 2>/dev/null |
| -TARGET_STRIP= $(CROSS)strip |
| +# lakitu: Use STRIP env to allow llvm-strip |
| +TARGET_STRIP= $(CROSS)$(STRIP) |
| |
| TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib) |
| TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER) |
| @@ -700,6 +701,7 @@ include Makefile.dep |
| # Target file rules. |
| ############################################################################## |
| |
| + |
| $(LUAJIT_A): $(LJVMCORE_O) |
| $(E) "AR $@" |
| $(Q)$(TARGET_AR) $@ $(LJVMCORE_O) |
| diff --git a/lib/onigmo/configure b/lib/onigmo/configure |
| index 23b88c43e..561e5865f 100755 |
| --- a/lib/onigmo/configure |
| +++ b/lib/onigmo/configure |
| @@ -12111,7 +12111,8 @@ then |
| eval ac_cv_prog_cc_${ac_cc}_c_o=yes |
| if test "x$CC" != xcc; then |
| # Test first that cc exists at all. |
| - if { ac_try='cc -c conftest.$ac_ext >&5' |
| + # lakitu: cros_sdk doesn't allow to use unprefixed cc directly. |
| + if { ac_try='$CC -c conftest.$ac_ext >&5' |
| { { case "(($ac_try" in |
| *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; |
| *) ac_try_echo=$ac_try;; |
| @@ -12122,7 +12123,8 @@ $as_echo "$ac_try_echo"; } >&5 |
| ac_status=$? |
| $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
| test $ac_status = 0; }; }; then |
| - ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' |
| + # lakitu: cros_sdk doesn't allow to use unprefixed cc directly. |
| + ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' |
| rm -f conftest2.* |
| if { { case "(($ac_try" in |
| *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; |
| -- |
| 2.37.0.170.g444d1eabd0-goog |
| |