Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running ohNet on older levels of Linux ARM
16-03-2012, 09:49 AM
Post: #1
Running ohNet on older levels of Linux ARM
I've recently added MinimServer support for QNAP NAS devices. Some of these devices use old versions of Linux dating back to about 2006. In general, NAS devices are a few years behind the current state of the Linux world.

Unfortunately, it isn't usually possible to build a .so file for Linux ARM with a current level of gcc/glibc and run it on an older Linux ARM runtime. In contrast, building with an older compiler produces executables that will run on newer levels of the OS.

For this reason I've changed the way I'm building ohNet for Linux ARM. I'm compiling it using g++ 4.1.1 with glibc 3.2.6. This has required a few changes to Makefile which I'll post to this thread later. The resulting binaries seem to work on all variants of Linux ARM from 2006 to the present day, based on my own testing and user feedback.

I'm interested to know whether there's any interest in changing the official ohNet build for Linux ARM to use this approach. It would make the official binaries usable on a much greater variety of Linux ARM devices. Without this change, I won't be able to use the official binaries and would always need to build my own. I'd imagine that some other users of ohNet on Linux ARM would be in the same position.

Doing my own builds is a minor inconvenience. I'd have a major problem if ohNet were to start using new C++ features that aren't compatible with older compilers. Does ohNet currently have any policy on the use of newer language features?
Find all posts by this user
16-03-2012, 11:44 AM
Post: #2
RE: Running ohNet on older levels of Linux ARM
I'd be interested to see your Makefile changes. Before I could include the code and update our releasables, I'd need to check that they didn't interfere with existing clients and that they were maintainable. The former will be proved by running ohNet's unit tests (using the AllTests.py script). The latter could be addressed by adding additional tests that use your new binaries.

Are you able to look into this?

Regarding new C++ features: ohNet is a relatively mature library so its unlikely we'll find a compelling case to adopt any. The fact that (your) client code would be inconvenienced would count against take up of new features too.

I can't guarantee that we'll never use any new features but its really pretty unlikely.
Find all posts by this user
29-04-2012, 09:57 PM
Post: #3
RE: Running ohNet on older levels of Linux ARM
(16-03-2012 11:44 AM)simonc Wrote:  I'd be interested to see your Makefile changes. Before I could include the code and update our releasables, I'd need to check that they didn't interfere with existing clients and that they were maintainable. The former will be proved by running ohNet's unit tests (using the AllTests.py script). The latter could be addressed by adding additional tests that use your new binaries.

Are you able to look into this?

Yes, I'm happy to do whatever level of testing is needed to ensure that this version of the ohNet binaries works properly on all versions of Linux ARM, and that the Makefile changes don't cause any problems when building ohNet with the latest gcc for Linux ARM and for other platforms.

I'm attaching my modified Makefile to this post. To see the changes, look for "oldgcc". I've also made a change that allows the hard-wired path to libjvm.so to be overridden, as the current value only works for Linux x86.

To try this out, you'll need to install the folowing:
1) The older version of gcc that I'm using. You can download it from this link.
2) The OpenJDK 6 JDK (not JRE) for ARM. This is needed for compiling the .java files and the JNI .c files.
3) The Oracle JRE for ARM (see this link). This is needed for linking libohNetJni.so with libjvm.so, as the older version of the linker doesn't like the OpenJDK version of libjvm.so for some reason.

You'll also need to export the following environment variables before you run make:
JAVA_HOME=<path to OpenJDK>
oldgcc=yes
CROSS_COMPILE=<path to old gcc>
libjvm_dir=<path to Oracle JRE version of libjvm.so>

Quote:Regarding new C++ features: ohNet is a relatively mature library so its unlikely we'll find a compelling case to adopt any. The fact that (your) client code would be inconvenienced would count against take up of new features too.

I can't guarantee that we'll never use any new features but its really pretty unlikely.

OK, thanks!


Attached File(s)
.zip  Makefile.zip (Size: 3.34 KB / Downloads: 1)
Find all posts by this user
01-05-2012, 03:02 PM
Post: #4
RE: Running ohNet on older levels of Linux ARM
Sorry, I hadn't realised before you were proposing changing the compiler we used - I thought you were going to propose a change in compiler flags. I'm afraid I don't think it'd be appropriate to downgrade gcc for all Linux-ARM builds. It seems more correct that users who require an old compiler build from source (in the absense of an array of compiler targets from ohNet at any rate).

Changing Makefile to support more compilers does however seem very sensible so I've integrated your changes. Note that I've changed the oldgcc guards to gcc4-1 to allow for the possibility of adding support for further deprecated versions in future. This should at least mean that you won't need to edit any source or resolve conflicts when you fetch ohNet updates.

The changes are committed locally now so should be on github this evening.
Find all posts by this user
01-05-2012, 05:02 PM
Post: #5
RE: Running ohNet on older levels of Linux ARM
For my own use, I'm happy with having the Makefile adjusted so that I can use it "as is" without needing to edit it myself every time I download a new version of ohNet. Thanks for doing this.

However, for the sake of other users of ohNet on Linux ARM, I'd suggest that you consider the benefits of using an older compiler to build the binary distribution. The resulting binaries are fully upward compatible with modern versions of Linux, but the converse isn't true. So a binary built with this older compiler can run anywhere (older or newer Linux), but a binary built with the newer compiler can only run on fairly recent versions of Linux.

There might be some disadvantages of using the older compiler, but I haven't found any yet. As I said in my previous post, I'd be willing to help with testing or debugging any such problems.
Find all posts by this user
13-08-2012, 02:27 PM
Post: #6
RE: Running ohNet on older levels of Linux ARM
(01-05-2012 05:02 PM)simoncn Wrote:  For my own use, I'm happy with having the Makefile adjusted so that I can use it "as is" without needing to edit it myself every time I download a new version of ohNet. Thanks for doing this.

I now need to the same thing for Linux x86, for the same reason.

The toolchain I'm using (provided by the NAS manufacturer) has a slightly different structure than the toolchain I've been using for Linux ARM. This means the Makefile doesn't quite work. The problem is in this section:
Code:
ifeq ($(gcc4-1), yes)
    version_specific_cflags =
    version_specific_linkflags = -B${CROSS_COMPILE} -L${CROSS_COMPILE}../../lib  -L${CROSS_COMPILE}../lib
    version_specific_library_path = LD_LIBRARY_PATH=${CROSS_COMPILE}../lib
    version_specific_cflags_third_party = -Wno-non-virtual-dtor
    version_specific_includes = -I${CROSS_COMPILE}../include
    version_specific_java_cflags = -Wstrict-aliasing=0
else
    version_specific_cflags = -Wno-psabi
    version_specific_linkflags =
    version_specific_library_path =
    version_specific_cflags_third_party =
    version_specific_includes =
    version_specific_java_cflags =
endif

Some of the settings under gcc4-1 are compiler flags that genuinely relate to GCC 4.1, but other settings are related to the particular toolchain I was using.

To solve this problem, I've changed this section to the following:
Code:
ifeq ($(gcc4-1), yes)
    version_specific_cflags =
    version_specific_cflags_third_party = -Wno-non-virtual-dtor
    version_specific_java_cflags = -Wstrict-aliasing=0
else
    version_specific_cflags = -Wno-psabi
    version_specific_cflags_third_party =
    version_specific_java_cflags =
endif
version_specific_linkflags = ${CROSS_COMPILE_LINKFLAGS}
version_specific_library_path = ${CROSS_COMPILE_LIBRARY_PATH}
version_specific_includes = ${CROSS_COMPILE_INCLUDES}

This cleanly separates toolchain-related settings from compiler-specific settings, and allows the Makefile to be used without modification on different toolchains as well as different compiler levels.
Find all posts by this user
13-08-2012, 02:28 PM
Post: #7
RE: Running ohNet on older levels of Linux ARM
Thanks. On a cursory glance, the changes look good. I'll try to get them integrated in the next couple of days.
Find all posts by this user
13-08-2012, 02:33 PM
Post: #8
RE: Running ohNet on older levels of Linux ARM
(13-08-2012 02:28 PM)simonc Wrote:  Thanks. On a cursory glance, the changes look good. I'll try to get them integrated in the next couple of days.

Thanks very much!
Find all posts by this user
14-08-2012, 02:20 PM (This post was last modified: 14-08-2012 02:28 PM by simonc.)
Post: #9
RE: Running ohNet on older levels of Linux ARM
I've committed your changes now so they should be available on github this evening.
Find all posts by this user
06-09-2012, 09:19 AM
Post: #10
RE: Running ohNet on older levels of Linux ARM
(14-08-2012 02:20 PM)simonc Wrote:  I've committed your changes now so they should be available on github this evening.

I'm trying to put my build settings into environment variables so I don't need to remember to type them as part of the make command. Most are OK, but the shell doesn't recognise gcc4-1 as a valid name because of the hyphen. Would it be possible to either remove the hyphen character or change it to something else such as underscore?
Find all posts by this user


Forum Jump: