Commit 11c4e2f2 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

Fix libdl dependency on Android and remove librt hack.

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}
parent df40d51e
...@@ -1398,17 +1398,15 @@ source_set("v8_libbase") { ...@@ -1398,17 +1398,15 @@ source_set("v8_libbase") {
} else if (is_android) { } else if (is_android) {
defines += [ "CAN_USE_VFP_INSTRUCTIONS" ] 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" ] sources += [ "src/base/platform/platform-macos.cc" ]
} else { } else {
sources += [ "src/base/platform/platform-linux.cc" ] sources += [ "src/base/platform/platform-linux.cc" ]
} }
} else { } else {
sources += [ "src/base/platform/platform-linux.cc" ] sources += [ "src/base/platform/platform-linux.cc" ]
if (current_toolchain == host_toolchain) {
defines += [ "V8_LIBRT_NOT_AVAILABLE" ]
}
} }
} else if (is_mac) { } else if (is_mac) {
sources += [ "src/base/platform/platform-macos.cc" ] sources += [ "src/base/platform/platform-macos.cc" ]
......
...@@ -15,11 +15,8 @@ namespace base { ...@@ -15,11 +15,8 @@ namespace base {
#if V8_OS_POSIX #if V8_OS_POSIX
ConditionVariable::ConditionVariable() { 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 || \ #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 // On Free/Net/OpenBSD and Linux with glibc we can change the time
// source for pthread_cond_timedwait() to use the monotonic clock. // source for pthread_cond_timedwait() to use the monotonic clock.
pthread_condattr_t attr; pthread_condattr_t attr;
...@@ -81,11 +78,8 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { ...@@ -81,11 +78,8 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) {
result = pthread_cond_timedwait_relative_np( result = pthread_cond_timedwait_relative_np(
&native_handle_, &mutex->native_handle(), &ts); &native_handle_, &mutex->native_handle(), &ts);
#else #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 || \ #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 // On Free/Net/OpenBSD and Linux with glibc we can change the time
// source for pthread_cond_timedwait() to use the monotonic clock. // source for pthread_cond_timedwait() to use the monotonic clock.
result = clock_gettime(CLOCK_MONOTONIC, &ts); result = clock_gettime(CLOCK_MONOTONIC, &ts);
......
...@@ -548,15 +548,6 @@ TimeTicks TimeTicks::HighResolutionNow() { ...@@ -548,15 +548,6 @@ TimeTicks TimeTicks::HighResolutionNow() {
info.numer / info.denom); info.numer / info.denom);
#elif V8_OS_SOLARIS #elif V8_OS_SOLARIS
ticks = (gethrtime() / Time::kNanosecondsPerMicrosecond); 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 #elif V8_OS_POSIX
struct timespec ts; struct timespec ts;
int result = clock_gettime(CLOCK_MONOTONIC, &ts); int result = clock_gettime(CLOCK_MONOTONIC, &ts);
...@@ -576,7 +567,7 @@ bool TimeTicks::IsHighResolutionClockWorking() { ...@@ -576,7 +567,7 @@ bool TimeTicks::IsHighResolutionClockWorking() {
} }
#if V8_OS_LINUX && !V8_LIBRT_NOT_AVAILABLE #if V8_OS_LINUX
class KernelTimestampClock { class KernelTimestampClock {
public: public:
...@@ -632,7 +623,7 @@ class KernelTimestampClock { ...@@ -632,7 +623,7 @@ class KernelTimestampClock {
bool Available() { return false; } bool Available() { return false; }
}; };
#endif // V8_OS_LINUX && !V8_LIBRT_NOT_AVAILABLE #endif // V8_OS_LINUX
static LazyStaticInstance<KernelTimestampClock, static LazyStaticInstance<KernelTimestampClock,
DefaultConstructTrait<KernelTimestampClock>, DefaultConstructTrait<KernelTimestampClock>,
......
...@@ -33,13 +33,6 @@ ...@@ -33,13 +33,6 @@
namespace v8 { namespace v8 {
namespace internal { 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 #if V8_OS_LINUX
// Linux perf tool logging support // Linux perf tool logging support
......
...@@ -1407,8 +1407,17 @@ ...@@ -1407,8 +1407,17 @@
'../../src/base/platform/platform-posix.cc' '../../src/base/platform/platform-posix.cc'
], ],
'link_settings': { 'link_settings': {
'libraries': [ 'target_conditions': [
'-ldl' ['_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': [ 'conditions': [
...@@ -1425,28 +1434,6 @@ ...@@ -1425,28 +1434,6 @@
}], }],
], ],
}, { }, {
# 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': [ 'sources': [
'../../src/base/platform/platform-linux.cc' '../../src/base/platform/platform-linux.cc'
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment