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

Fixes two build failures when cross-compiling LLVM for QNX
(aarch64-unknown-nto-qnx8.0.0).

gcc `-Wstringop-overread` false-positive in `AArch64InstructionSelector.cpp`:  
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]
```

Replacing the constructor-then-move with `assign()` fills the already-live object in place,
which GCC can analyze correctly.

### 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.
Mirrors the existing `target_link_libraries` pattern already present for SunOS and Haiku.

Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Diksha authored and GitHub committed 2026-06-29 20:39:00 +02:00
1 parent 2a711f6cc2
commit debf392ce8
2 files changed
+5 -1

No files matched your search

@@ -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.
+4
View File
@@ -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()