Archived

This forum has been archived. Please start a new discussion on GitHub.

double data format for arm linux is not correct

Ice 3.4.1
compiler:arm-none-linux-gnueabi-c++ (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72))
target: Samsung s3c6410 (ARM11 core)

The process of porting is quit smooth ( I use only libIce and libIceUtil so I need only compile the bzip2 lib). All the functions work correctly in my test program except that the Ice::Double data type value has some problem.

when sending a Ice::Double value from a Linux or Windows(both on the same 32-bit X86 machine) Ice client to the ARM target board Ice server, the server on target board prints strange values.

After analysed the binary data of the double value , I found it's some thing related to the so called middle-endian issue.

I found a lot of articles discuss about the endian of double type on a ARM is neither big nor little, but the middle one. I noticed that in the Ice source file: cpp/src/Ice/BasicStream.cpp line 1228,1274,1316,1363,1422, there are special treatments for the predefined __arm__ and __linux macro. This is reasonable if the middle-endian on ARM is true. But on my board, it seems that it needs no treatment for it. Just comment those special lines for __arm__ and __linux(treated as normal little-endian), the Ice::Double datas on my target board print correctly.

Because I have only one type of the target board, so I can not do any more test on different ARM. So I don't know, whether it will be different on different ARM core version.

Comments

  • bernard
    bernard Jupiter, FL
    Welcome to our forums, and thank you for this report. This behavior may also depend on the options you pass to GCC.

    Please note that all ARM-related conditionals in the Ice source are currently experimental, as we do not support Ice for C++ on ARM with any toolchain.

    Once you have completed this port, perhaps you could post a source code & build system patch? I am sure other users could be interested in this platform.

    Best regards,
    Bernard
  • patch of basic Ice porting for armlinux

    Two patch files included in the attachment. One for the bzip2 one for The Ice-3.4.1 source code.

    I used the compiler from Code Sourcery Sourcery G++ Lite 2008q3-72, which is gcc version 4.3.2.

    Please notice that there are different distributes of Sourcery G++. The distribute for ARM Linux must be used.

    More recent version of Sourcery G++ can also be used to compile Ice for ARM Linux(I also tried the Sourcery G++ 2010.09-103 which compiles fine, but I meet some libstdc++.so version problem when runing the program on my target board. So I chose the older version).

    I ported only libIce and libIceUtil, those are two most core parts of the Ice library, and I use C++ language.

    And the porting to my Samsung S3C6410 target board works fine.

    before the porting, there are several things must be done first:

    1. prepare the Ice binaries that can be run on your Linux host machine. Make sure you can run the command such as slice2cpp on your command line.
    You can compile the full Ice for Linux(I use Ubuntu 10.04 lts) use the original source file from Zeroc.
    And in the following steps , I will assume that the binaries of Ice are installed in the path /opt/Ice-3.4.1 .

    2. prepare the cross-build tool chain for ARM Linux.
    You can download it from http://www.codesourcery.com.

    usage:

    1. unpack the gz file in the attachment.
    2. unpack source file folder of the bzip2-1.0.5 from the ThirdParty-Sources-3.4.1 package from Zeroc.
    3. unpack source file folder of the Ice-3.4.1 source code downloaded from Zeroc.
    4. enter the folder where you unpacked bzip2-1.0.5 folder exists.
    5. test the patch of the source codes use the following command (linux):

    patch --dry-run p1 -i /path/to/bzip2-1.0.5.armlinux.patch

    which will print some informations like this:
    patching file bzip2-1.0.5/Makefile
    patching file bzip2-1.0.5/Makefile-libbz2_so


    6. if no error, you can patch it use:

    patch -p1 -i /path/to/bzip2-1.0.5.armlinux.patch

    (in step 5,6 the /path/to refers to the real patch where the unpacked patch files exist).

    7. follow the directions in the ThirdParty release notes to make and install the bzip2 lib. May be command like this:

    cd bzip2-1.0.5
    make -f Makefile-libbz2_so
    sudo make install

    maybe you need to copy the shared lib of the bzip2 to the install folder too, but it seems that Ice builded in linux use only the static lib of bizp2.

    sudo cp libbz2.so.1.0.4 libbz2.so.1.0 /opt/arm/bzip2/lib/

    In the patch file, the make install will copy the result to the folder /opt/arm/bzip2/lib

    this path will be used in the Ice Makefile.

    8. enter the folder where you unpacked Ice-3.4.1 source file folder exists.

    9. test the patch file:

    patch --dry-run p1 -i /path/to/Ice-3.4.1.armlinux.patch

    which will display something like this:
    patching file Ice-3.4.1/cpp/config/Make.rules
    patching file Ice-3.4.1/cpp/config/Make.rules.Linux
    patching file Ice-3.4.1/cpp/include/IceUtil/Config.h
    patching file Ice-3.4.1/cpp/Makefile
    patching file Ice-3.4.1/cpp/src/Ice/BasicStream.cpp
    patching file Ice-3.4.1/cpp/src/Makefile

    10. if no error in the patch test, patch it use:

    patch p1 -i /path/to/Ice-3.4.1.armlinux.patch


    11. after patch the source file, make and make install the Ice library for armlinux:

    cd Ice-3.4.1/cpp
    make
    sudo make install

    Because I compiled only libIce and libIceUtil, the make install command will output some error when trying to copy include/IceBox. And because the copying of include/IceUtil is after the error place, so you need to copy include/IceUtil manually to the destiny install place.

    the result library will be "installed" into /opt/arm/Ice-3.4.1 . Remember that the shared library must be copied to the target board to run.

    12. more gracefully porting

    Because I only began to work on Linux platform two weeks ago, so I'm not quit familiar with the makefiles and commands on Linux.

    I'm sure that there must be some more graceful way to do these, but at this time, this is all that I can do it.