fish-shell / fish-shell

The user-friendly command line shell.
https://fishshell.com
Other
26.11k stars 1.91k forks source link

Cross-Compiling for Multiple Architectures #5848

Closed JoshuaDoes closed 5 years ago

JoshuaDoes commented 5 years ago

I can't seem to find anything anywhere indicating how to build Fish for multiple architectures other than the host system's arch, and I'm not as familiar with CMake as I'd like to be. I've noticed that the nightly build servers are building the Fedora variant of Fish for all four architectures that I'd like to target (arm, arm64, x86, and x64), so hopefully I'm in the right place to ask:

How does one configure the build environment to build for a different architecture without modifying the CMake configuration files? i.e. environment variables, make parameters, etc

zanchey commented 5 years ago

All of the continuous builds are done with native building, so that's not a great indication.

https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling has the information you need, although I have no idea whether it will work. The old build system never supported cross-compilation (see #1067). In particular the check for /proc/self/stat (mostly used in calculating CPU usage) runs on the build system, not against the target, so that might blow up if your target doesn't have that file. The other check referenced in that issue has been removed, thankfully.

zanchey commented 5 years ago

I've just fixed the runtime check, so there's no impediment to cross-compiling the current git master that I'm aware of - if you could give it a go (I haven't got any useful targets) and let us know that would be great!

JoshuaDoes commented 5 years ago

I apologize for the lack of reply, but thank you!

I'll give it a go later on today and let you know how it turns out.

JoshuaDoes commented 5 years ago

Update: Attempted the following:

joshuadoes@joshuadoes:~/Projects/fish-shell/build$ cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DTHREADS_PTHREAD_ARG=0 ..
[...]
-- The following features have been enabled:

 * gettext, translate messages with gettext

-- The following OPTIONAL packages have been found:

 * Curses
 * Intl
 * Gettext

-- The following REQUIRED packages have been found:

 * Threads

-- The following features have been disabled:

 * Documentation, user manual and documentation

-- Configuring done
-- Generating done
-- Build files have been written to: /home/joshuadoes/Projects/fish-shell/build
joshuadoes@joshuadoes:~/Projects/fish-shell/build$ make
Scanning dependencies of target CHECK-FISH-BUILD-VERSION-FILE
FISH_BUILD_VERSION=3.0.2-1011-g05b2d4ee
[  0%] Built target CHECK-FISH-BUILD-VERSION-FILE
Scanning dependencies of target fishlib
[  1%] Building CXX object CMakeFiles/fishlib.dir/src/autoload.cpp.o
In file included from /home/joshuadoes/Projects/fish-shell/src/autoload.h:9:0,
                 from /home/joshuadoes/Projects/fish-shell/src/autoload.cpp:4:
/home/joshuadoes/Projects/fish-shell/src/wutil.h:15:10: fatal error: xlocale.h: No such file or directory
 #include <xlocale.h>
          ^~~~~~~~~~~
compilation terminated.
CMakeFiles/fishlib.dir/build.make:65: recipe for target 'CMakeFiles/fishlib.dir/src/autoload.cpp.o' failed
make[2]: *** [CMakeFiles/fishlib.dir/src/autoload.cpp.o] Error 1
CMakeFiles/Makefile2:947: recipe for target 'CMakeFiles/fishlib.dir/all' failed
make[1]: *** [CMakeFiles/fishlib.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

Any idea of where to go from here?

faho commented 5 years ago

@JoshuaDoes: That include is only used if HAVE_XLOCALE_H is set by cmake:

#ifdef HAVE_XLOCALE_H
#include <xlocale.h>
#endif
CHECK_INCLUDE_FILES("xlocale.h" HAVE_XLOCALE_H)

So it looks like cmake is failing to check the correct include path.

zanchey commented 5 years ago
> cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DTHREADS_PTHREAD_ARG=0

Those arguments won't be enough - you almost certainly need CMAKE_FIND_ROOT_PATH as well.