veeenu / hudhook

A videogame overlay framework written in Rust, supporting DirectX and OpenGL
MIT License
209 stars 30 forks source link

Build failed on --target i686-pc-windows-msvc #128

Closed bub-bl closed 1 year ago

bub-bl commented 1 year ago

I can't build from the target i686-pc-windows-msvc. The target x86_64-pc-windows-msvc works fine.

veeenu commented 1 year ago

Could you provide more details, please? I don't have a i686 build pipeline setup at the moment.

bub-bl commented 1 year ago

A lot of errors come from winapi crate. I can't post the logs because she is pretty insanly big. I have tested with a blank project and im only useing hudhook + imgui_hook but a got the same problem.

Maybe switch from winapi to windows-sys for better compatibility ?? (the api is almost the same).

Another things is the size of produced .dll, i reach 600 ko's on a blank project dll when i build with hudhook crate. (The problem seem to come from the size of imgui-sys crate).

bub-bl commented 1 year ago

This is a little part of the logs like 1%..

    ::: C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\um\winnt.rs:8606:1
     |
8606 | / FN!{stdcall PTP_WORK_CALLBACK(
8607 | |     Instance: PTP_CALLBACK_INSTANCE,
8608 | |     Context: PVOID,
8609 | |     Work: PTP_WORK,
8610 | | ) -> ()}
     | |________- in this macro invocation
     |
     = note: this error originates in the macro `FN` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0405]: cannot find trait `Clone` in this scope
    --> C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\macros.rs:393:14
     |
393  |           impl Clone for $name {
     |                ^^^^^ not found in this scope
     |
    ::: C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\um\winnt.rs:8611:1
     |
8611 | / STRUCT!{struct TP_TIMER {
8612 | |     dummy: *mut c_void,
8613 | | }}
     | |__- in this macro invocation
     |
     = note: this error originates in the macro `STRUCT` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0412]: cannot find type `Option` in this scope
    --> C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\macros.rs:412:26
     |
412  |           pub type $func = Option<unsafe extern "system" fn($($p: $t,)*) -> $ret>;
     |                            ^^^^^^ not found in this scope
     |
    ::: C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\um\winnt.rs:8615:1
     |
8615 | / FN!{stdcall PTP_TIMER_CALLBACK(
8616 | |     Instance: PTP_CALLBACK_INSTANCE,
8617 | |     Context: PVOID,
8618 | |     Timer: PTP_TIMER,
8619 | | ) -> ()}
     | |________- in this macro invocation
     |
     = note: this error originates in the macro `FN` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0405]: cannot find trait `Clone` in this scope
    --> C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\macros.rs:393:14
     |
393  |           impl Clone for $name {
     |                ^^^^^ not found in this scope
     |
    ::: C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\um\winnt.rs:8621:1
     |
8621 | / STRUCT!{struct TP_WAIT {
8622 | |     dummy: *mut c_void,
8623 | | }}
     | |__- in this macro invocation
     |
     = note: this error originates in the macro `STRUCT` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0412]: cannot find type `Option` in this scope
    --> C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\macros.rs:412:26
     |
412  |           pub type $func = Option<unsafe extern "system" fn($($p: $t,)*) -> $ret>;
     |                            ^^^^^^ not found in this scope
     |
    ::: C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\um\winnt.rs:8625:1
     |
8625 | / FN!{stdcall PTP_WAIT_CALLBACK(
8626 | |     Instance: PTP_CALLBACK_INSTANCE,
8627 | |     Context: PVOID,
8628 | |     Wait: PTP_WAIT,
8629 | |     WaitResult: TP_WAIT_RESULT,
8630 | | ) -> ()}
     | |________- in this macro invocation
     |
     = note: this error originates in the macro `FN` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0405]: cannot find trait `Clone` in this scope
    --> C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\macros.rs:393:14
     |
393  |           impl Clone for $name {
     |                ^^^^^ not found in this scope
     |
    ::: C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\um\winnt.rs:8631:1
     |
8631 | / STRUCT!{struct TP_IO {
8632 | |     dummy: *mut c_void,
8633 | | }}
     | |__- in this macro invocation
     |
     = note: this error originates in the macro `STRUCT` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0405]: cannot find trait `Clone` in this scope
    --> C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\macros.rs:393:14
     |
393  |           impl Clone for $name {
     |                ^^^^^ not found in this scope
     |
    ::: C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\um\winnt.rs:8646:1
     |
8646 | / STRUCT!{struct ACTIVATION_CONTEXT {
8647 | |     dummy: *mut c_void,
8648 | | }}
     | |__- in this macro invocation
     |
     = note: this error originates in the macro `STRUCT` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0405]: cannot find trait `Clone` in this scope
   --> C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\macros.rs:393:14
    |
393 |           impl Clone for $name {
    |                ^^^^^ not found in this scope
    |
   ::: C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\um\winreg.rs:55:1
    |
55  | / STRUCT!{struct VALENTA {
56  | |     ve_valuename: LPSTR,
57  | |     ve_valuelen: DWORD,
58  | |     ve_valueptr: DWORD_PTR,
59  | |     ve_type: DWORD,
60  | | }}
    | |__- in this macro invocation
    |
    = note: this error originates in the macro `STRUCT` (in Nightly builds, run with -Z macro-backtrace for more info)
62  | / STRUCT!{struct VALENTW {
63  | |     ve_valuename: LPWSTR,
64  | |     ve_valuelen: DWORD,
65  | |     ve_valueptr: DWORD_PTR,
66  | |     ve_type: DWORD,
67  | | }}
    | |__- in this macro invocation
    |
    = note: this error originates in the macro `STRUCT` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0405, E0412, E0463.
error: could not compile `winapi` (lib) due to 1248 previous errors
veeenu commented 1 year ago

hudhook hasn't depended on the winapi crate in a long, long time, and we actually adopted windows pretty early.

I found out that we still transitively depend on it via tracing-subscriber but that's only actually activated on the examples and tests, so it shouldn't influence regular usage.

Turns out there was an actual issue on i686 but it should be covered by #129, and it only produced two errors.

Your error messages refer to missing standard traits and types:

error[E0412]: cannot find type `Option` in this scope
    --> C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\macros.rs:412:26
     |
412  |           pub type $func = Option<unsafe extern "system" fn($($p: $t,)*) -> $ret>;
     |                            ^^^^^^ not found in this scope
error[E0405]: cannot find trait `Clone` in this scope
   --> C:\Users\bubbl\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\macros.rs:393:14
    |
393 |           impl Clone for $name {
    |                ^^^^^ not found in this scope

This makes me think you might actually be missing the target triple entirely, as that's what it looks like in these cases. It could be that you have it installed but only on a different toolchain -- e.g. you're compiling with nightly but have it installed on stable or viceversa. Try this:

rustup target add i686-pc-windows-msvc --toolchain stable
rustup target add i686-pc-windows-msvc --toolchain nightly
veeenu commented 1 year ago

Another things is the size of produced .dll, i reach 600 ko's on a blank project dll when i build with hudhook crate. (The problem seem to come from the size of imgui-sys crate).

That might be worth looking into, but small binary size was not an explicit goal so far; 600kb is actually relatively on the small side for your average Rust binary. Have you tried deactivating default features and only using the hook(s) you care about? Not sure much else can be done on our end.

I'm not sure if #![no_std] support can be achieved considering that we do have a few third party dependencies, but it definitely would be desirable to pursue that. I think that could help reducing binary size eventually.

veeenu commented 1 year ago

Closing this and tracking the no_std support efforts in #131