summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGautam Prajapati <gautamprajapati06@gmail.com>2017-07-24 10:21:16 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-08-15 16:27:43 +0200
commitcad80f35f4944ebd23ea7818e7a3e9e825b55b28 (patch)
treec01418f8e0c3e7a4e63ccf10ced59b5aaf9d4534
parent3281628e1cf66f51f414436cd2002e0a63ec4750 (diff)
Fix and enable NSS build for Android
Change-Id: Ifa8e01542ed0e7d72bfc9684f36b6dee9e185df4 Reviewed-on: https://gerrit.libreoffice.org/40645 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--config_host.mk.in4
-rw-r--r--configure.ac13
-rw-r--r--external/nss/ExternalProject_nss.mk2
-rw-r--r--external/nss/Module_nss.mk2
-rw-r--r--external/nss/UnpackedTarball_nss.mk2
-rw-r--r--external/nss/nss-android.patch250
6 files changed, 268 insertions, 5 deletions
diff --git a/config_host.mk.in b/config_host.mk.in
index 75298b966716..71993077899a 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -16,10 +16,14 @@ export BUILDDIR=@BUILDDIR@
export ABW_CFLAGS=$(gb_SPACE)@ABW_CFLAGS@
export ABW_LIBS=$(gb_SPACE)@ABW_LIBS@
export ALLOC=@ALLOC@
+export ANDROID_NDK_HOME=@ANDROID_NDK_HOME@
export ANDROID_APP_ABI=@ANDROID_APP_ABI@
export ANDROID_NDK_GDBSERVER=@ANDROID_NDK_GDBSERVER@
export ANDROID_SDK_HOME=@ANDROID_SDK_HOME@
export ANDROID_PACKAGE_NAME=@ANDROID_PACKAGE_NAME@
+export ANDROID_CLANG_TOOLCHAIN=@ANDROID_CLANG_TOOLCHAIN@
+export ANDROID_GCC_TOOLCHAIN_VERSION=@ANDROID_GCC_TOOLCHAIN_VERSION@
+export ANDROID_PLATFORM_DIRECTORY=@ANDROID_PLATFORM_DIRECTORY@
export ANT=@ANT@
export ANT_HOME=@ANT_HOME@
export ANT_LIB=@ANT_LIB@
diff --git a/configure.ac b/configure.ac
index 490d03e058cd..4cd517015019 100644
--- a/configure.ac
+++ b/configure.ac
@@ -416,7 +416,8 @@ if test -n "$with_android_ndk"; then
fi
case "$with_android_ndk_toolchain_version" in
clang5.0)
- ANDROID_BINUTILS_DIR=$ANDROID_NDK_HOME/toolchains/$android_platform_prefix-4.9
+ ANDROID_GCC_TOOLCHAIN_VERSION=4.9
+ ANDROID_BINUTILS_DIR=$ANDROID_NDK_HOME/toolchains/$android_platform_prefix-$ANDROID_GCC_TOOLCHAIN_VERSION
ANDROID_COMPILER_DIR=$ANDROID_NDK_HOME/toolchains/llvm
ANDROID_USING_CLANG=true
;;
@@ -449,8 +450,8 @@ if test -n "$with_android_ndk"; then
AC_MSG_ERROR([We only support building for Android from Linux or OS X])
;;
esac
-
- ANDROID_COMPILER_BIN=$ANDROID_COMPILER_DIR/prebuilt/$ndk_build_os-x86/bin
+ ANDROID_CLANG_TOOLCHAIN=$ANDROID_COMPILER_DIR/prebuilt/$ndk_build_os-x86_64
+ ANDROID_COMPILER_BIN=$ANDROID_CLANG_TOOLCHAIN/bin
ANDROID_BINUTILS_PREBUILT_ROOT=$ANDROID_BINUTILS_DIR/prebuilt/$ndk_build_os-x86
if test $build_cpu = x86_64; then
if test -d $ANDROID_COMPILER_DIR/prebuilt/$ndk_build_os-x86_64; then
@@ -512,6 +513,8 @@ if test -n "$with_android_ndk"; then
ANDROID_APP_ABI=x86
ANDROIDCFLAGS="-march=atom -gcc-toolchain $ANDROID_BINUTILS_PREBUILT_ROOT -target i686-none-linux-android"
fi
+
+ ANDROID_PLATFORM_DIRECTORY=$ANDROID_NDK_HOME/platforms/android-${ANDROID_API_LEVEL}/arch-${ANDROID_ARCH}
ANDROIDCFLAGS="$ANDROIDCFLAGS -ffunction-sections -fdata-sections"
ANDROIDCFLAGS="$ANDROIDCFLAGS -L$ANDROID_NDK_HOME/sources/cxx-stl/gnu-libstdc++/${ANDROID_NDK_TOOLCHAIN_VERSION_SUBDIR}libs/$ANDROID_APP_ABI"
ANDROIDCFLAGS="$ANDROIDCFLAGS --sysroot=$ANDROID_NDK_HOME/platforms/android-${ANDROID_API_LEVEL}/arch-${ANDROID_ARCH}"
@@ -581,8 +584,12 @@ if test -n "$with_android_ndk"; then
# remember to download the ownCloud Android library later
BUILD_TYPE="$BUILD_TYPE OWNCLOUD_ANDROID_LIB"
fi
+AC_SUBST(ANDROID_NDK_HOME)
AC_SUBST(ANDROID_NDK_GDBSERVER)
AC_SUBST(ANDROID_APP_ABI)
+AC_SUBST(ANDROID_CLANG_TOOLCHAIN)
+AC_SUBST(ANDROID_GCC_TOOLCHAIN_VERSION)
+AC_SUBST(ANDROID_PLATFORM_DIRECTORY)
dnl ===================================================================
dnl --with-android-sdk
diff --git a/external/nss/ExternalProject_nss.mk b/external/nss/ExternalProject_nss.mk
index f555975ee7fa..0a0e89006352 100644
--- a/external/nss/ExternalProject_nss.mk
+++ b/external/nss/ExternalProject_nss.mk
@@ -21,6 +21,7 @@ $(call gb_ExternalProject_get_state_target,nss,configure):
NSINSTALL="$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/external/nss/nsinstall.py") \
nspr/configure --includedir=$(call gb_UnpackedTarball_get_dir,nss)/mozilla/dist/out/include \
$(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
+ $(if $(filter ANDROID,$(OS)),--build=$(BUILD_PLATFORM) --host="arm-linux-androidebi" --with-android-ndk=$(ANDROID_NDK_HOME) --with-android-toolchain=$(ANDROID_CLANG_TOOLCHAIN) --with-android-platform=$(ANDROID_PLATFORM_DIRECTORY)) \
$(if $(filter MSC-X86_64,$(COM)-$(CPUNAME)),--enable-64bit) \
$(if $(filter MSC-INTEL,$(COM)-$(CPUNAME)),--host=i686-pc-cygwin) \
,,nss_configure.log)
@@ -58,6 +59,7 @@ $(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalProject
NMEDIT="$(NM)edit" \
CCC="$(CXX)" \
$(if $(CROSS_COMPILING),NSPR_CONFIGURE_OPTS="--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)") \
+ $(if $(filter ANDROID,$(OS)),OS_TARGET=Android ANDROID_NDK=$(ANDROID_NDK_HOME) ANDROID_TOOLCHAIN_VERSION=$(ANDROID_GCC_TOOLCHAIN_VERSION) NSPR_CONFIGURE_OPTS="--build=$(BUILD_PLATFORM) --host=arm-linux-androidebi --with-android-ndk=$(ANDROID_NDK_HOME) --with-android-toolchain=$(ANDROID_CLANG_TOOLCHAIN) --with-android-platform=$(ANDROID_PLATFORM_DIRECTORY)") \
nss_build_all \
&& rm -f $(call gb_UnpackedTarball_get_dir,nss)/dist/out/lib/*.a \
$(if $(filter MACOSX,$(OS)),\
diff --git a/external/nss/Module_nss.mk b/external/nss/Module_nss.mk
index 69b39f59ee5d..eae9e9524480 100644
--- a/external/nss/Module_nss.mk
+++ b/external/nss/Module_nss.mk
@@ -9,12 +9,10 @@
$(eval $(call gb_Module_Module,nss))
-ifeq ($(filter ANDROID,$(OS)),)
$(eval $(call gb_Module_add_targets,nss,\
UnpackedTarball_nss \
ExternalPackage_nss \
ExternalProject_nss \
))
-endif
# vim: set noet sw=4 ts=4:
diff --git a/external/nss/UnpackedTarball_nss.mk b/external/nss/UnpackedTarball_nss.mk
index 314ff875ecbd..7858915ae06e 100644
--- a/external/nss/UnpackedTarball_nss.mk
+++ b/external/nss/UnpackedTarball_nss.mk
@@ -32,6 +32,8 @@ $(eval $(call gb_UnpackedTarball_add_patches,nss,\
external/nss/nss.vs2015.pdb.patch) \
$(if $(filter WNT,$(OS)), \
external/nss/nss.utf8bom.patch.1) \
+ $(if $(filter ANDROID,$(OS)), \
+ external/nss/nss-android.patch) \
))
ifeq ($(COM_IS_CLANG),TRUE)
diff --git a/external/nss/nss-android.patch b/external/nss/nss-android.patch
new file mode 100644
index 000000000000..7630cc58082b
--- /dev/null
+++ b/external/nss/nss-android.patch
@@ -0,0 +1,250 @@
+--- a/nss.org/nspr/config/config.mk 2017-08-14 18:58:33.560407294 +0530
++++ b/nss/nspr/config/config.mk 2017-08-14 18:59:34.319025410 +0530
+@@ -42,6 +42,13 @@
+
+ LDFLAGS = $(OS_LDFLAGS)
+
++# When targeting Android, add HOST_CFLAGS to CC flags
++# It is mandatory when using Clang toolchain in NDK
++# See autoconf.mk in nspr/out/config/ for the values.
++ifeq ($(OS_TARGET),Android)
++CC += $(OS_CFLAGS)
++endif
++
+ # Enable profile-guided optimization
+ ifndef NO_PROFILE_GUIDED_OPTIMIZE
+ ifdef MOZ_PROFILE_GENERATE
+--- a/nss.org/nspr/config/Makefile.in 2017-08-14 18:58:33.560407294 +0530
++++ b/nss/nspr/config/Makefile.in 2017-08-14 18:59:34.319025410 +0530
+@@ -76,6 +76,7 @@
+
+ include $(topsrcdir)/config/rules.mk
+
++ifneq ($(OS_TARGET),Android)
+ PROGS = $(OBJDIR)/now$(PROG_SUFFIX)
+
+ ifeq (,$(CROSS_COMPILE)$(filter-out OS2 WINNT,$(OS_ARCH)))
+@@ -88,6 +89,7 @@
+ TARGETS = $(PROGS) $(PLSRCS:.pl=)
+ endif
+ endif
++endif
+
+ OUTOPTION = -o # end of the line
+ ifeq (,$(filter-out WINNT WIN95 WINCE,$(OS_TARGET)))
+--- a/nss.org/nspr/configure 2017-08-14 18:58:33.544407658 +0530
++++ b/nss/nspr/configure 2017-08-14 18:59:34.319025410 +0530
+@@ -2509,7 +2509,9 @@
+ OBJDIR='$(OBJDIR_NAME)'
+ OBJDIR_NAME=.
+ OBJDIR_SUFFIX=OBJ
+-NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
++if [ -z "$NSINSTALL" ]; then
++ NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
++fi
+ NOSUCHFILE=/no-such-file
+ LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)'
+ LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)'
+@@ -2643,7 +2645,7 @@
+
+ case "$target" in
+ arm-linux*-android*|*-linuxandroid*)
+- android_tool_prefix="arm-linux-androideabi"
++ android_tool_prefix="clang"
+ ;;
+ i?86-*android*)
+ android_tool_prefix="i686-linux-android"
+@@ -2737,18 +2739,19 @@
+ esac
+
+ AS="$android_toolchain"/bin/"$android_tool_prefix"-as
+- CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
+- CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
+- CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
++ CC="$android_toolchain"/bin/"$android_tool_prefix"
++ CXX="$android_toolchain"/bin/"$android_tool_prefix"++
++ CPP="$CC" -E
+ LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
+ AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
+ RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
+ STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
+
+ CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
+- CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
+- CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
+- LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
++ CFLAGS="-gcc-toolchain "$android_ndk"/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64"
++ CFLAGS="$CFLAGS -target armv7-none-linux-androideabi"
++ CFLAGS="$CFLAGS --sysroot=$android_platform"
++ CXXFLAGS="-I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
+
+ $as_echo "#define ANDROID 1" >>confdefs.h
+
+@@ -5954,7 +5957,7 @@
+ CFLAGS="$_SAVE_CFLAGS"
+ fi
+
+-all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
++all_flags=`echo -target armv7-none-linux-androideabi $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
+ if test -n "$all_flags"; then
+ _SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$all_flags"
+--- a/nss.org/nss/coreconf/arch.mk 2017-08-14 18:58:33.596406475 +0530
++++ b/nss/nss/coreconf/arch.mk 2017-08-14 18:59:34.319025410 +0530
+@@ -237,7 +237,7 @@
+ OS_TEST := arm
+ OS_ARCH = Android
+ ifndef OS_TARGET_RELEASE
+- OS_TARGET_RELEASE := 8
++ OS_TARGET_RELEASE := 15
+ endif
+ endif
+
+--- a/nss.org/nss/coreconf/Linux.mk 2017-08-14 18:58:33.596406475 +0530
++++ b/nss/nss/coreconf/Linux.mk 2017-08-14 19:00:20.201982027 +0530
+@@ -33,16 +33,17 @@
+ ANDROID_TARGET=$(ANDROID_PREFIX)-$(ANDROID_TOOLCHAIN_VERSION)
+ # should autodetect which linux we are on, currently android only
+ # supports linux-x86 prebuilts
+- ANDROID_TOOLCHAIN=$(ANDROID_NDK)/toolchains/$(ANDROID_TARGET)/prebuilt/linux-x86
++ ANDROID_GCC_TOOLCHAIN = $(ANDROID_NDK)/toolchains/$(ANDROID_TARGET)/prebuilt/linux-x86_64
++ ANDROID_TOOLCHAIN=$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64
+ ANDROID_SYSROOT=$(ANDROID_NDK)/platforms/android-$(OS_TARGET_RELEASE)/arch-$(OS_TEST)
+- ANDROID_CC=$(ANDROID_TOOLCHAIN)/bin/$(ANDROID_PREFIX)-gcc
+- ANDROID_CCC=$(ANDROID_TOOLCHAIN)/bin/$(ANDROID_PREFIX)-g++
++ ANDROID_CC=$(ANDROID_TOOLCHAIN)/bin/clang
++ ANDROID_CCC=$(ANDROID_TOOLCHAIN)/bin/clang++
+ NSS_DISABLE_GTESTS=1
+ # internal tools need to be built with the native compiler
+ ifndef INTERNAL_TOOLS
+- CC = $(ANDROID_CC) --sysroot=$(ANDROID_SYSROOT)
++ CC = $(ANDROID_CC) --gcc-toolchain=$(ANDROID_GCC_TOOLCHAIN) -target armv7-none-linux-androideabi --sysroot=$(ANDROID_SYSROOT)
+ CCC = $(ANDROID_CCC) --sysroot=$(ANDROID_SYSROOT)
+- DEFAULT_COMPILER=$(ANDROID_PREFIX)-gcc
++ DEFAULT_COMPILER=clang
+ ARCHFLAG = --sysroot=$(ANDROID_SYSROOT)
+ DEFINES += -DNO_SYSINFO -DNO_FORK_CHECK -DANDROID
+ CROSS_COMPILE = 1
+--- a/nss.org/nss/coreconf/Makefile 2017-08-14 18:58:33.596406475 +0530
++++ b/nss/nss/coreconf/Makefile 2017-08-14 18:59:34.319025410 +0530
+@@ -7,7 +7,9 @@
+
+ MODULE = coreconf
+
++ifneq ($(OS_TARGET),Android)
+ DIRS = nsinstall
++endif
+
+ include $(DEPTH)/coreconf/config.mk
+ include $(DEPTH)/coreconf/rules.mk
+--- a/nss.org/nss/coreconf/UNIX.mk 2017-08-14 18:58:33.596406475 +0530
++++ b/nss/nss/coreconf/UNIX.mk 2017-08-14 18:59:34.319025410 +0530
+@@ -24,7 +24,6 @@
+ NSINSTALL = $(BUILD_TREE)/nss/nsinstall
+ else
+ NSINSTALL_DIR = $(CORE_DEPTH)/coreconf/nsinstall
+-NSINSTALL = $(NSINSTALL_DIR)/$(OBJDIR_NAME)/nsinstall
+ endif
+
+ MKDEPEND_DIR = $(CORE_DEPTH)/coreconf/mkdepend
+--- a/nss.org/nss/coreconf/Werror.mk 2017-08-14 18:58:33.596406475 +0530
++++ b/nss/nss/coreconf/Werror.mk 2017-08-14 18:59:34.319025410 +0530
+@@ -52,9 +52,6 @@
+
+ WARNING_CFLAGS = -Wall
+ ifdef CC_IS_CLANG
+- # -Qunused-arguments : clang objects to arguments that it doesn't understand
+- # and fixing this would require rearchitecture
+- WARNING_CFLAGS += -Qunused-arguments
+ # -Wno-parentheses-equality : because clang warns about macro expansions
+ WARNING_CFLAGS += $(call disable_warning,parentheses-equality)
+ ifdef BUILD_OPT
+--- a/nss.org/nss/lib/freebl/unix_rand.c 2017-08-14 18:58:33.632405656 +0530
++++ b/nss/nss/lib/freebl/unix_rand.c 2017-08-14 18:59:34.319025410 +0530
+@@ -682,6 +682,7 @@ RNG_GetNoise(void *buf, size_t maxbytes)
+ return n;
+ }
+
++#ifndef __ANDROID__
+ #define SAFE_POPEN_MAXARGS 10 /* must be at least 2 */
+
+ /*
+@@ -809,6 +810,7 @@ safe_pclose(FILE *fp)
+
+ return status;
+ }
++#endif
+
+ #ifdef DARWIN
+ #include <TargetConditionals.h>
+@@ -820,12 +822,16 @@ safe_pclose(FILE *fp)
+ /* Fork netstat to collect its output by default. Do not unset this unless
+ * another source of entropy is available
+ */
++#ifndef __ANDROID__
+ #define DO_NETSTAT 1
++#endif
+
+ void
+ RNG_SystemInfoForRNG(void)
+ {
++ #ifndef __ANDROID__
+ FILE *fp;
++ #endif
+ char buf[BUFSIZ];
+ size_t bytes;
+ const char *const *cp;
+@@ -860,11 +866,13 @@ RNG_SystemInfoForRNG(void)
+ };
+ #endif
+
++#ifndef __ANDROID__
+ #if defined(BSDI)
+ static char netstat_ni_cmd[] = "netstat -nis";
+ #else
+ static char netstat_ni_cmd[] = "netstat -ni";
+ #endif
++#endif
+
+ GiveSystemInfo();
+
+@@ -890,7 +898,10 @@ RNG_SystemInfoForRNG(void)
+ if (gethostname(buf, sizeof(buf)) == 0) {
+ RNG_RandomUpdate(buf, strlen(buf));
+ }
++
++ #ifndef __ANDROID__
+ GiveSystemInfo();
++ #endif
+
+ /* grab some data from system's PRNG before any other files. */
+ bytes = RNG_FileUpdate("/dev/urandom", SYSTEM_RNG_SEED_COUNT);
+@@ -939,8 +950,10 @@ RNG_SystemInfoForRNG(void)
+ * and for Solaris 8 we have the libkstat interface, so we don't need to
+ * fork netstat.
+ */
+-
++#ifndef __ANDROID__
+ #undef DO_NETSTAT
++#endif
++
+ if (!bytes) {
+ /* On Solaris 8, /dev/urandom isn't available, so we use libkstat. */
+ PRUint32 kstat_bytes = 0;
+@@ -952,6 +965,7 @@ RNG_SystemInfoForRNG(void)
+ }
+ #endif
+
++#ifndef __ANDROID__
+ #ifdef DO_NETSTAT
+ fp = safe_popen(netstat_ni_cmd);
+ if (fp != NULL) {
+@@ -960,6 +974,7 @@ RNG_SystemInfoForRNG(void)
+ safe_pclose(fp);
+ }
+ #endif
++#endif
+ }
+
+ #define TOTAL_FILE_LIMIT 1000000 /* one million */
+ \ No newline at end of file