commit d4215cdbc472573bafe020532ebfcfb491e7615f Author: sisbell shane.isbell@gmail.com Date: Fri Nov 16 07:19:03 2018 +0000
Bug 28469: Fix unsupported libbacktrace in Rust 1.26 --- ...e-dl_iterate_phdr-is-undefined-on-Android.patch | 34 +++++++++++++++++ projects/rust/build | 5 +++ projects/rust/config | 6 ++- projects/rust/replace_pagesize_in_mmap.patch | 44 ++++++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/projects/rust/0001-Make-sure-dl_iterate_phdr-is-undefined-on-Android.patch b/projects/rust/0001-Make-sure-dl_iterate_phdr-is-undefined-on-Android.patch new file mode 100644 index 0000000..75cd657 --- /dev/null +++ b/projects/rust/0001-Make-sure-dl_iterate_phdr-is-undefined-on-Android.patch @@ -0,0 +1,34 @@ +From 4fa67c8a014ac10558be71edec9048851ca7a02d Mon Sep 17 00:00:00 2001 +From: Georg Koppen gk@torproject.org +Date: Thu, 15 Nov 2018 19:04:46 +0000 +Subject: [PATCH] Make sure `dl_iterate_phdr` is undefined on Android + +If we build with API < 21 we'll run into undefined reference errors. +We follow the Rust people who ran into similar issues when +upgrading libbacktrace for 1.28.0 in making sure `dl_iterate_phdr` is +not defined for Android. + +diff --git a/src/libbacktrace/configure b/src/libbacktrace/configure +index 8bdb29d256..8941fcd2b0 100755 +--- a/src/libbacktrace/configure ++++ b/src/libbacktrace/configure +@@ -12397,7 +12397,15 @@ rm -f conftest* + have_dl_iterate_phdr=no ;; + esac + else +- ac_fn_c_check_func "$LINENO" "dl_iterate_phdr" "ac_cv_func_dl_iterate_phdr" ++ case "${host}" in ++ *-*-androideabi*) ++ # Avoid dl_iterate_phdr on older Android API (which we use), ++ # as defining it causes undefined reference errors when ++ # compiling Firefox later on. ++ have_dl_iterate_phdr=no ;; ++ *) ac_fn_c_check_func "$LINENO" "dl_iterate_phdr" "ac_cv_func_dl_iterate_phdr" ;; ++ esac ++ + if test "x$ac_cv_func_dl_iterate_phdr" = x""yes; then : + have_dl_iterate_phdr=yes + else +-- +2.19.1 + diff --git a/projects/rust/build b/projects/rust/build index 7ae3073..12f012a 100644 --- a/projects/rust/build +++ b/projects/rust/build @@ -62,6 +62,11 @@ cd /var/tmp/build/rustc-[% c('version') %]-src patch -p1 < $rootdir/unwind.patch [% END %]
+[% IF c("var/android") %] + patch -p1 < $rootdir/0001-Make-sure-dl_iterate_phdr-is-undefined-on-Android.patch + patch -p1 < $rootdir/replace_pagesize_in_mmap.patch +[% END %] + mkdir build cd build ../configure --prefix=$distdir [% c("var/configure_opt") %] diff --git a/projects/rust/config b/projects/rust/config index 83ae690..99d1177 100644 --- a/projects/rust/config +++ b/projects/rust/config @@ -22,7 +22,7 @@ targets: - libssl-dev - pkg-config - zlib1g-dev - configure_opt: --enable-local-rust --enable-vendor --enable-extended --release-channel=stable --sysconfdir=etc --target=armv7-linux-androideabi --set=target.armv7-linux-androideabi.ar=$ANDROID_NDK_HOME/arm/bin/arm-linux-androideabi-ar --set=target.armv7-linux-androideabi.linker=$ANDROID_NDK_HOME/arm/bin/arm-linux-androideabi-clang --set=target.armv7-linux-androideabi.cc=$ANDROID_NDK_HOME/arm/bin/arm-linux-androideabi-gcc + configure_opt: --enable-local-rust --enable-vendor --enable-extended --release-channel=stable --sysconfdir=etc --target=armv7-linux-androideabi --set=target.armv7-linux-androideabi.cc=$ANDROID_NDK_HOME/arm/bin/arm-linux-androideabi-gcc
linux: var: @@ -90,3 +90,7 @@ input_files: gpg_keyring: rust.gpg - filename: unwind.patch enable: '[% c("var/windows-i686") %]' + - filename: 0001-Make-sure-dl_iterate_phdr-is-undefined-on-Android.patch + enable: '[% c("var/android") %]' + - filename: replace_pagesize_in_mmap.patch + enable: '[% c("var/android") %]' diff --git a/projects/rust/replace_pagesize_in_mmap.patch b/projects/rust/replace_pagesize_in_mmap.patch new file mode 100644 index 0000000..598f190 --- /dev/null +++ b/projects/rust/replace_pagesize_in_mmap.patch @@ -0,0 +1,44 @@ +diff --git a/src/libbacktrace/mmap.c b/src/libbacktrace/mmap.c +index 138ef70711..e3c4cd2643 100644 +--- a/src/libbacktrace/mmap.c ++++ b/src/libbacktrace/mmap.c +@@ -140,7 +140,7 @@ backtrace_alloc (struct backtrace_state *state, + { + /* Allocate a new page. */ + +- pagesize = getpagesize (); ++ pagesize = sysconf(_SC_PAGESIZE); + asksize = (size + pagesize - 1) & ~ (pagesize - 1); + page = mmap (NULL, asksize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); +@@ -181,7 +181,7 @@ backtrace_free (struct backtrace_state *state, void *addr, size_t size, + { + size_t pagesize; + +- pagesize = getpagesize (); ++ pagesize = sysconf(_SC_PAGESIZE); + if (((uintptr_t) addr & (pagesize - 1)) == 0 + && (size & (pagesize - 1)) == 0) + { +@@ -226,7 +226,7 @@ backtrace_vector_grow (struct backtrace_state *state,size_t size, + size_t alc; + void *base; + +- pagesize = getpagesize (); ++ pagesize = sysconf(_SC_PAGESIZE); + alc = vec->size + size; + if (vec->size == 0) + alc = 16 * size; +diff --git a/src/libbacktrace/mmapio.c b/src/libbacktrace/mmapio.c +index dfdaf6fa52..5b23003090 100644 +--- a/src/libbacktrace/mmapio.c ++++ b/src/libbacktrace/mmapio.c +@@ -60,7 +60,7 @@ backtrace_get_view (struct backtrace_state *state ATTRIBUTE_UNUSED, + off_t pageoff; + void *map; + +- pagesize = getpagesize (); ++ pagesize = sysconf(_SC_PAGESIZE); + inpage = offset % pagesize; + pageoff = offset - inpage; +