gtk-rs / gtk4-rs

Rust bindings of GTK 4
https://gtk-rs.org/gtk4-rs/
MIT License
1.88k stars 175 forks source link

[BUG] gsk4 build failed #1128

Closed neko-para closed 2 years ago

neko-para commented 2 years ago

Bug description cargo check failed during building gsk4.

env:

It seems that many sub crates have been built correctly, but it fails at gsk.

[package]
name = "gtk-test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gtk = { version = "0", package = "gtk4" }
use gtk::prelude::*;
use gtk::Application;

const APP_ID: &str = "org.gtk_rs.HelloWorld1";

fn main() {
    // Create a new application
    let app = Application::builder().application_id(APP_ID).build();

    // Run the application
    app.run();
}

output for cargo check:

Compiling gsk4 v0.4.8
error: cannot determine resolution for the import
 --> C:\Users\liaoh\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\gsk4-0.4.8\src\render_node.rs:4:5
  |
4 | use glib::translate::*;
  |     ^^^^^^^^^^^^^^^^^^
  |
  = note: import resolution is stuck, try simplifying other imports

error: cannot determine resolution for the import
 --> C:\Users\liaoh\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\gsk4-0.4.8\src\gl_shader.rs:4:5
  |
4 | use glib::translate::*;
  |     ^^^^^^^^^^^^^^^^^^
  |
  = note: import resolution is stuck, try simplifying other imports

... over 4k rows

full output

bilelmoussaoui commented 2 years ago

Very wired. Could you try to remove the target folder and re-build again?

neko-para commented 2 years ago

Very wired. Could you try to remove the target folder and re-build again?

I've removed the target directory, but It raises the same problem.

sdroege commented 2 years ago

Are you sure you're using Rust 1.64.0 here and not some broken custom build?

error[E0603]: tuple struct constructor `SignalHandlerId` is private
  --> C:\Users\liaoh\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\gsk4-0.4.8\src\auto\renderer.rs:9:19
   |
9  | use glib::signal::SignalHandlerId;
   |                   ^^^^^^^^^^^^^^^ private tuple struct constructor
   |
  ::: C:\Users\liaoh\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\glib-0.15.12\src\signal.rs:50:28
   |
50 | pub struct SignalHandlerId(NonZeroU64);
   |                            ---------- a constructor is private if any of the fields is private
   |
note: the tuple struct constructor `SignalHandlerId` is defined here
  --> C:\Users\liaoh\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\glib-0.15.12\src\signal.rs:50:1
   |
50 | pub struct SignalHandlerId(NonZeroU64);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

This error makes no sense at all, for example. That line is importing the type itself into the scope and doesn't even do anything with the constructor of the type (which is indeed private).

Can you also check if this maybe works better if you use crates.io directly instead of that mirror?

neko-para commented 2 years ago

Of course. I've installed it with offical rustup.

I'll try using it, but it's too slow for CN users without proxy.

sdroege commented 2 years ago

That's very strange :) Can you do a clean build (after cargo clean) with cargo -vvvvv build and provide the full output? Also can you reproduce this problem on another machine? I'm wondering if there's something strange in your environment.

neko-para commented 2 years ago

gtk-agian.zip These are logs.

neko-para commented 2 years ago

I'm sorry, but I don't have another WIndows machine to do so.

neko-para commented 2 years ago

I've changed to the official mirror. But the problem stays.

neko-para commented 2 years ago

