Skip to content

Commit 94b082e

Browse files
committed
Comment out MemoryFootprintLinux directly to prevent build break on NDK API < 18
Summary: getline() only existed after NDK API 18, there is a compile error to support mininal API 16. As MemoryFootprint does not being used in JSC, comment out the implementation directly to prevent build break.
1 parent 2b8b43a commit 94b082e

File tree

2 files changed

+17
-31
lines changed

2 files changed

+17
-31
lines changed

patches/jsc.patch

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -292,39 +292,24 @@ diff -aur target-org/webkit/Source/JavaScriptCore/CMakeLists.txt target/webkit/S
292292
+add_definitions(-DJSC_VERSION="${JSC_VERSION}")
293293

294294
diff -aur target-org/webkit/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp target/webkit/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp
295-
--- target-org/webkit/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp 2018-08-24 16:08:22.000000000 +0800
296-
+++ target/webkit/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp 2018-11-07 22:59:05.000000000 +0800
297-
@@ -38,6 +38,30 @@
298-
#if OS(LINUX)
299-
static const Seconds s_memoryFootprintUpdateInterval = 1_s;
295+
--- target-org/webkit/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp 2018-11-11 23:05:48.000000000 +0800
296+
+++ target/webkit/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp 2018-11-12 23:39:22.000000000 +0800
297+
@@ -23,6 +23,10 @@
298+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
299+
*/
300300

301-
+#if defined(__ANDROID__) && __ANDROID_API__ < 18
302-
+//
303-
+// The POSIX.1 C getline isn't exported until API 18 in NDK.
304-
+// As the getline() used to read content from /proc/self/smaps,
305-
+// the content fortunately are plain text and lines are not too long.
306-
+// Here to simply use fgets() as fallback.
307-
+// Some differences further:
308-
+// 1. Line buffer is fixed 512 bytes.
309-
+// 2. Return 1 if succeed.
310-
+// This is only for forEachLine() use.
311-
+// Just don't want to do strlen() calculating length again.
312-
+//
313-
+static ssize_t getline(char** linep, size_t* linecapp, FILE* stream) {
314-
+ int fixedBufferSize = 512;
315-
+ if (*linep == nullptr) {
316-
+ *linep = reinterpret_cast<char*>(malloc(fixedBufferSize));
317-
+ }
318-
+ if (fgets(*linep, fixedBufferSize, stream) == nullptr)
319-
+ return -1;
301+
+// CUSTOMIZE_REACT_NATIVE: getline() does not implemented until Android NDK API 18.
302+
+// Since MemoryFootprint does not being used in JSC, comment out to prevent build break.
303+
+#if !defined(CUSTOMIZE_REACT_NATIVE)
320304
+
321-
+ return 1;
322-
+}
323-
+#endif
324-
+
325-
template<typename Functor>
326-
static void forEachLine(FILE* file, Functor functor)
327-
{
305+
#include "config.h"
306+
#include "MemoryFootprint.h"
307+
308+
@@ -107,3 +111,4 @@
309+
}
310+
311+
}
312+
+#endif // !defined(CUSTOMIZE_REACT_NATIVE)
328313
diff -aur target-org/webkit/Source/JavaScriptCore/Sources.txt target/webkit/Source/JavaScriptCore/Sources.txt
329314
--- target-org/webkit/Source/JavaScriptCore/Sources.txt 2018-11-11 23:05:40.000000000 +0800
330315
+++ target/webkit/Source/JavaScriptCore/Sources.txt 2018-11-12 00:03:26.000000000 +0800

scripts/compile/common.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ COMMON_CFLAGS=" \
141141
-fPIC \
142142
-fvisibility=hidden \
143143
-DNDEBUG \
144+
-DCUSTOMIZE_REACT_NATIVE \
144145
$SWITCH_COMMON_CFLAGS_INTL \
145146
"
146147

0 commit comments

Comments
 (0)