[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:14:50 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: Diksha (diksha)
<details>
<summary>Changes</summary>
## Summary
Fixes two build failures when cross-compiling LLVM for QNX (aarch64-unknown-nto-qnx8.0.0).
### 1. `AArch64InstructionSelector.cpp` — 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.
Replacing the constructor-then-move with `assign()` fills the already-live object in place,
which GCC can analyze correctly.
**No functional change.**
### 2. `llvm-jitlink` — undefined references to socket functions 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 `llvm::Session::Create()`:
```
undefined reference to `getaddrinfo'
undefined reference to `socket'
undefined reference to `connect'
undefined reference to `freeaddrinfo'
undefined reference to `gai_strerror'
```
Mirrors the existing `target_link_libraries` pattern already present for SunOS and Haiku.
---
Full diff: https://github.com/llvm/llvm-project/pull/206290.diff
2 Files Affected:
- (modified) llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp (+1-1)
- (modified) llvm/tools/llvm-jitlink/CMakeLists.txt (+4)
``````````diff
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 1a6749b9e5c0c..62c78acfc813b 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -4104,7 +4104,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()
``````````
</details>
https://github.com/llvm/llvm-project/pull/206290
More information about the llvm-commits
mailing list