Skip to content

Add support io-pkt Driver Development Kit from QNX #162

Closed

Description

@nradakovic

Add support for the QNX io-pkt Driver Development Kit (DDK)

Background

QNX SDP implements network device drivers and network protocol modules on top of FreeBSD's kernel TCP/IP stack (io-pkt). Building such modules requires a FreeBSD "kernel" compilation personality and the usr/include/devs header search paths. The toolchain currently exposes neither, so these modules cannot be built with Bazel.

Scope

New opt-in feature io_pkt_ddk (QNX only)

  • Added features/custom/qnx/io_pkt_ddk/feature.bzl with make_io_pkt_ddk_feature(target_dir, cpu), mirroring usr/include/devs/devs.mk, mods.mk and opt_global.mk.
  • Kernel personality flags: -D__FreeBSD__ -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -D__EXT -fno-builtin-log -fno-strict-aliasing.
  • Global option flags: -DSMP -DEARLY_AP_STARTUP -DVIMAGE -DALTQ -DDEV_NETMAP -D_STRINGS_H_INCLUDED -D_UNISTD_H_INCLUDED.
  • Include paths: devs, devs/contrib/ck/include, devs/include_<cpu>, devs/qnx, devs/qnx-gen, devs/sys-nto.
  • Debug-only flags (-DINVARIANTS -DINVARIANT_SUPPORT -DKTR) are added only when the dbg feature is on (the diag variant in the QNX makefiles).
  • Disabled by default. Targets opt in with features = ["io_pkt_ddk"]. It is registered per toolchain instance in features/custom/qnx/make_cc_features.bzl.
  • rules/gcc.bzl generates the feature per QNX toolchain instance. It passes the package's target_dir filegroup label and tc_cpu.

C standard selection fix and new c_std_c99 feature

  • Added the c_std_c99 marker (-std=iso9899:1999) and registered it, together with gnu11, as an opt-in known feature for QNX. It is also registered for Linux.

  • requires_any_of is an OR, so the old constraints (not_gnu11 / not_c99) could make -std=c11 and -std=gnu11 apply together. Each -std flag now has a single constraint:

    Enabled feature Flag
    none (default) -std=c11
    gnu11 -std=gnu11
    c_std_c99 -std=iso9899:1999 (wins if gnu11 is also set)

Tests

  • Added tests/qnx_ddk with a build-only io_pkt_ddk_test target. It checks that the DDK headers compile with the feature, and fails if the include path falls back to the non-DDK QNX sys/param.h.

Misc

  • Added tests to the copyright checker in the root BUILD.
  • Ignored .vscode/ in .gitignore.

Notes

  • The io_pkt_ddk include paths must not contain devs/sys. It would shadow the QNX limits.h, errno.h and stddef.h with the FreeBSD versions, which breaks builds (for example missing CHAR_BIT, errno and size_t).
  • The test is not part of any test_suite.
  • The test's license header is duplicated and should be cleaned up.

How to verify

cd tests
bazel build --config x86_64-qnx //qnx_ddk:io_pkt_ddk_test

The compile line should include -std=iso9899:1999, the -D__FreeBSD__ -D_KERNEL ... flags and the devs include paths, and should not include -std=c11 or -std=gnu11.

Acceptance criteria

  • io_pkt_ddk is off by default and does not change the flags of targets that don't request it.
  • //qnx_ddk:io_pkt_ddk_test builds for x86_64-qnx. Note: I haven't run it for aarch64-qnx.
  • Only one -std= flag is emitted for each of: default, gnu11, c_std_c99.
  • Linux toolchains are unaffected, apart from the new opt-in c_std_c99 feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

p3

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions