Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to build on 32-bit architecture #474

Closed
jbeich opened this issue Feb 11, 2021 · 4 comments
Closed

Fails to build on 32-bit architecture #474

jbeich opened this issue Feb 11, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@jbeich
Copy link

jbeich commented Feb 11, 2021

Build Environment

  • OS: FreeBSD 11.4/12.2/13.0 i386
  • Compiler: Clang 10
  • Rust version: 1.49.0 packaged downstream

Dependencies

I've used downstream package which builds fine at least on amd64.

The build output

From error log:

error: literal out of range for usize
   --> termwiz/src/cell.rs:371:17
    |
371 |                 0x7f000000_00000000
    |                 ^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[deny(overflowing_literals)]` on by default
    = note: the literal `0x7f000000_00000000` (decimal `9151314442816847872`) does not fit into the type `usize` and will become `0usize`
$ rustc --print cfg
debug_assertions
target_arch="x86"
target_endian="little"
target_env=""
target_family="unix"
target_os="freebsd"
target_pointer_width="32"
target_vendor="unknown"
unix
@jbeich jbeich added the bug Something isn't working label Feb 11, 2021
@wez
Copy link
Owner

wez commented Feb 11, 2021

Thanks for adding the wezterm port!

re: 32-bit: supporting it hasn't been an active goal thus far, but I don't believe that there have been any deliberate choices that prevent it from working (except perhaps on Windows where the PTY stuff requires additional binaries to work).

what's curious is that the line in that error message is in the target_pointer_width=64 case of some code that should in theory be doing the right thing for 32-bit systems:

            if cfg!(target_pointer_width = "64") {
                0x7f000000_00000000
            } else if cfg!(target_pointer_width = "32") {
                0x7f000000
            } else if cfg!(target_pointer_width = "16") {
                0x7f00
            } else {
                panic!("unsupported target");
            }

https://github.com/wez/wezterm/blob/main/termwiz/src/cell.rs#L370-L378

I won't have time to investigate this further for a few days.

@valpackett
Copy link
Contributor

valpackett commented Feb 12, 2021

Oh.. well that's not correct!

if cfg!(..) will still compile all branches on all cfg's (it's just a plain if!), and only eliminate branches in the optimization phase (because the values are constants).

Use the cfg_if macro.

wez added a commit that referenced this issue Feb 12, 2021
@jbeich
Copy link
Author

jbeich commented Feb 12, 2021

Confirmed and applied the fix downstream.

@jbeich jbeich closed this as completed Feb 12, 2021
@github-actions
Copy link

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants