add QNX qcc/q++ support - #16018
Conversation
bonzini
left a comment
There was a problem hiding this comment.
Setting aside the question of AI generated changes, at least the code isn't as horrible as for other AI usage for meson development.
The changes to support the qnx runtime looks good, as to the compiler why would you choose to subject yourself to this brokenness? Can you use gcc/g++ and call it a day? If so, I don't see the reason to support qcc/q++ in Meson.
|
Following up on my review comment, I've copied the contents of qcc-support.md here for completeness. Added support for the QNX qcc/q++ compiler driverMeson can now detect and use This file is a compendium of the QNX/qcc-specific adaptations across the Driver architecture qcc (C) and q++ (C++) are QNX SDP's own compiler drivers: they parse the Consequence: flags implemented by cc1/cc1plus/cpp itself (
Detection (
Dependency-file generation
Two caveats found in the process:
Preprocess-only output
Link-time optimization Plain LTO ( ThinLTO's incremental cache is the one part that's broken: Alternate linker selection
[binaries]
c_ld = 'lld'
Coverage instrumentation
Runtime auto-linking gaps (OpenMP, PGO, sanitizers) Real gcc's driver auto-links a matching runtime library whenever
Default include directories
Sanity-check command construction
Sanity-check licensing hint
. ~/qnx710/qnxsdp-env.shThe exact path is SDP-version- and install-location-dependent (e.g.
C++20 named modules (q++ only, unfixed) On SDP 8.0 (gcc 12.2.0 backend), q++'s driver silently no-ops on a SDP 7.1 (gcc 8.3.0 backend) is worse, not just older: q++'s cc1plus Threading ( Not handled in
This also covers non-GCC-family compilers and non-qcc/q++ toolchains Symbol extraction ( QNX ships real GNU binutils ( JNI dependency (
Cross-compiling for QNX Point a cross file's [binaries]
c = ['qcc', '-Vgcc_ntoaarch64le']
cpp = ['q++', '-Vgcc_ntoaarch64le']
[host_machine]
system = 'qnx'
cpu_family = 'aarch64'
cpu = 'aarch64'
endian = 'little' |
The answer is complicated. As you may know, QNX OS is a commercial Real-Time Operating System widely used in the automotive industry. For non-commercial purposes, QNX offers free licenses and the QNX Developer Desktop, which includes the Clang compiler for native compilation. The qcc compiler is the official QNX frontend for the C compiler, and it is the only way to cross-compile software for QNX safety-certified systems. Unfortunately, Meson does not support unknown compilers, which is why I am kindly asking you to add support for it. |
Ok, so that is the answer. |
|
I've addressed all review comments, pushed the changes, and resolved the corresponding discussion threads. |
|
Hi, please rebase and ensure that CI is green, especially with respect to the static checking jobs (flake8, mypy, pylint) |
b40cc04 to
d24c7c1
Compare
QNX: handle -pthread flag on the platform level QNX: add QNX support to symbolextractor (self-hosted optimization) JNI: add QNX OS support
- Remove technical details provided in the PR - Provide an example of a cross file - List known issues
… for linker detection
d24c7c1 to
2839021
Compare
Hi, |
Summary
Adds a new
qcc/q++compiler mixin (compiler id: qcc) so Meson can detectand use the QNX SDP's C/C++ compiler drivers, along with platform-level QNX
adaptations throughout the codebase.
https://qnx.software/en/developers/get-started/qnx-everywhere
https://www.qnx.com/developers/docs/qnxeverywhere/index.html
https://www.qnx.com/developers/docs/8.0/com.qnx.doc.neutrino.utilities/topic/q/qcc.html
Verified end-to-end against real QNX SDP installations, including:
What's New
Compiler support
Introduces
QccCCompiler/QccCPPCompiler(
compilers/c.py,compilers/cpp.py), which mix in the newQccCompiler(compilers/mixins/qcc.py) ahead ofGnuCCompiler/GnuCPPCompiler.qcc/q++invoke the underlyingcc1/cc1plusbackends directly rather thanwrapping a
gcc/g++driver. As a result, mostcc1-level flags behaveidentically to GCC (
-c,-I,-D,-O,-std=,-f*,-m*, LTO, etc.).Only driver-level behavior required Meson-specific handling.
Detection
qccrejects-Wl,--versionwithout an input file.qcc/q++.Dependency files
-M/-MDconflict withqccdriver semantics.get_dependency_gen_args()now routes through-Wc,passthrough.qcccc1crash caused by adjacent-MD/-MF.Preprocessor output
qccredirects-E -Poutput to a file instead of stdout.-Wp,-P, which also fixesget_define()andhas_define().ThinLTO
qcc'scc1.EnvironmentExceptioninstead of failing later.Alternate linkers
c_ld/cpp_ldnow raiseMesonException.qccprovides no mechanism for selecting alternate linkers.Coverage
Uses:
instead of the undocumented
--coverage.OpenMP, PGO, and sanitizers
Since
qccdoes not automatically link runtime libraries like the GCC driver:openmp_link_flags()adds-lgompget_profile_generate_args()adds-fprofile-arcssanitizer_link_args()adds the required runtime librariesSanitizer linking also brackets
-lcwith--no-as-neededto work around anSDP 8.0
pthread_oncelink failure.Default include directories
-vv, since plain-vproduces no compilerbanner.
Sanity check
generic GCC/Clang command sequence.
qnxsdp-env.shand licensing.--print-search-dirsqccinenvironment.pybecause the option isundocumented and causes the driver to fail.
Known limitation
.cppm,.ixx) either silently no-op or fail dependingon the SDP version.
Platform-level QNX handling
MachineInfo.is_qnx()(envconfig.py)QNX Neutrino's libc always includes pthread support, so Meson now skips
-pthread/-lpthreadfor any compiler or linker targeting QNX(
mixins/clike.py,linkers/linkers.py), not justqcc.symbolextractor.pyNative/self-hosted QNX builds now use the GNU
readelf/nm-basedgnu_syms()implementation instead ofdummy_syms(), avoiding unnecessaryrelinks.
dependencies/dev.pyJNISystemDependencynow maps:for locating
jni_md.h.CUDANVIDIA uses
<arch>-<system>scheme for QNX:https://developer.nvidia.com/docs/drive/drive-os/6.0.6/public/drive-os-qnx-installation/common/topics/installation/build-samples/build-run-sample-apps-qnx.html#ariaid-title3
Documentation
qcccompiler ID toReference-tables.md.docs/markdown/snippets/qcc-support.md, covering:Tests
Extended
unittests/internaltests.pyso existing GNU compiler-mixin tests alsorun against
QccCCompilerandQccCPPCompiler, including:Added new QCC-specific tests covering:
Testing
Automated
unittests/internaltests.py.Manual
Verified against real installations of:
Validated:
Note: SDP 7.1 ships only
libubsan;libasan,liblsan, andlibtsanare unavailable.
AI Assistance Disclosure
This pull request used Claude Code to analyze the existing codebase, propose implementation changes, and validate those changes using the real compiler. AI assistance was used for code analysis, solution exploration, implementation suggestions, and testing support.
All AI-generated suggestions and code changes were reviewed, verified, and validated by me before being included in this pull request. I take responsibility for the final implementation and have confirmed that the submitted changes behave as intended.