Tookmund / Swapspace

A fork of Jeroen T. Vermeulen's excellent dynamic swap space manager
GNU General Public License v2.0
139 stars 13 forks source link

Port to ARM? #12

Closed nick-s-b closed 6 years ago

nick-s-b commented 6 years ago

I don't have much use for swap on x86/x86-64 architectures but I do use swap files on ARM due to limited RAM. Has anyone managed to compile swapspace on ARM? How difficult would it be to port swapspace to ARM?

Thanks!

chungy commented 6 years ago

Have you ran into any issues with it on ARM?

nick-s-b commented 6 years ago

@chungy I attempted to install it with pacman on my Raspi. Immediately I was given an error that the arch wasn't supported. Not sure if compiling manually would work... I'll give it a try later today.

chungy commented 6 years ago

Sounds like a purely pacman thing. Since only a single architecture (x86_64) is currently with official Arch support, you can expect a lot of them won't include others in the arch array.

swapspace itself should work fine on ARM, or pretty much any other CPU Linux supports. If it doesn't, please file an issue report about that!

nick-s-b commented 6 years ago

Here's the error message:

gcc --std=gnu99 -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wl,-O1,--sort-common,--as-needed,-z,relro -o hog hog.o 
/usr/bin/ld: hog.o: relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
hog.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Tookmund commented 6 years ago
/usr/bin/ld: hog.o: relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC

I don't have Pi I can test on at the moment, and I haven't used this is quite a while but there are a couple things you can try to fix this.

  1. Follow the instructions from the error message. This would require added -fPIC to the compile flags, either in src/Makefile.am line 1:
    AM_CFLAGS = --std=gnu99 -fPIC

    Or when running make, as in:

    make CFLAGS="--std=gnu99 -fPIC"
  2. Remove hog from the build hog is a tool for testing swapspace and is not required to use it. Removing src/Makefile.am lines 8 and 9 removes hog from the build:
    noinst_PROGRAMS = hog
    hog_SOURCES = hog.c

    I haven't tested either solution but they should work. Good luck!

Tookmund commented 6 years ago

I've now built this on a Pi and had no issues. Thus I'm closing this issue. Feel free to reopen if you continue to experience this build issue with the latest version.