Some extra informations (I'm not sure if they matter)

C:\Users\liaoh\Documents\Projects\gtk-agian>rustup toolchain list 
stable-x86_64-pc-windows-msvc (default)
C:\Users\liaoh\Documents\Projects\gtk-agian>rustc --version
rustc 1.64.0 (a55dd71d5 2022-09-19)
C:\vcpkg>vcpkg --version
vcpkg package management program version 2022-09-20-522aa94e9d261c7d7b2f079bf2591ca62df5c714

See LICENSE.txt for license information.

C:\vcpkg>vcpkg list
atk:x64-windows                                   2.38.0#2            GNOME Accessibility Toolkit
brotli:x64-windows                                1.0.9#3             a generic-purpose lossless compression algorithm...
bzip2:x64-windows                                 1.0.8#2             bzip2 is a freely available, patent free, high-q...
cairo:x64-windows                                 1.17.6#4            Cairo is a 2D graphics library with support for ...
cairo[fontconfig]:x64-windows                                         build with fontconfig
cairo[freetype]:x64-windows                                           use the freetype font backend
cairo[gobject]:x64-windows                                            build gobject module
dirent:x64-windows                                1.23.2#1            Dirent is a C/C++ programming interface that all...
expat:x64-windows                                 2.4.8#1             XML parser library written in C
fontconfig:x64-windows                            2.14.0#4            Library for configuring and customizing font acc...
freetype:x64-windows                              2.12.1#2            A library to render fonts.
freetype[brotli]:x64-windows                                          Support decompression of WOFF2 streams
freetype[bzip2]:x64-windows                                           Support bzip2 compressed fonts.
freetype[png]:x64-windows                                             Support PNG compressed OpenType embedded bitmaps.
freetype[zlib]:x64-windows                                            Use zlib instead of internal library for DEFLATE
fribidi:x64-windows                               1.0.12              GNU FriBidi is an implementation of the Unicode ...
gdk-pixbuf:x64-windows                            2.42.9#1            Image loading library.
getopt-win32:x64-windows                          0.1#4               An implementation of getopt.
getopt:x64-windows                                0#2                 The getopt and getopt_long functions automate so...
gettext:x64-windows                               0.21#9              GNU gettext provides libintl and a set of tools ...
gettext[tools]:x64-windows                                            Build gettext tools
glib:x64-windows                                  2.72.3#3            Portable, general-purpose utility library.
gperf:x64-windows                                 3.1#4               GNU perfect hash function generator
graphene:x64-windows                              1.10.2#3            A thin layer of types for graphic libraries.
gtk:x64-windows                                   4.6.2#2             Portable library for creating graphical user int...
harfbuzz:x64-windows                              5.0.1#2             HarfBuzz OpenType text shaping engine
libepoxy:x64-windows                              1.5.9#1             Epoxy is a library for handling OpenGL function ...
libffi:x64-windows                                3.4.2#6             Portable, high level programming interface to va...
libiconv:x64-windows                              1.17                GNU Unicode text conversion
libjpeg-turbo:x64-windows                         2.1.4               libjpeg-turbo is a JPEG image codec that uses SI...
liblzma:x64-windows                               5.2.5#6             Compression library with an API similar to that ...
libpng:x64-windows                                1.6.37#19           libpng is a library implementing an interface fo...
libsass:x64-windows                               3.6.5#1             LibSass - Sass compiler written in C++
lzo:x64-windows                                   2.10#7              Lossless data compression library
pango:x64-windows                                 1.50.9              Text and font handling library.
pcre:x64-windows                                  8.45#5              Perl Compatible Regular Expressions
pixman:x64-windows                                0.40.0#4            Pixman is a low-level software library for pixel...
pkgconf:x64-windows                               1.8.0#3             pkgconf is a program which helps to configure co...
pthread:x64-windows                               3.0.0#1             empty package, linking to other port
pthreads:x64-windows                              3.0.0#11            Meta-package that provides PThreads4W on Windows...
sassc:x64-windows                                 3.6.2               SassC is a wrapper around libsass (http://github...
tiff:x64-windows                                  4.4.0#1             A library that supports the manipulation of TIFF...
tiff[jpeg]:x64-windows                                                Support JPEG compression in TIFF image files
tiff[lzma]:x64-windows                                                Support LZMA compression in TIFF image files
tiff[zip]:x64-windows                                                 Support ZIP/deflate compression in TIFF image files
vcpkg-cmake-config:x64-windows                    2022-02-06#1        
vcpkg-cmake:x64-windows                           2022-08-18          
vcpkg-tool-meson:x64-windows                      0.63                Meson build system
zlib:x64-windows                                  1.2.12#1            A compression library
sdroege commented 2 years ago

If you only depend on glib in Cargo.toml and have a hello world src/main.rs that just does use glib::translate::*;, does that fail the same way? Probably not, because then gdk4 would've also failed already to build and not just gsk4 afterwards.

If you git clone the gtk4-rs repo and run cargo build inside the gsk4 subdirectory, does that also fail the same way?

I'm not really sure what to look for here.

neko-para commented 2 years ago

Yes, for glib = "*", it works fine.

I'm cloning it, which may take a long time.

neko-para commented 2 years ago

It requires gtk > 4.7, while mine is 4.6.2. Is there a branch or tag to checkout?

bilelmoussaoui commented 2 years ago

no it doesn't, build with cargo build --manifest-path ./gdk4/Cargo.toml for example

neko-para commented 2 years ago

It builds successfully.

sdroege commented 2 years ago

gdk4 or also gsk4?

neko-para commented 2 years ago

Oh, gsk failed! Error Here's the log err.log

sdroege commented 2 years ago

Ok so that's the same error then. now the question is: what's difference between gsk and gdk that makes the first fail? They both seem to do things the same way :)

bilelmoussaoui commented 2 years ago

cc @GuillaumeGomez, maybe you have an idea?

otherwise i think this should be opened as a bug against rust itself. We build gtk4-rs using msvc on the CI and it builds just fine

bilelmoussaoui commented 2 years ago

Closing as this doesn't seem to be related to gsk itself but rather caused by some very weird environment issue