Skip to content

core: mark float ClampBounds methods as #[inline] - #162191

Open
ojeda wants to merge 1 commit into
rust-lang:mainfrom
ojeda:clamp-inline
Open

core: mark float ClampBounds methods as #[inline]#162191
ojeda wants to merge 1 commit into
rust-lang:mainfrom
ojeda:clamp-inline

Conversation

@ojeda

@ojeda ojeda commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Commit bd174e1 ("Implement clamp_to") added a few float methods that are not marked #[inline]. This causes core to require new symbols in soft-float builds, even if the methods are unused, e.g. from the Linux kernel:

ld.lld: error: undefined symbol: fmaximum_numf
>>> referenced by core.1f440ee8661e09f9-cgu.0
>>>               rust/core.o:(<core::ops::range::RangeFrom<f32> as core::cmp::clamp::ClampBounds<f32>>::clamp) in archive vmlinux.a

(and similar for f{min,max}imum_num{f,} and __gt{s,d}f2).

It is possible to work around this in the Linux side, but these methods should probably be #[inline] to begin with, like many other similar methods are.

Thus mark them as inline.

Commit bd174e1 ("Implement clamp_to") added a few float methods that
are not marked `#[inline]`. This causes `core` to require new symbols
in soft-float builds, even if the methods are unused, e.g. from the
Linux kernel:

    ld.lld: error: undefined symbol: fmaximum_numf
    >>> referenced by core.1f440ee8661e09f9-cgu.0
    >>>               rust/core.o:(<core::ops::range::RangeFrom<f32> as core::cmp::clamp::ClampBounds<f32>>::clamp) in archive vmlinux.a

(and similar for `f{min,max}imum_num{f,}` and `__gt{s,d}f2`).

It is possible to work around this in the Linux side, but these methods
should probably be `#[inline]` to begin with, like many other similar
methods are.

Thus mark them as inline.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 2, 2026
@rustbot

rustbot commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

r? @clarfonthey

rustbot has assigned @clarfonthey.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from JohnTitor, Mark-Simulacrum, clarfonthey

@clarfonthey

Copy link
Copy Markdown
Contributor

These things pop up in the weirdest places. I think marking these as inline is perfectly fine and if it accomplishes what you want, doubly so.

@bors r+ rollup

@rust-bors

rust-bors Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 07c0090 has been approved by clarfonthey

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 2, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 2, 2026
core: mark float `ClampBounds` methods as `#[inline]`

Commit bd174e1 ("Implement clamp_to") added a few float methods that are not marked `#[inline]`. This causes `core` to require new symbols in soft-float builds, even if the methods are unused, e.g. from the Linux kernel:

    ld.lld: error: undefined symbol: fmaximum_numf
    >>> referenced by core.1f440ee8661e09f9-cgu.0
    >>>               rust/core.o:(<core::ops::range::RangeFrom<f32> as core::cmp::clamp::ClampBounds<f32>>::clamp) in archive vmlinux.a

(and similar for `f{min,max}imum_num{f,}` and `__gt{s,d}f2`).

It is possible to work around this in the Linux side, but these methods should probably be `#[inline]` to begin with, like many other similar methods are.

Thus mark them as inline.
@ojeda

ojeda commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

These things pop up in the weirdest places. I think marking these as inline is perfectly fine and if it accomplishes what you want, doubly so.

Thanks for the quick review! :)

Yeah, the kernel build works with these 3 (all needed, i.e. it is the minimum set -- maybe the other methods on top could be marked too, but they are generic anyway).

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 2, 2026
core: mark float `ClampBounds` methods as `#[inline]`

Commit bd174e1 ("Implement clamp_to") added a few float methods that are not marked `#[inline]`. This causes `core` to require new symbols in soft-float builds, even if the methods are unused, e.g. from the Linux kernel:

    ld.lld: error: undefined symbol: fmaximum_numf
    >>> referenced by core.1f440ee8661e09f9-cgu.0
    >>>               rust/core.o:(<core::ops::range::RangeFrom<f32> as core::cmp::clamp::ClampBounds<f32>>::clamp) in archive vmlinux.a

(and similar for `f{min,max}imum_num{f,}` and `__gt{s,d}f2`).

It is possible to work around this in the Linux side, but these methods should probably be `#[inline]` to begin with, like many other similar methods are.

Thus mark them as inline.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 2, 2026
core: mark float `ClampBounds` methods as `#[inline]`

Commit bd174e1 ("Implement clamp_to") added a few float methods that are not marked `#[inline]`. This causes `core` to require new symbols in soft-float builds, even if the methods are unused, e.g. from the Linux kernel:

    ld.lld: error: undefined symbol: fmaximum_numf
    >>> referenced by core.1f440ee8661e09f9-cgu.0
    >>>               rust/core.o:(<core::ops::range::RangeFrom<f32> as core::cmp::clamp::ClampBounds<f32>>::clamp) in archive vmlinux.a

(and similar for `f{min,max}imum_num{f,}` and `__gt{s,d}f2`).

It is possible to work around this in the Linux side, but these methods should probably be `#[inline]` to begin with, like many other similar methods are.

Thus mark them as inline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants