Skip to content

Add OpenBSD -current release version to target_env - #160739

Draft
dybucc wants to merge 2 commits into
rust-lang:mainfrom
dybucc:main
Draft

Add OpenBSD -current release version to target_env#160739
dybucc wants to merge 2 commits into
rust-lang:mainfrom
dybucc:main

Conversation

@dybucc

@dybucc dybucc commented Aug 8, 2026

Copy link
Copy Markdown
Contributor
  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below
    how it was used.

Draft PR to add support for target_env values in OpenBSD to carry their
-current release channel version number.

This is meant to be the associated implementation for
rust-lang/compiler-team#1018.

Unlike the proposed implementation plan in the MCP, no specific target specs
have been modified. The base specification currently serves just fine for all
supported OpenBSD targets.

If at some point in the future, some OpenBSD release drops support for a current
Rust target, the target-specific module can be modified to avoid relying on the
default Env value.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 8, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread src/librustdoc/clean/cfg.rs Outdated
Nto71 => "QNX SDP 7.1",
Nto71IoSock => "QNX SDP 7.1 with io-sock",
Ohos => "OpenHarmony",
OpenBsd => "OpenBSD -current",

@tgross35 tgross35 Aug 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd name the variant OpenBsdCurrent and update this name to maybe OpenBSD -current (7.9)

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -156,7 +156,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
LL | target_env = "_UNEXPECTED_VALUE",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `gnu`, `macabi`, `mlibc`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `ohos`, `p1`, `p2`, `p3`, `relibc`, `sgx`, `sim`, `uclibc`, and `v5`
= note: expected values for `target_env` are: ``, `gnu`, `macabi`, `mlibc`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `ohos`, `openbsd7.9`, `p1`, `p2`, `p3`, `relibc`, `sgx`, `sim`, `uclibc`, and `v5`

@tgross35 tgross35 Aug 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to allow any openbsdM.m for M.m > 7.9 for the unexpected cfg lint, so e.g. this version of Rust doesn't emit a warning if it sees target_env = "openbsd8.0".

If that's easy then I think you could do it here but if not, can be a followup.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking into this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have some basics done to accomplish this. The current
implementation is far from ideal, but I preferred to have an initial
overview of it.

In rustc_session, there lives functionality to both address cfgs
and check-cfg for those cfgs. The data structures backing value
validation, though, seem quite primitive in nature.

I've tried to go for something simple (that doesn't yet build.) The
enumeration that is used for expected values in cfgs, namely,
ExpectedValue, has been extended with one more variant.

The two prior variants covered the possibility for (1) some cfg to
be capable of taking any value, or for (2) a cfg to take in a
pre-defined set of values. The new variant allows setting a bound.

This bound is currently limitted to all values above some known value,
which is the usecase we have in the MCP, but I think it could be
extended easily.

Then back in the rustc_target::spec::Env, I extended this type with
a new method that returns a decimal representation of the OpenBSD
variant. This then gets interned back at rustc_session::config::cfg.

I've yet to look into how do the set of expected values get parsed in
rustc_session, so for now this only sets up some infrastructure.
I've yet to work on changing the actual checking logic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not feasible. It possibly needs an RFC prior to
implementation, as it's a non-trivial change that would require
modifying the way cfg values are parsed.

Working around it only for OpenBSD while using the
ExpectedValues::Any variant of the type in charge of holding
expected values is a subpar solution.

I think the need we have in this instance could be fulfilled once the
versioned cfgs RFC 1 gets implemented. That can be followed up by
another RFC that extends typing from whole cfgs to more fine-grained
cfg variants (like Env::OpenBsdCurrent here.)

Footnotes

  1. Version-typed cfgs rfcs#3905

Comment thread compiler/rustc_target/src/spec/mod.rs Outdated
Nto71 = "nto71",
Nto71IoSock = "nto71_iosock",
Ohos = "ohos",
OpenBsd = "openbsd7.9",

@tgross35 tgross35 Aug 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this version to https://doc.rust-lang.org/beta/rustc/platform-support/openbsd.html. Put a comment by it in the markdown file as well saying that the target_spec_enum should be updated when that version is bumped (and anything else that needs it)

Also, isn't the current -current 8.0?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that should be done now. I'm not sure how to handle the
possibility for some target to still have Rust support but be dropped
out of OpenBSD support.

What value should they use then? We only ever target the latest
-current, but that hypothetical target would be stuck in some older
-current. They can't just abide by the general OpenBSD spec.

Yes, the current -current is 8.0. That's fixed now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you give an example of what OpenBSD and Rust version combo would be problematic? I'm not sure what the circumstances would be, given Rust support moves every 6 weeks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example would be any platform that has been deprecated in upstream
OpenBSD in the next ten years, and for which we could have Rust
support.

Suppose the powerpc64-unknown-openbsd Rust target, which corresponds
with the PowerPC architecture family, now isn't supported anymore in
OpenBSD 9.0. And yet we do want to still provide support for it in
Rust.

What value of the rustc_target::spec::Env should we provide for this
target in future rustc releases (starting from the nightly that would
ship support for OpenBSD 9.0?) Should they use Env::Unspecified?

Or should we immediately drop newer Rust support for any target that
gets dropped out of upstream OpenBSD support?

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

167 LL |     target_env = "_UNEXPECTED_VALUE",
168    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
169    |
-    = note: expected values for `target_env` are: ``, `gnu`, `macabi`, `mlibc`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `ohos`, `openbsd7.9`, `p1`, `p2`, `p3`, `relibc`, `sgx`, `sim`, `uclibc`, and `v5`
+    = note: expected values for `target_env` are: ``, `gnu`, `macabi`, `mlibc`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `ohos`, `openbsd8.0`, `p1`, `p2`, `p3`, `relibc`, `sgx`, `sim`, `uclibc`, and `v5`
171    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
172 
173 warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args check-cfg/well-known-values.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/check-cfg/well-known-values.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/check-cfg/well-known-values" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--check-cfg=cfg()" "-Zcheck-cfg-all-expected"
stdout: none
--- stderr -------------------------------
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:30:5
   |
LL |     clippy = "_UNEXPECTED_VALUE",
   |     ^^^^^^----------------------
   |           |
   |           help: remove the value
   |
   = note: no expected value for `clippy`
---

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:40:5
   |
LL |     miri = "_UNEXPECTED_VALUE",
   |     ^^^^----------------------
   |         |
   |         help: remove the value
   |
   = note: no expected value for `miri`
---

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:46:5
   |
LL |     proc_macro = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^----------------------
   |               |
   |               help: remove the value
   |
   = note: no expected value for `proc_macro`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:48:5
   |
LL |     relocation_model = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `relocation_model` are: `dynamic-no-pic`, `pic`, `pie`, `ropi`, `ropi-rwpi`, `rwpi`, and `static`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:50:5
   |
---

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:52:5
   |
LL |     rustfmt = "_UNEXPECTED_VALUE",
   |     ^^^^^^^----------------------
   |            |
   |            help: remove the value
   |
   = note: no expected value for `rustfmt`
---
   |
LL |     sanitize = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `sanitize` are: `address`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `kernel-hwaddress`, `leak`, `memory`, `memtag`, `realtime`, `safestack`, `shadow-call-stack`, and `thread`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:56:5
   |
LL |     target_abi = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_abi` are: ``, `abi64`, `abiv2`, `abiv2hf`, `eabi`, `eabihf`, `elfv1`, `elfv2`, `fortanix`, `ilp32`, `ilp32e`, `llvm`, `macabi`, `pauthtest`, `sim`, `softfloat`, `spe`, `uwp`, `vec-extabi`, and `x32`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:58:5
   |
LL |     target_arch = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_arch` are: `aarch64`, `amdgpu`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch32`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`, and `xtensa`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:60:5
   |
---
   |
LL |     target_env = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_env` are: ``, `gnu`, `macabi`, `mlibc`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `ohos`, `openbsd8.0`, `p1`, `p2`, `p3`, `relibc`, `sgx`, `sim`, `uclibc`, and `v5`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:64:5
   |
---
   |
LL |     target_has_atomic = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_has_atomic` are: (none), `128`, `16`, `32`, `64`, `8`, and `ptr`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:70:5
   |
LL |     target_has_atomic_load_store = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_has_atomic_load_store` are: (none), `128`, `16`, `32`, `64`, `8`, and `ptr`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:72:5
   |
LL |     target_has_atomic_primitive_alignment = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_has_atomic_primitive_alignment` are: `128`, `16`, `32`, `64`, `8`, and `ptr`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:74:5
   |
LL |     target_has_threads = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^----------------------
   |                       |
   |                       help: remove the value
   |
   = note: no expected value for `target_has_threads`
---
   |
LL |     target_object_format = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_object_format` are: `coff`, `elf`, `mach-o`, `wasm`, and `xcoff`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:78:5
   |
LL |     target_os = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qnx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:80:5
   |
LL |     target_pointer_width = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_pointer_width` are: `16`, `32`, and `64`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:82:5
   |
---
   |
LL |     target_vendor = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:86:5
   |
LL |     ub_checks = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^----------------------
   |              |
   |              help: remove the value
   |
   = note: no expected value for `ub_checks`
---

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:90:5
   |
LL |     windows = "_UNEXPECTED_VALUE",
   |     ^^^^^^^----------------------
   |            |
   |            help: remove the value
   |
   = note: no expected value for `windows`
---
   |
LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux`
   |       ^^^^^^^^^^^^-------
   |                   |
   |                   help: there is a expected value with a similar name: `"linux"`
   |
   = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qnx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: 31 warnings emitted
------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants