Skip to content

Cross-Compiling for Multiple Architectures #5848

Closed

Description

@JoshuaDoes

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

Activity

  1. zanchey commented on Apr 28, 2019

    @zanchey
    Member

    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.

  2. zanchey commented on Apr 30, 2019

    @zanchey
    Member

    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!

  3. JoshuaDoes commented on Apr 30, 2019

    @JoshuaDoes
    Author

    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.

  4. JoshuaDoes commented on Apr 30, 2019

    @JoshuaDoes
    Author

    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?

  5. faho commented on Apr 30, 2019

    @faho
    Member

    @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.

  6. zanchey commented on May 1, 2019

    @zanchey
    Member
    > 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.

  7. locked as resolved and limited conversation to collaborators on Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions