Merge "Statically link libgcc and libstdc++ into gold"
diff --git a/build/core/definitions.mk b/build/core/definitions.mk
index 7bdc711..1d989e2 100644
--- a/build/core/definitions.mk
+++ b/build/core/definitions.mk
@@ -932,7 +932,9 @@
# $3: list of C++ runtime shared libraries (if any)
#
module-add-c++-deps = \
+ $(if $(call strip,$2),$(call ndk_log,Add dependency '$(call strip,$2)' to module '$1'))\
$(eval __ndk_modules.$1.STATIC_LIBRARIES += $(2))\
+ $(if $(call strip,$3),$(call ndk_log,Add dependency '$(call strip,$3)' to module '$1'))\
$(eval __ndk_modules.$1.SHARED_LIBRARIES += $(3))
diff --git a/build/tools/build-gcc.sh b/build/tools/build-gcc.sh
index d73d479..6b0843f 100755
--- a/build/tools/build-gcc.sh
+++ b/build/tools/build-gcc.sh
@@ -233,6 +233,9 @@
# the flags are ignored for older GCC versions.
EXTRA_CONFIG_FLAGS=$EXTRA_CONFIG_FLAGS" --disable-libquadmath --disable-plugin"
+# Enable OpenMP
+EXTRA_CONFIG_FLAGS=$EXTRA_CONFIG_FLAGS" --enable-libgomp"
+
# Enable Gold as default
case "$TOOLCHAIN" in
# Note that only ARM and X86 are supported
@@ -316,6 +319,16 @@
# copy to toolchain path
run copy_directory "$TOOLCHAIN_BUILD_PREFIX" "$TOOLCHAIN_PATH"
+if [ "$MINGW" = "yes" ] ; then
+ # For some reasons, libraries in $ABI_CONFIGURE_TARGET (*) are not installed.
+ # Hack here to copy them over.
+ # (*) FYI: libgcc.a and libgcov.a not installed there in the first place
+ INSTALL_TARGET_LIB_PATH="$BUILD_OUT/host-$ABI_CONFIGURE_BUILD/install/$ABI_CONFIGURE_TARGET/lib"
+ TOOLCHAIN_TARGET_LIB_PATH="$TOOLCHAIN_PATH/$ABI_CONFIGURE_TARGET/lib"
+ (cd "$INSTALL_TARGET_LIB_PATH" &&
+ find . \( -name "*.a" -o -name "*.la" -o -name "*.spec" \) -exec install -D "{}" "$TOOLCHAIN_TARGET_LIB_PATH/{}" \;)
+fi
+
# don't forget to copy the GPL and LGPL license files
run cp -f $TOOLCHAIN_LICENSES/COPYING $TOOLCHAIN_LICENSES/COPYING.LIB $TOOLCHAIN_PATH
diff --git a/build/tools/build-gnu-libstdc++.sh b/build/tools/build-gnu-libstdc++.sh
index 7920be3..f42240e 100755
--- a/build/tools/build-gnu-libstdc++.sh
+++ b/build/tools/build-gnu-libstdc++.sh
@@ -173,7 +173,7 @@
setup_ccache
- export LDFLAGS="-nostdinc -L$SYSROOT/usr/lib -lc $EXTRA_FLAGS"
+ export LDFLAGS="-L$SYSROOT/usr/lib -lc $EXTRA_FLAGS"
if [ "$ABI" = "armeabi-v7a" ]; then
CXXFLAGS=$CXXFLAGS" -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
@@ -204,6 +204,7 @@
--prefix=$INSTALLDIR \
--host=$BUILD_HOST \
$LIBTYPE_FLAGS \
+ --enable-libstdcxx-time \
--disable-symvers \
--disable-multilib \
--disable-nls \
diff --git a/build/tools/build-host-prebuilts.sh b/build/tools/build-host-prebuilts.sh
index f0c578b..9f63e5c 100755
--- a/build/tools/build-host-prebuilts.sh
+++ b/build/tools/build-host-prebuilts.sh
@@ -53,6 +53,10 @@
LLVM_VERSION_LIST=$DEFAULT_LLVM_VERSION_LIST
register_var_option "--llvm-version-list=<vers>" LLVM_VERSION_LIST "List of LLVM release versions"
+CHECK_FLAG=
+do_check_option () { CHECK_FLAG="--check"; }
+register_option "--check" do_check_option "Check host prebuilts"
+
register_try64_option
PROGRAM_PARAMETERS="<toolchain-src-dir>"
@@ -264,7 +268,7 @@
fi
for LLVM_VERSION in $LLVM_VERSION_LIST; do
echo "Building $SYSTEM clang/llvm-$LLVM_VERSION"
- run $BUILDTOOLS/build-llvm.sh "$SRC_DIR" "$NDK_DIR" "llvm-$LLVM_VERSION" $TOOLCHAIN_FLAGS $POLLY_FLAGS
+ run $BUILDTOOLS/build-llvm.sh "$SRC_DIR" "$NDK_DIR" "llvm-$LLVM_VERSION" $TOOLCHAIN_FLAGS $POLLY_FLAGS $CHECK_FLAG
fail_panic "Could not build llvm for $SYSTEM"
done
diff --git a/build/tools/build-llvm.sh b/build/tools/build-llvm.sh
index 2da41ea..44ad805 100755
--- a/build/tools/build-llvm.sh
+++ b/build/tools/build-llvm.sh
@@ -47,9 +47,12 @@
POLLY=no
do_polly_option () { POLLY=yes; }
-
register_option "--with-polly" do_polly_option "Enable Polyhedral optimizations for LLVM"
+CHECK=no
+do_check_option () { CHECK=yes; }
+register_option "--check" do_check_option "Check LLVM"
+
register_jobs_option
register_mingw_option
register_try64_option
@@ -214,7 +217,7 @@
run make -j$NUM_JOBS
fail_panic "Couldn't compile llvm toolchain"
-if [ "$MINGW" != "yes" ] ; then
+if [ "$CHECK" = "yes" -a "$MINGW" != "yes" ] ; then
# run the regression test
dump "Running : llvm toolchain regression test"
cd $LLVM_BUILD_OUT
diff --git a/build/tools/download-toolchain-sources.sh b/build/tools/download-toolchain-sources.sh
index ff6f80c..026d1e6 100755
--- a/build/tools/download-toolchain-sources.sh
+++ b/build/tools/download-toolchain-sources.sh
@@ -259,9 +259,10 @@
SRC_DIR=`cd $SRC_DIR && pwd`
rm -rf $SRC_DIR && mkdir -p $SRC_DIR
fail_panic "Could not create target source directory: $SRC_DIR"
- copy_directory "$TMPDIR" "$SRC_DIR"
cp $SOURCES_LIST $SRC_DIR/SOURCES
- fail_panic "Could not copy downloaded sources to: $SRC_DIR"
+ fail_panic "Could not copy $SOURCES_LIST to $SRC_DIR"
+ mv "$TMPDIR"/* "$SRC_DIR" #copy_directory "$TMPDIR" "$SRC_DIR"
+ fail_panic "Could not move to target source directory: $TMPDIR -> $SRC_DIR"
dump "Toolchain sources downloaded and copied to $SRC_DIR"
fi
diff --git a/build/tools/gen-platforms.sh b/build/tools/gen-platforms.sh
index 3f9d14e..0ced51f 100755
--- a/build/tools/gen-platforms.sh
+++ b/build/tools/gen-platforms.sh
@@ -633,6 +633,9 @@
# Generate shared libraries from symbol files
gen_shared_libraries $ARCH $PLATFORM_SRC/arch-$ARCH/symbols $PLATFORM_DST/arch-$ARCH
+ else
+ # Copy the prebuilt binaries to bootstrap GCC
+ copy_src_directory $PLATFORM_SRC/arch-$ARCH/lib-bootstrap $SYSROOT_DST/lib "$ARCH sysroot libs (boostrap)"
fi
PREV_SYSROOT_DST=$SYSROOT_DST
done
diff --git a/build/tools/prebuilt-common.sh b/build/tools/prebuilt-common.sh
index b882ef7..d363508 100644
--- a/build/tools/prebuilt-common.sh
+++ b/build/tools/prebuilt-common.sh
@@ -917,7 +917,7 @@
ABI_CXXFLAGS_FOR_TARGET="-frtti -fpic"
# Add --disable-fixed-point to disable fixed-point support
# Add --disable-threads for eh_frame handling in a single thread
- ABI_CONFIGURE_EXTRA_FLAGS="$ABI_CONFIGURE_EXTRA_FLAGS --disable-fixed-point --disable-threads"
+ ABI_CONFIGURE_EXTRA_FLAGS="$ABI_CONFIGURE_EXTRA_FLAGS --disable-fixed-point"
;;
* )
echo "Invalid toolchain specified. Expected (arm-linux-androideabi-*|arm-eabi-*|x86-*|mips*)"
diff --git a/tests/device/issue39680-chrono-resolution/jni/Android.mk b/tests/device/issue39680-chrono-resolution/jni/Android.mk
new file mode 100644
index 0000000..8eb988b
--- /dev/null
+++ b/tests/device/issue39680-chrono-resolution/jni/Android.mk
@@ -0,0 +1,8 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := issue39680-chrono-resolution
+LOCAL_SRC_FILES := issue39680-chrono-resolution.cpp
+LOCAL_CFLAGS += -std=gnu++0x
+include $(BUILD_EXECUTABLE)
+
diff --git a/tests/device/issue39680-chrono-resolution/jni/Application.mk b/tests/device/issue39680-chrono-resolution/jni/Application.mk
new file mode 100644
index 0000000..3563119
--- /dev/null
+++ b/tests/device/issue39680-chrono-resolution/jni/Application.mk
@@ -0,0 +1,2 @@
+APP_ABI := all
+APP_STL := gnustl_static
diff --git a/tests/device/issue39680-chrono-resolution/jni/issue39680-chrono-resolution.cpp b/tests/device/issue39680-chrono-resolution/jni/issue39680-chrono-resolution.cpp
new file mode 100644
index 0000000..6d7dbaf
--- /dev/null
+++ b/tests/device/issue39680-chrono-resolution/jni/issue39680-chrono-resolution.cpp
@@ -0,0 +1,51 @@
+#include <iostream>
+#include <chrono>
+#include <ratio>
+
+#if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
+// In GCC 4.6 and below, "steady_clock" is called "monotonic_clock",
+// and "is_steady" is called "is_monotonic"
+namespace std {
+namespace chrono {
+ typedef monotonic_clock steady_clock;
+}
+}
+#define is_steady is_monotonic
+#endif
+
+template <typename C>
+void printClockData (bool &is_high_res, bool &is_steady)
+{
+ using namespace std;
+
+ cout << "- precision: ";
+ // if time unit is less or equal one millisecond
+ typedef typename C::period P;// type of time unit
+ if (ratio_less_equal<P,milli>::value) {
+ // convert to and print as milliseconds
+ typedef typename ratio_multiply<P,kilo>::type TT;
+ cout << fixed << double(TT::num)/TT::den
+ << " milliseconds" << endl;
+ is_high_res = true;
+ }
+ else {
+ // print as seconds
+ cout << fixed << double(P::num)/P::den << " seconds" << endl;
+ is_high_res = false;
+ }
+ cout << "- is_steady: " << boolalpha << C::is_steady << endl;
+ is_steady = C::is_steady;
+}
+
+int main()
+{
+ bool is_high_res1, is_high_res2, is_high_res3, is_steady;
+ std::cout << "system_clock: " << std::endl;
+ printClockData<std::chrono::system_clock>(is_high_res1, is_steady);
+ std::cout << "\nhigh_resolution_clock: " << std::endl;
+ printClockData<std::chrono::high_resolution_clock>(is_high_res2, is_steady);
+ std::cout << "\nsteady_clock: " << std::endl;
+ printClockData<std::chrono::steady_clock>(is_high_res3, is_steady);
+
+ return (is_high_res1 && is_high_res2 && is_high_res3 && is_steady)? 0 : 1;
+}
diff --git a/tests/device/test-openmp/BROKEN_BUILD b/tests/device/test-openmp/BROKEN_BUILD
new file mode 100644
index 0000000..02bef2a
--- /dev/null
+++ b/tests/device/test-openmp/BROKEN_BUILD
@@ -0,0 +1 @@
+clang3.1
\ No newline at end of file
diff --git a/tests/device/test-openmp/jni/Android.mk b/tests/device/test-openmp/jni/Android.mk
new file mode 100644
index 0000000..ed7f548
--- /dev/null
+++ b/tests/device/test-openmp/jni/Android.mk
@@ -0,0 +1,9 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := openmp
+LOCAL_SRC_FILES := openmp.c
+LOCAL_CFLAGS += -fopenmp
+LOCAL_LDFLAGS += -fopenmp
+include $(BUILD_EXECUTABLE)
+
diff --git a/tests/device/test-openmp/jni/Application.mk b/tests/device/test-openmp/jni/Application.mk
new file mode 100644
index 0000000..a252a72
--- /dev/null
+++ b/tests/device/test-openmp/jni/Application.mk
@@ -0,0 +1 @@
+APP_ABI := all
diff --git a/tests/device/test-openmp/jni/openmp.c b/tests/device/test-openmp/jni/openmp.c
new file mode 100644
index 0000000..ed0ed18
--- /dev/null
+++ b/tests/device/test-openmp/jni/openmp.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <omp.h>
+
+int main(int argc, char *argv[])
+{
+ int iam = 0, np = 1;
+
+ if (!getenv("OMP_NUM_THREADS"))
+ omp_set_num_threads(4);
+
+ #pragma omp parallel default(shared) private(iam, np)
+ {
+ #if defined(_OPENMP)
+ np = omp_get_num_threads();
+ iam = omp_get_thread_num();
+ #endif
+ printf("Hello from thread %d out of %d\n", iam, np);
+ }
+
+ return 0;
+}