* 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

Signed-off-by: Martin Jansa <martin.ja...@gmail.com>
---
 meta-oe/recipes-devtools/nodejs/nodejs_18.16.0.bb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_18.16.0.bb 
b/meta-oe/recipes-devtools/nodejs/nodejs_18.16.0.bb
index 06631f27db..3adb51549e 100644
--- a/meta-oe/recipes-devtools/nodejs/nodejs_18.16.0.bb
+++ b/meta-oe/recipes-devtools/nodejs/nodejs_18.16.0.bb
@@ -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}' \
-- 
2.41.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#103633): 
https://lists.openembedded.org/g/openembedded-devel/message/103633
Mute This Topic: https://lists.openembedded.org/mt/99838410/21656
Group Owner: openembedded-devel+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to