Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
32-bit version of unison on amd64?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Havin_it
Veteran
Veteran


Joined: 17 Jul 2005
Posts: 1247
Location: Edinburgh, UK

PostPosted: Wed May 16, 2012 1:18 pm    Post subject: 32-bit version of unison on amd64? Reply with quote

Hi,

I've been using unison for some time now to sync a folder between home (Gentoo and Arch x86) and work (Win 7 32bit) PCs via a central server (Gentoo amd64). The server was originally x86 but I replaced it with an amd64 box a couple of months ago, which didn't immediately seem to cause any problems.

However, lately I've had problems syncing specific files from the Windows box to the server. The compare stage goes normally, but transfer hangs on certain files. (Unfortunately I can't share the files in question due variously to business sensitivity and software licensing, but they include some quite small SQL files and some largish .chm help files.)

In the unison wiki I found this passage:
Quote:
Why does synchronization always fail with Uncaught exception Failure("input_value: integer too large")?

This is because of an incompatibilitly in an underlying programming layer and shows up when you're synchronizing between 32 and 64 bit systems.

A workaround is the following one: on the 32 bit system nothing changes, but on the 64 bit system you don't use a native 64 bit version of unison, but a 32 bit one that is run in the 32 bit compatibility mode.

There are two possibilities to achieve that: a) there may be a way to run a usual dynamically linked 32 bit binary with a 32 bit compatible runtime environment or b) you use a statically linked 32 bit binary that doesn't depend on such a runtime environment.

To get a statically linked 32 bit binary there are in turn again two possibilities: a) you compile it statically (or have someone else do that and just download it) or b) you use a tool like the ELF statifier (http://statifier.sourceforge.net/) or Ermine (http://www.magicErmine.com) on a dynamically linked binary to convert it into a statically linked one.


Now I haven't seen that message, but using "-debug all" when running the profile on the Windows box generates so much output that the command window hangs, so who knows? :roll: It seems worth a try, anyway, if possible.

So the actual question is: How would I go about creating such a 32-bit version of unison that I could run with emulation on the server? And can this be achieved in a manner that plays nicely with portage? (Not that this is the end of the world, since unison is hardly ever updated these days.)

I don't mind jumping through a lot of hoops to achieve this, since unison is the most appropriate solution I've found for my use-case. (Of course, suggestions of other bi-directional multi-host, cross-platform sync solutions I might have overlooked are still welcome too!)

For the record, the amd64 box is +multilib, 32-bit emulation is already enabled in the kernel, and I have an i686 crossdev setup there if that helps at all. TIA for any advice.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Thu May 17, 2012 2:02 am    Post subject: Reply with quote

That looks like a bug in the design of the Unison network protocol. Wire protocols should be independent of the bitness and even endianness of the hosts using them. If Unison does not have dependencies on other libraries, you could probably build a 32-bit version by modifying the ebuild. It looks like it is not a normal C program, so this could be somewhat difficult.

For basic transfers, net-misc/rsync works well. However, it assumes policy is provided by its caller.
Back to top
View user's profile Send private message
MotivatedTea
Apprentice
Apprentice


Joined: 06 Nov 2006
Posts: 269
Location: Toronto, Canada

PostPosted: Thu May 17, 2012 2:32 am    Post subject: Reply with quote

I use unison a lot too. (For the record, unison does a lot more than rsync.) I haven't tried running between 32 and 64 bit systems yet. However, I have had to use it on computers on which I did not have permission to install software system-wide, or computers on which the installed version didn't match the version I wanted to use. In those cases, I simply compiled the executable from source in my home directory and moved the "unison" executable to ${HOME}/bin/unison (making sure that ${HOME}/bin was in my PATH before /usr/bin).

Although it's not a portage-y solution, it would probably work for you. If you already have an i686 crossdev environment set up, build ocaml and then unison in that environment. (If you can do without the GUI, you should only need ocaml. If you want the GUI, you'll need to cross-compile a bunch of GTK libraries as well. Read the "INSTALL" file in the source tarball for details. However, it will probably be much easier to cross-compile without the GUI. I would at least try that first. You can always just use the GUI on the "other" machine you're syncing.) I'm sorry I can't help you figure out how to do that - I haven't used crossdev in a while. However, given that your system is multilib, if you can acquire a 32-bit unison executable from somewhere, you should be able to run it directly. Note that you may need to use the "servercmd" directive in your unison profile to make sure the 32-bit version is run instead of the one in /usr/bin, since non-interactive logins won't necessarily have the same PATH that you're used to. (See the unison documentation.)

I hope that helps at least a little bit. If you find a solution, please post it here. I'm not syncing between 64 and 32 bit system yet, but I probably will need to in the future!
Back to top
View user's profile Send private message
Havin_it
Veteran
Veteran


Joined: 17 Jul 2005
Posts: 1247
Location: Edinburgh, UK

PostPosted: Thu May 17, 2012 11:46 am    Post subject: Reply with quote

OK, thanks for that. So does that mean if I follow the cross-compiling guide and do "xmerge unison" I'll get a binary with its own 32-bit libs, all of which'll run happily on the host system, or will I need to do other things either (a) to ensure it loads the correct libs at runtime, or (b) to create a static binary if (a) won't work?

Should also mention that the connection is over SSH (using cygwin's ssh binary on the client, although the unison client I'm using is native not the cygwin one). Just in case that complicates the remote invocation (I assume some kind of wrapper can deal with this).
Back to top
View user's profile Send private message
MotivatedTea
Apprentice
Apprentice


Joined: 06 Nov 2006
Posts: 269
Location: Toronto, Canada

PostPosted: Fri May 18, 2012 8:10 pm    Post subject: Reply with quote

I believe that should work, although I'm not in a position to test it. I believe unison is written in Ocaml, not C, and that's a language I'm not familiar with. I don't know what shared libraries it might need to run - that would be your biggest potential problem. That's why I suggest compiling it without the GUI - that will greatly reduce the list of dependencies.

Cross-dev still uses portage, correct? In that case, I would use cross-dev to build a 32-bit version of unison with USE="static -gtk". That is, turn the GUI off (-gtk), and make a static executable. That should result in a 32-bit executable with few or no dependencies. You should be able to just run a 32-bit static executable on a 64-bit multilib machine without problems. You can check what shared libraries a program expects by running "ldd /path/to/32/bit/unison". Ideally you will get a message saying "not a dynamic executable". If you do get some dependencies, they will hopefully be only a few libraries that are provided by your multilib setup.

Once you know you have a 32-bit build you can run, then you need to make sure unison uses it. Locally, you can just run it explicitly (although you won't get a GUI). Remotely, you'll need to edit your unison profile as I indicated before, and make sure the "servercmd" points to the full path to the 32-bit executable.
Back to top
View user's profile Send private message
Havin_it
Veteran
Veteran


Joined: 17 Jul 2005
Posts: 1247
Location: Edinburgh, UK

PostPosted: Sat May 19, 2012 10:39 am    Post subject: Reply with quote

Getting closer, but still some problems. The static, non-gtk build has only a few deps but one of them (coreutils) is having a build failure. Besides the xmerge script, I also spotted that there's an emerge-i686-pc-linux-gnu command, which seemed to function identically to xmerge, but failed identically too :(

Can cross-compiling failures be reported to b.g.o?

Also, seems odd that ocaml was not pulled in. It's not a runtime dep as long as USE="ocamlopt" (compiles a binary instead of ocaml bytecode) but I'm surprised that it doesn't require a 32-bit version of ocamlopt to build it (as would be the case with gcc).
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Sat May 19, 2012 3:07 pm    Post subject: Reply with quote

Cross-compilation failures should be supported on b.g.o, but you can bring them here first if you want confirmation. Did you set USE=static for the entire xmerge tree or only for unison? You should only need to set it for unison.

As I read the ebuild, dev-lang/ocaml is never a runtime dependency. The check for USE=ocamlopt is because OCaml support for creating native code is an optional feature of dev-lang/ocaml, so users might have installed dev-lang/ocaml[-ocamlopt], which would give them an OCaml interpreter, but not enable them to build native code from OCaml inputs. Such users would fail to build net-misc/unison[ocamlopt]. It might be a mistake that the ebuild does not include RDEPEND+="!ocamlopt? ( dev-lang/ocaml )". Most people end up with the build time dependencies lurking on their systems indefinitely, so would not notice the mistake, if it is a mistake at all. It is also possible that net-misc/unison[-ocamlopt] works without an installed OCaml interpreter, although I see nothing in the ebuild to explain why that would be the case.

If OCaml's method of generating native code is to translate OCaml source into C source, then run a C compiler on it, then any runnable architecture of OCaml could be used to perform the translation step. You would only need a C compiler for the appropriate target.
Back to top
View user's profile Send private message
Havin_it
Veteran
Veteran


Joined: 17 Jul 2005
Posts: 1247
Location: Edinburgh, UK

PostPosted: Sat May 19, 2012 5:19 pm    Post subject: Reply with quote

Hu wrote:
Cross-compilation failures should be supported on b.g.o, but you can bring them here first if you want confirmation. Did you set USE=static for the entire xmerge tree or only for unison? You should only need to set it for unison.


I did set it in /usr/i686-pc-linux-gnu/etc/make.conf but that didn't actually take effect when I ran xmerge or emerge-i686-pc-linux-gnu, so I put it in /etc/i686-pc-linux-gnu/etc/portage/package.use too. I did raise a bug as I found plenty of precedent on there.

Hu wrote:
As I read the ebuild, dev-lang/ocaml is never a runtime dependency. The check for USE=ocamlopt is because OCaml support for creating native code is an optional feature of dev-lang/ocaml, so users might have installed dev-lang/ocaml[-ocamlopt], which would give them an OCaml interpreter, but not enable them to build native code from OCaml inputs. Such users would fail to build net-misc/unison[ocamlopt]. It might be a mistake that the ebuild does not include RDEPEND+="!ocamlopt? ( dev-lang/ocaml )". Most people end up with the build time dependencies lurking on their systems indefinitely, so would not notice the mistake, if it is a mistake at all. It is also possible that net-misc/unison[-ocamlopt] works without an installed OCaml interpreter, although I see nothing in the ebuild to explain why that would be the case.


Well, I guess that'll become clearer once I can get as far as building unison...

Hu wrote:
If OCaml's method of generating native code is to translate OCaml source into C source, then run a C compiler on it, then any runnable architecture of OCaml could be used to perform the translation step. You would only need a C compiler for the appropriate target.


As long as it uses the right compiler name; might run into trouble if it just does "cc"...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum