Fix libdl dependency on Android and remove librt hack.
authorrmcilroy <rmcilroy@chromium.org>
Tue, 31 Mar 2015 12:08:10 +0000 (05:08 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 31 Mar 2015 12:08:21 +0000 (12:08 +0000)
The libdl library is already included on target builds of Android and needs
to be added to the build command line with a particular order to avoid
undefined references in other libraries. Fix this by only explicitly including
it in host builds and relying on the implicit inclusion on target builds.

Also remove the librt hack which is not longer necessary due to the AOSP build
bot having been removed.

BUG=chromium:469973
LOG=Y

Review URL: https://codereview.chromium.org/1036133005

Cr-Commit-Position: refs/heads/master@{#27535}

BUILD.gn
src/base/platform/condition-variable.cc
src/base/platform/time.cc
src/perf-jit.h
tools/gyp/v8.gyp

index fc0ea8eb6802bfb5e4a94a353d87141128e67f4a..6b102f37a102c1a03734a186106032d001ea4ce7 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1398,17 +1398,15 @@ source_set("v8_libbase") {
   } else if (is_android) {
     defines += [ "CAN_USE_VFP_INSTRUCTIONS" ]
 
-    if (host_os == "mac") {
-      if (current_toolchain == host_toolchain) {
+    if (current_toolchain == host_toolchain) {
+      libs = [ "dl", "rt" ]
+      if (host_os == "mac") {
         sources += [ "src/base/platform/platform-macos.cc" ]
       } else {
         sources += [ "src/base/platform/platform-linux.cc" ]
       }
     } else {
       sources += [ "src/base/platform/platform-linux.cc" ]
-      if (current_toolchain == host_toolchain) {
-        defines += [ "V8_LIBRT_NOT_AVAILABLE" ]
-      }
     }
   } else if (is_mac) {
     sources += [ "src/base/platform/platform-macos.cc" ]
index b91025a3dbb86b9e242221695a071d1c8fef7c9b..982497fea449959c54d2ceea5ed0ee70809a7785 100644 (file)
@@ -15,11 +15,8 @@ namespace base {
 #if V8_OS_POSIX
 
 ConditionVariable::ConditionVariable() {
-  // TODO(bmeurer): The test for V8_LIBRT_NOT_AVAILABLE is a temporary
-  // hack to support cross-compiling Chrome for Android in AOSP. Remove
-  // this once AOSP is fixed.
 #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \
-     (V8_OS_LINUX && V8_LIBC_GLIBC)) && !V8_LIBRT_NOT_AVAILABLE
+     (V8_OS_LINUX && V8_LIBC_GLIBC))
   // On Free/Net/OpenBSD and Linux with glibc we can change the time
   // source for pthread_cond_timedwait() to use the monotonic clock.
   pthread_condattr_t attr;
@@ -81,11 +78,8 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) {
   result = pthread_cond_timedwait_relative_np(
       &native_handle_, &mutex->native_handle(), &ts);
 #else
-  // TODO(bmeurer): The test for V8_LIBRT_NOT_AVAILABLE is a temporary
-  // hack to support cross-compiling Chrome for Android in AOSP. Remove
-  // this once AOSP is fixed.
 #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \
-     (V8_OS_LINUX && V8_LIBC_GLIBC)) && !V8_LIBRT_NOT_AVAILABLE
+     (V8_OS_LINUX && V8_LIBC_GLIBC))
   // On Free/Net/OpenBSD and Linux with glibc we can change the time
   // source for pthread_cond_timedwait() to use the monotonic clock.
   result = clock_gettime(CLOCK_MONOTONIC, &ts);
index 6734218e5071a94180cfa007569100407589a6c3..e4480e11f58b5d3af3590bead49deb851b21eff7 100644 (file)
@@ -548,15 +548,6 @@ TimeTicks TimeTicks::HighResolutionNow() {
            info.numer / info.denom);
 #elif V8_OS_SOLARIS
   ticks = (gethrtime() / Time::kNanosecondsPerMicrosecond);
-#elif V8_LIBRT_NOT_AVAILABLE
-  // TODO(bmeurer): This is a temporary hack to support cross-compiling
-  // Chrome for Android in AOSP. Remove this once AOSP is fixed, also
-  // cleanup the tools/gyp/v8.gyp file.
-  struct timeval tv;
-  int result = gettimeofday(&tv, NULL);
-  DCHECK_EQ(0, result);
-  USE(result);
-  ticks = (tv.tv_sec * Time::kMicrosecondsPerSecond + tv.tv_usec);
 #elif V8_OS_POSIX
   struct timespec ts;
   int result = clock_gettime(CLOCK_MONOTONIC, &ts);
@@ -576,7 +567,7 @@ bool TimeTicks::IsHighResolutionClockWorking() {
 }
 
 
-#if V8_OS_LINUX && !V8_LIBRT_NOT_AVAILABLE
+#if V8_OS_LINUX
 
 class KernelTimestampClock {
  public:
@@ -632,7 +623,7 @@ class KernelTimestampClock {
   bool Available() { return false; }
 };
 
-#endif  // V8_OS_LINUX && !V8_LIBRT_NOT_AVAILABLE
+#endif  // V8_OS_LINUX
 
 static LazyStaticInstance<KernelTimestampClock,
                           DefaultConstructTrait<KernelTimestampClock>,
index 7872910b29595c4061ad3c77f29d728c201a3102..e1436cd9cb9f5e9d8d7a2f2cc562b15c0a770f11 100644 (file)
 namespace v8 {
 namespace internal {
 
-// TODO(jarin) For now, we disable perf integration on Android because of a
-// build problem - when building the snapshot with AOSP, librt is not
-// available, so we cannot use the clock_gettime function. To fix this, we
-// should thread through the V8_LIBRT_NOT_AVAILABLE flag here and only disable
-// the perf integration when this flag is present (the perf integration is not
-// needed when generating snapshot, so it is fine to ifdef it away).
-
 #if V8_OS_LINUX
 
 // Linux perf tool logging support
index d764b2fcf58d77c36b77b30cb96e0cb73a39e622..853d99ac97b9f1a2a6ef0edbaab96eb40901e738 100644 (file)
               '../../src/base/platform/platform-posix.cc'
             ],
             'link_settings': {
-              'libraries': [
-                '-ldl'
+              'target_conditions': [
+                ['_toolset=="host"', {
+                  # Only include libdl and librt on host builds because they
+                  # are included by default on Android target builds, and we
+                  # don't want to re-include them here since this will change
+                  # library order and break (see crbug.com/469973).
+                  'libraries': [
+                    '-ldl',
+                    '-lrt'
+                  ]
+                }]
               ]
             },
             'conditions': [
                   }],
                 ],
               }, {
-                # TODO(bmeurer): What we really want here, is this:
-                #
-                # 'link_settings': {
-                #   'target_conditions': [
-                #     ['_toolset=="host"', {
-                #       'libraries': [
-                #         '-lrt'
-                #       ]
-                #     }]
-                #   ]
-                # },
-                #
-                # but we can't do this right now, as the AOSP does not support
-                # linking against the host librt, so we need to work around this
-                # for now, using the following hack (see platform/time.cc):
-                'target_conditions': [
-                  ['_toolset=="host"', {
-                    'defines': [
-                      'V8_LIBRT_NOT_AVAILABLE=1',
-                    ],
-                  }],
-                ],
                 'sources': [
                   '../../src/base/platform/platform-linux.cc'
                 ]