[llvm] [AArch64][llvm-jitlink] Fix two QNX cross-compile build failures (PR #206290)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 27 15:39:09 PDT 2026


https://github.com/diksha updated https://github.com/llvm/llvm-project/pull/206290

>From 4e7aa746bdd60201658cddf0c23025dc757f5cd7 Mon Sep 17 00:00:00 2001
From: Diksha Gohlyan <dgohlyan at nvidia.com>
Date: Sat, 27 Jun 2026 15:30:13 -0700
Subject: [PATCH] [AArch64][llvm-jitlink] Fix two QNX cross-compile build
 failures

1. AArch64InstructionSelector: fix GCC -Wstringop-overread false positive

GCC's static analysis misreads the SmallVector fill constructor in
selectUnmergeValues() as potentially reading NumInsertRegs*sizeof(Register)
bytes from the 16-byte inline buffer of SmallVector<Register, 4>, emitting:

  warning: reading between 20 and 17179869180 bytes from a region of size 16
  [-Wstringop-overread]

This is a false positive: SmallVector heap-allocates when the inline buffer
is exceeded. Replace the constructor-then-move with assign(), which fills
the already-live object in place and avoids the false positive.

No functional change.

2. llvm-jitlink: link against libsocket on QNX

On QNX, POSIX socket functions (getaddrinfo, socket, connect, freeaddrinfo,
gai_strerror) live in libsocket rather than libc. Without it the QNX
cross-compile linker fails with undefined references in Session::Create().
Mirrors the existing pattern for SunOS and Haiku.

Assisted-by: Claude Sonnet 4.6 <noreply at anthropic.com>
---
 llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp | 2 +-
 llvm/tools/llvm-jitlink/CMakeLists.txt                       | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 4b10faefea877..1e38849d3136e 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -4123,7 +4123,7 @@ bool AArch64InstructionSelector::selectUnmergeValues(MachineInstr &I,
   // directly. Otherwise, we need to do a bit of setup with some subregister
   // inserts.
   if (NarrowTy.getSizeInBits() * NumElts == 128) {
-    InsertRegs = SmallVector<Register, 4>(NumInsertRegs, SrcReg);
+    InsertRegs.assign(NumInsertRegs, SrcReg);
   } else {
     // No. We have to perform subregister inserts. For each insert, create an
     // implicit def and a subregister insert, and save the register we create.
diff --git a/llvm/tools/llvm-jitlink/CMakeLists.txt b/llvm/tools/llvm-jitlink/CMakeLists.txt
index 19e3edaf63d86..ae103a1f1769f 100644
--- a/llvm/tools/llvm-jitlink/CMakeLists.txt
+++ b/llvm/tools/llvm-jitlink/CMakeLists.txt
@@ -37,3 +37,7 @@ endif()
 if("${CMAKE_SYSTEM_NAME}" MATCHES "SunOS")
   target_link_libraries(llvm-jitlink PRIVATE socket)
 endif()
+
+if("${CMAKE_SYSTEM_NAME}" MATCHES "QNX")
+  target_link_libraries(llvm-jitlink PRIVATE socket)
+endif()



More information about the llvm-commits mailing list