nodejs: use PIE for host binaries
PATCH 1/3 nodejs: use PIE for host binaries
* mksnapshot is built as host binary, but then gets executed under qemu-arm, because for 32bit target we need to run 32bit mksnapshot even when building on x86-64 host
* unfortunately since upgrade to qemu-8 in:
https://git.openembedded.org/openembedded-core/commit/?id=fe8125565af07b73f9b29db2188ecb6e884bcc70
the mksnapshot fails to execute with:
LD_LIBRARY_PATH=/OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/node-v18.16.0/out/Release/lib.host:/OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/node-v18.16.0/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/v8_gypfiles; mkdir -p /OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/node-v18.16.0/out/Release/obj.target/v8_snapshot/geni; "/OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/node-v18.16.0/out/Release/v8-qemu-wrapper.sh" "/OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/node-v18.16.0/out/Release/mksnapshot" --turbo_instruction_scheduling "--target_os=linux" "--target_arch=arm" --startup_src "/OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/node-v18.16.0/out/Release/obj.target/v8_snapshot/geni/snapshot.cc" --embedded_variant Default --embedded_src "/OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/node-v18.16.0/out/Release/obj.target/v8_snapshot/geni/embedded.S" --no-native-code-counters
#
# Fatal process OOM in Failed to reserve virtual memory for CodeRange #
/OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/node-v18.16.0/out/Release/v8-qemu-wrapper.sh: line 7: 669880 Trace/breakpoint trap (core dumped) PSEUDO_UNLOAD=1 qemu-arm -r 5.15 -L /OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/recipe-sysroot -E LD_LIBRARY_PATH=/OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/recipe-sysroot/usr/lib:/OE/build/oe-core/tmp-glibc/work/cortexa8t2hf-neon-oe-linux-gnueabi/nodejs/18.16.0-r0/recipe-sysroot/lib "$@"
It was failing only in some of my builds first, in the end I was able to narrow the difference between the build where it fails and where it doesn't fail to
require conf/distro/include/security_flags.inc then
GCCPIE = "--enable-default-pie"
and lastly this PIE enabled just for nodejs to work around this issue without downgrading qemu-native.
* using -strace with qemu doesn't help much, just confirms that the OOM error message is really caused by failed mmap2:
--- SIGPROF {si_signo=SIGPROF, si_code=SI_TKILL, si_pid=2908258, si_uid=1026} --- clock_gettime64(CLOCK_MONOTONIC,0x407ef640) = 0 ({tv_sec=20187,tv_nsec=678404286}) rt_sigreturn(0x407efb70) = -1 errno=513 (Successful exit from sigreturn) write(3,0x141e538,28) = 28
write(3,0x141e538,28) = 28
write(3,0x141e538,32) = 32
mmap2(0x0097a000,33554432,PROT_NONE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE,-1,0) = -1 errno=12 (Cannot allocate memory) mmap2(0x0097a000,33554432,PROT_NONE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE,-1,0) = -1 errno=12 (Cannot allocate memory)
* diffoscope on this 1.7G binary didn't really help as it got killed by OOMK after a while
Out of memory: Killed process 1136999 (diffoscope) total-vm:404300108kB, anon-rss:122594688kB, file-rss:512kB, shmem-rss:0kB, UID:1026 pgtables:764240kB oom_score_adj:0
--- meta-oe/recipes-devtools/nodejs/nodejs_18.16.0.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta-oe/recipes-devtools/nodejs/nodejs_18.16.0.bb +2 -2
@@ -79,9 +79,9 @@ PACKAGECONFIG[zlib] = "--shared-zlib,,zlib" # and we need to use the right flags during host compile, # too. EXTRA_OEMAKE = "\ - CC.host='${CC}' \ + CC.host='${CC} -pie -fPIE' \ CFLAGS.host='${CPPFLAGS} ${CFLAGS}' \ - CXX.host='${CXX}' \ + CXX.host='${CXX} -pie -fPIE' \ CXXFLAGS.host='${CPPFLAGS} ${CXXFLAGS}' \ LDFLAGS.host='${LDFLAGS}' \ AR.host='${AR}' \
Signature · 1 line
2.41.0
PATCH 2/3 gupnp: backport a fix not to use deprecated xmlReadMemory
* deprecated since libxml2-2.11 upgraded in oe-core in:
https://git.openembedded.org/openembedded-core/commit/?id=24860598ba8557ea3a145f249938ea411f1ef1d8
* fixes:../gupnp-1.4.1/libgupnp/gupnp-service-info.c: In function 'got_scpd_url':../gupnp-1.4.1/libgupnp/gupnp-service-info.c:595:17: error: 'xmlRecoverMemory' is deprecated [-Werror=deprecated-declarations]
595 | scpd = xmlRecoverMemory (msg->response_body->data,
| ^~~~
In file included from /OE/build/luneos-nanbield/webos-ports/tmp-glibc/work/cortexa8t2hf-neon-webos-linux-gnueabi/gupnp/1.4.1-r0/recipe-sysroot/usr/include/libxml2/libxml/globals.h:18,
from /OE/build/luneos-nanbield/webos-ports/tmp-glibc/work/cortexa8t2hf-neon-webos-linux-gnueabi/gupnp/1.4.1-r0/recipe-sysroot/usr/include/libxml2/libxml/threads.h:35,
from /OE/build/luneos-nanbield/webos-ports/tmp-glibc/work/cortexa8t2hf-neon-webos-linux-gnueabi/gupnp/1.4.1-r0/recipe-sysroot/usr/include/libxml2/libxml/xmlmemory.h:222,
from /OE/build/luneos-nanbield/webos-ports/tmp-glibc/work/cortexa8t2hf-neon-webos-linux-gnueabi/gupnp/1.4.1-r0/recipe-sysroot/usr/include/libxml2/libxml/tree.h:1310,
from ../gupnp-1.4.1/libgupnp/gupnp-service-introspection-private.h:12,
from ../gupnp-1.4.1/libgupnp/gupnp-service-info.c:26:
/OE/build/luneos-nanbield/webos-ports/tmp-glibc/work/cortexa8t2hf-neon-webos-linux-gnueabi/gupnp/1.4.1-r0/recipe-sysroot/usr/include/libxml2/libxml/parser.h:872:17: note: declared here
872 | xmlRecoverMemory (const char *buffer,
| ^~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
--- .../0001-all-Drop-xmlRecoverMemory.patch | 107 ++++++++++++++++++ .../recipes-connectivity/gupnp/gupnp_1.4.1.bb | 4 +- 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 meta-multimedia/recipes-connectivity/gupnp/gupnp/0001-all-Drop-xmlRecoverMemory.patch
meta-multimedia/recipes-connectivity/gupnp/gupnp/0001-all-Drop-xmlRecoverMemory.patch new file +107 -0
@@ -0,0 +1,107 @@ +From 46f13d9929c81ec2340a1a5d48f596b1892c5a81 Mon Sep 17 00:00:00 2001 +From: Jens Georg <[email protected]> +Date: Thu, 4 May 2023 19:14:29 +0200 +Subject: [PATCH] all: Drop xmlRecoverMemory + +use xmlReadMemory, also use NONET flat + +Signed-off-by: Martin Jansa <[email protected]> +Upstream-Status: Backport [https://github.com/GNOME/gupnp/commit/80e68995b745a5900eaaa1d0c424d3a9d354e42d] +--- + libgupnp/gupnp-control-point.c | 7 +++++-- + libgupnp/gupnp-service-info.c | 7 +++++-- + libgupnp/gupnp-service-proxy-action.c | 7 +++++-- + libgupnp/gupnp-service-proxy.c | 7 +++++-- + libgupnp/gupnp-service.c | 7 +++++-- + 5 files changed, 25 insertions(+), 10 deletions(-) + +diff --git a/libgupnp/gupnp-control-point.c b/libgupnp/gupnp-control-point.c +index dc04732..99ebda5 100644 +--- a/libgupnp/gupnp-control-point.c ++++ b/libgupnp/gupnp-control-point.c +@@ -608,8 +608,11 @@ got_description_url (SoupSession *session, + xmlDoc *xml_doc; + + /* Parse response */ +- xml_doc = xmlRecoverMemory (msg->response_body->data, +- msg->response_body->length); ++ xml_doc = xmlReadMemory (msg->response_body->data, ++ msg->response_body->length, ++ NULL, ++ NULL, ++ XML_PARSE_NONET | XML_PARSE_RECOVER); + if (xml_doc) { + doc = gupnp_xml_doc_new (xml_doc); + +diff --git a/libgupnp/gupnp-service-info.c b/libgupnp/gupnp-service-info.c +index 9a9f4de..d468801 100644 +--- a/libgupnp/gupnp-service-info.c ++++ b/libgupnp/gupnp-service-info.c +@@ -592,8 +592,11 @@ got_scpd_url (G_GNUC_UNUSED SoupSession *session, + if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { + xmlDoc *scpd; + +- scpd = xmlRecoverMemory (msg->response_body->data, +- msg->response_body->length); ++ scpd = xmlReadMemory (msg->response_body->data, ++ msg->response_body->length, ++ NULL, ++ NULL, ++ XML_PARSE_NONET | XML_PARSE_RECOVER); + if (scpd) { + introspection = gupnp_service_introspection_new (scpd); + +diff --git a/libgupnp/gupnp-service-proxy-action.c b/libgupnp/gupnp-service-proxy-action.c +index 4d9336c..ef8a808 100644 +--- a/libgupnp/gupnp-service-proxy-action.c ++++ b/libgupnp/gupnp-service-proxy-action.c +@@ -86,8 +86,11 @@ check_action_response (G_GNUC_UNUSED GUPnPServiceProxy *proxy, + } + + /* Parse response */ +- response = xmlRecoverMemory (action->msg->response_body->data, +- action->msg->response_body->length); ++ response = xmlReadMemory (action->msg->response_body->data, ++ action->msg->response_body->length, ++ NULL, ++ NULL, ++ XML_PARSE_NONET | XML_PARSE_RECOVER); + + if (!response) { + if (action->msg->status_code == SOUP_STATUS_OK) { +diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c +index 25d5ef6..af2fd46 100644 +--- a/libgupnp/gupnp-service-proxy.c ++++ b/libgupnp/gupnp-service-proxy.c +@@ -1560,8 +1560,11 @@ server_handler (G_GNUC_UNUSED SoupServer *soup_server, + } + + /* Parse the actual XML message content */ +- doc = xmlRecoverMemory (msg->request_body->data, +- msg->request_body->length); ++ doc = xmlReadMemory (msg->request_body->data, ++ msg->request_body->length, ++ NULL, ++ NULL, ++ XML_PARSE_NONET | XML_PARSE_RECOVER); + if (doc == NULL) { + /* Failed */ + g_warning ("Failed to parse NOTIFY message body"); +diff --git a/libgupnp/gupnp-service.c b/libgupnp/gupnp-service.c +index 67b3d43..0ebfb26 100644 +--- a/libgupnp/gupnp-service.c ++++ b/libgupnp/gupnp-service.c +@@ -985,8 +985,11 @@ control_server_handler (SoupServer *server, + *end = '\0'; + + /* Parse action_node */ +- doc = xmlRecoverMemory (msg->request_body->data, +- msg->request_body->length); ++ doc = xmlReadMemory (msg->request_body->data, ++ msg->request_body->length, ++ NULL, ++ NULL, ++ XML_PARSE_NONET | XML_PARSE_RECOVER); + if (doc == NULL) { + soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); +
meta-multimedia/recipes-connectivity/gupnp/gupnp_1.4.1.bb +3 -1
@@ -7,7 +7,9 @@ DEPENDS = "e2fsprogs gssdp libsoup-2.4 libxml2" inherit meson pkgconfig vala gobject-introspection -SRC_URI = "${GNOME_MIRROR}/${BPN}/1.4/${BPN}-${PV}.tar.xz" +SRC_URI = "${GNOME_MIRROR}/${BPN}/1.4/${BPN}-${PV}.tar.xz \ + file://0001-all-Drop-xmlRecoverMemory.patch \ +" SRC_URI[sha256sum] = "899196b5e66f03b8e25f046a7a658cd2a6851becb83f2d55345ab3281655dc0c" SYSROOT_PREPROCESS_FUNCS += "gupnp_sysroot_preprocess"
Signature · 1 line
2.41.0
PATCH 3/3 pidgin-sipe: allow to build with libxml2-2.11
In reply to Martin Jansa* deprecated since libxml2-2.11 upgraded in oe-core in:
https://git.openembedded.org/openembedded-core/commit/?id=24860598ba8557ea3a145f249938ea411f1ef1d8
* avoids:
| ../../../pidgin-sipe-1.25.0/src/core/sipe-xml.c: In function 'sipe_xml_parse': | ../../../pidgin-sipe-1.25.0/src/core/sipe-xml.c:220:17: error: 'xmlSAXUserParseMemory' is deprecated [-Werror=deprecated-declarations] | 220 | if (xmlSAXUserParseMemory(&parser, pd, string, length)) | | ^~
--- meta-oe/recipes-support/pidgin/pidgin-sipe_1.25.0.bb | 2 ++ 1 file changed, 2 insertions(+)
meta-oe/recipes-support/pidgin/pidgin-sipe_1.25.0.bb +2 -0
@@ -35,3 +35,5 @@ FILES:${PN} += " \ ${datadir}/appdata \ ${datadir}/metainfo \ " + +CFLAGS = "-Wno-error=deprecated-declarations"
Signature · 1 line
2.41.0