jeremyletang / rgtk

GTK+ bindings and wrappers for Rust (DEPRECATED SEE https://github.com/rust-gnome )
GNU Lesser General Public License v3.0
121 stars 22 forks source link

32bit support? #250

Open buster opened 9 years ago

buster commented 9 years ago

Hi,

i just wanted to compile my program on i386 (Atom based netbook) but the steps show the following errors. I guess this is due to the netbook being 32bit? Or could this be something different?

/home/buster/.cargo/git/checkouts/rgtk-1b1dd31ed25241cd/master/src/gtk/widgets/recent_info.rs:70:18: 70:87 error: mismatched types:
 expected `i64`,
    found `i32`
(expected i64,
    found i32) [E0308]
/home/buster/.cargo/git/checkouts/rgtk-1b1dd31ed25241cd/master/src/gtk/widgets/recent_info.rs:70         unsafe { ffi::gtk_recent_info_get_added(GTK_RECENT_INFO(self.unwrap_widget())) }
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/buster/.cargo/git/checkouts/rgtk-1b1dd31ed25241cd/master/src/gtk/widgets/recent_info.rs:74:18: 74:90 error: mismatched types:
 expected `i64`,
    found `i32`
(expected i64,
    found i32) [E0308]
/home/buster/.cargo/git/checkouts/rgtk-1b1dd31ed25241cd/master/src/gtk/widgets/recent_info.rs:74         unsafe { ffi::gtk_recent_info_get_modified(GTK_RECENT_INFO(self.unwrap_widget())) }
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/buster/.cargo/git/checkouts/rgtk-1b1dd31ed25241cd/master/src/gtk/widgets/recent_info.rs:78:18: 78:89 error: mismatched types:
 expected `i64`,
    found `i32`
(expected i64,
    found i32) [E0308]
/home/buster/.cargo/git/checkouts/rgtk-1b1dd31ed25241cd/master/src/gtk/widgets/recent_info.rs:78         unsafe { ffi::gtk_recent_info_get_visited(GTK_RECENT_INFO(self.unwrap_widget())) }
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/buster/.cargo/git/checkouts/rgtk-1b1dd31ed25241cd/master/src/gtk/widgets/recent_info.rs:97:21: 97:31 error: mismatched types:
 expected `*mut i32`,
    found `&mut i64`
(expected i32,
    found i64) [E0308]
/home/buster/.cargo/git/checkouts/rgtk-1b1dd31ed25241cd/master/src/gtk/widgets/recent_info.rs:97                     &mut time_));
                                                                                                                     ^~~~~~~~~~
/home/buster/.cargo/git/checkouts/rgtk-1b1dd31ed25241cd/master/src/gdk/widgets/pixbuf.rs:74:18: 74:90 error: mismatched types:
 expected `u64`,
    found `u32`
(expected u64,
    found u32) [E0308]
/home/buster/.cargo/git/checkouts/rgtk-1b1dd31ed25241cd/master/src/gdk/widgets/pixbuf.rs:74         unsafe { ffi::gdk_pixbuf_get_byte_length(self.pointer as *const ffi::C_GdkPixbuf) }
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 5 previous errors
Could not compile `rgtk`.

To learn more, run the command again with --verbose.
GuillaumeGomez commented 9 years ago

Oh ! That's perfect ! We need someone to check and add/replace conversion like i32 as c_int on 32 bit computer everywhere there's warning. Could you do that please ?

gkoz commented 9 years ago

Hmm. Didn't expect this to not have been tested at all. Checking 32-bit stuff on a 64-bit system should be pretty easy, just make a 32-bit chroot. Too bad travis doesn't provide this...

GuillaumeGomez commented 9 years ago

A 32-bit chroot ?

gkoz commented 9 years ago

Oh.. you might not be running Linux?.. My bad haha.

buster commented 9 years ago

Problem is that compiling rgtk on that netbook takes around 45 minutes or something like that, chroot on a beefier machine seems to be the better option

gkoz commented 9 years ago

In case anyone finds it useful, a 32-bit chroot is as simple as [UPDATED]

DIR=ubuntu32
RELEASE=vivid
mkdir $DIR
sudo debootstrap --arch i386 $RELEASE $DIR http://archive.ubuntu.com/ubuntu/
sudo mount -t proc proc $DIR/proc
sudo mount -t devtmpfs dev $DIR/dev
sudo setarch i386 chroot $DIR /bin/bash

This will also allow to test with various GTK versions.

GuillaumeGomez commented 9 years ago

@gkoz: I'm under linux and I didn't know that, thanks for the tip !

gkoz commented 9 years ago

@GuillaumeGomez Uh... actually rustc dies on me in this setup... even when I add setarch i386. So maybe not as simple as I thought.

gkoz commented 9 years ago

That was just laziness though, when running a system in a chroot you need to mount /proc and /dev :)

GuillaumeGomez commented 9 years ago

Hum... I was going to use a linux live usb to test 32-bit (taht's how I was doing before) but I'll give a try to your solution.

gkoz commented 9 years ago

So the more correct way to start the chroot would be

DIR=ubuntu32
sudo mount -t proc proc $DIR/proc
sudo mount -t devtmpfs dev $DIR/dev
sudo setarch i386 chroot $DIR /bin/bash

And if you're going to use a recent version of Ubuntu, your kernel better not be too old...

StephanvanSchaik commented 9 years ago

As I want to be able to compile this Rust binding for GTK+ on ARMv7, which is also a 32-bit architecture, I am currently working on a patch that fixes this particular issue.

StephanvanSchaik commented 9 years ago

Also, to set up a 32-bit chroot, do the following:

Download a rootfs for the distribution you want to use:

Debian

mkdir chroot32
debootstrap --arch=i386 --foreign jessie chroot32 http://http.debian.net/debian
chroot chroot32 /debootstrap/debootstrap --second-stage

Gentoo

mkdir chroot32
wget -O - http://distfiles.gentoo.org/releases/x86/autobuilds/$(wget -O - http://distfiles.gentoo.org/releases/x86/autobuilds/latest-stage-i686.txt 2>/dev/null | tail -n1 | tr ' ' '\n' | head -n1) | tar xvjp -C chroot32
wget -O - http://distfiles.gentoo.org/releases/snapshots/current/portage-latest.tar.bz2 | tar xjp -C chroot32/usr/

Ubuntu

mkdir chroot32
wget -O - http://cdimage.ubuntu.com/ubuntu-core/releases/14.10/release/ubuntu-core-14.10-core-i386.tar.gz | tar xvzp -C chroot32 

Entering the chroot32 environment

mount -t proc none chroot32/proc
for i in {dev,sys,tmp}; do mount -o bind /$i chroot32/$i; done
cp /etc/resolv.conf chroot32/etc/resolv.conf
chroot chroot32 /bin/bash

Note: you can also save this as a shell script.

Leaving the chroot32 environment

Simply type exit. You can save the following shell script to clean it all up:

for i in {dev,proc,sys,tmp}; do umount chroot32/$i; done