{"action":"closed","issue":{"url":"https://api.github.com/repos/AppImage/AppImageKit/issues/789","repository_url":"https://api.github.com/repos/AppImage/AppImageKit","labels_url":"https://api.github.com/repos/AppImage/AppImageKit/issues/789/labels{/name}","comments_url":"https://api.github.com/repos/AppImage/AppImageKit/issues/789/comments","events_url":"https://api.github.com/repos/AppImage/AppImageKit/issues/789/events","html_url":"https://github.com/AppImage/AppImageKit/issues/789","id":325277385,"node_id":"MDU6SXNzdWUzMjUyNzczODU=","number":789,"title":"Make AppImageKit more cross-compile friendly","user":{"login":"nurupo","id":1855294,"node_id":"MDQ6VXNlcjE4NTUyOTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1855294?v=4","gravatar_id":"","url":"https://api.github.com/users/nurupo","html_url":"https://github.com/nurupo","followers_url":"https://api.github.com/users/nurupo/followers","following_url":"https://api.github.com/users/nurupo/following{/other_user}","gists_url":"https://api.github.com/users/nurupo/gists{/gist_id}","starred_url":"https://api.github.com/users/nurupo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nurupo/subscriptions","organizations_url":"https://api.github.com/users/nurupo/orgs","repos_url":"https://api.github.com/users/nurupo/repos","events_url":"https://api.github.com/users/nurupo/events{/privacy}","received_events_url":"https://api.github.com/users/nurupo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":25,"created_at":"2018-05-22T12:45:14Z","updated_at":"2018-07-18T14:46:30Z","closed_at":"2018-07-18T14:46:30Z","author_association":"CONTRIBUTOR","body":"I want to cross-compile my program to several architectures (e.g. i386, x86_64, armel, armhf, etc.) and publish each as an AppImage. Besides cross-compiling my own application, I found that AppImageKit itself needs to be cross-compiled for each architecture in order to create the AppImage bundles for them. However, it has proven to be rather challenging to cross-compile AppImageKit.\r\n\r\n`src/build-runtime.sh.in` and `cmake/dependencies.cmake` are the biggest cross-compilation offenders here.\r\n\r\n- `src/build-runtime.sh.in` assumes that the build is made using system's native toolchain, it uses `gcc`, `strip`, `readelf`, `ld`, etc. without any way to specify the triplet prefix. \r\n- `cmake/dependencies.cmake` builds dependencies not found on the system without ability to set `--host=` configure's argument, which results in the build failure when cross-compiling.\r\n\r\nHere are full examples of how I have patched AppImageKit when cross-compiling it to armel and i386 on an x86_64 machine, so that you could see what I'm talking about and be able to reproduce:\r\n\r\n### armel\r\n\r\n```\r\nsudo docker run --rm -it debian:stretch-slim /bin/bash\r\n\r\ndpkg --add-architecture armel\r\napt-get update\r\napt-get install -y --no-install-recommends ca-certificates libgtest-dev:armel git ca-certificates make libarchive-dev:armel automake autoconf libtool make gcc g++ libfuse-dev:armel liblzma-dev:armel libglib2.0-dev:armel libssl-dev:armel libinotifytools0-dev:armel liblz4-dev:armel libcairo-dev:armel desktop-file-utils cmake patch wget xxd patchelf\r\n\r\napt-get install -y --no-install-recommends binutils-arm-linux-gnueabi gcc-arm-linux-gnueabi g++-arm-linux-gnueabi\r\n\r\necho \"\r\n    SET(CMAKE_SYSTEM_NAME Linux)\r\n\r\n    SET(CMAKE_C_COMPILER   /usr/bin/arm-linux-gnueabi-gcc)\r\n    SET(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabi-g++)\r\n    SET(CMAKE_AR           /usr/bin/arm-linux-gnueabi-gcc-ar CACHE FILEPATH \"Archiver\")\r\n\r\n    SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\r\n    SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\r\n    SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\r\n\" > /usr/local/share/toolchain.cmake\r\n\r\ncd /usr/src/gtest\r\ncmake -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/toolchain.cmake .\r\nmake install\r\ncd -\r\n\r\n# Make AppImageKit pick up liblzma.a instead of liblzma.so by hiding liblzma.so\r\nmv /usr/lib/arm-linux-gnueabi/liblzma.so /usr/lib/arm-linux-gnueabi/foo-liblzma.so\r\n\r\ngit clone --recursive https://github.com/AppImage/AppImageKit\r\ncd AppImageKit\r\ngit checkout c0ff6f738a65bfa890d5286d81d97754167237ea\r\n# The broken stuff\r\nsed -i 's|<SOURCE_DIR>/configure |<SOURCE_DIR>/configure --host=arm-linux-gnueabi |' cmake/dependencies.cmake\r\nsed -i 's|gcc|/usr/bin/arm-linux-gnueabi-gcc|' src/build-runtime.sh.in\r\nsed -i 's|ld |/usr/bin/arm-linux-gnueabi-ld |' src/build-runtime.sh.in\r\nsed -i 's|objcopy |/usr/bin/arm-linux-gnueabi-objcopy |' src/build-runtime.sh.in\r\nsed -i 's|readelf |/usr/bin/arm-linux-gnueabi-readelf |' src/build-runtime.sh.in\r\nsed -i 's|strip|/usr/bin/arm-linux-gnueabi-strip|' src/build-runtime.sh.in\r\nsed -i 's|objdump |/usr/bin/arm-linux-gnueabi-objdump |' src/build-runtime.sh.in\r\nmkdir build\r\ncd build\r\n# Don't mind the pkg-config command, this is not broken, that's the proper way to do it\r\nexport PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabi/pkgconfig:/usr/share/pkgconfig\r\ncmake -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/toolchain.cmake -DUSE_SYSTEM_XZ=ON -DUSE_SYSTEM_INOTIFY_TOOLS=ON -DUSE_SYSTEM_LIBARCHIVE=ON -DUSE_SYSTEM_GTEST=ON ..\r\nmake VERBOSE=1\r\nmake install\r\n\r\n# Restore it back\r\nmv /usr/lib/arm-linux-gnueabi/foo-liblzma.so /usr/lib/arm-linux-gnueabi/liblzma.so\r\n```\r\n\r\n### i386\r\n\r\n```\r\nsudo docker run --rm -it debian:stretch-slim /bin/bash\r\n\r\ndpkg --add-architecture i386\r\napt-get update\r\napt-get install -y --no-install-recommends ca-certificates git lib32z1-dev libgtest-dev:i386 gcc-multilib g++-multilib libarchive-dev:i386 automake autoconf libtool make gcc g++ libfuse-dev:i386 liblzma-dev:i386 libglib2.0-dev:i386 libssl-dev:i386 libinotifytools0-dev:i386 liblz4-dev:i386 libcairo-dev:i386 desktop-file-utils cmake patch wget xxd patchelf\r\n\r\n# There is no i386 cross-toolchain, you are supposed to use the multilib support for it, so let's create mock toolchain\r\n\r\necho '\r\n#!/bin/sh\r\n/usr/bin/x86_64-linux-gnu-gcc -m32 \"$@\"\r\n' > /usr/bin/i386-linux-gnu-gcc\r\nchmod +x /usr/bin/i386-linux-gnu-gcc\r\n\r\necho '\r\n#!/bin/sh\r\n/usr/bin/x86_64-linux-gnu-g++ -m32 \"$@\"\r\n' > /usr/bin/i386-linux-gnu-g++\r\nchmod +x /usr/bin/i386-linux-gnu-g++\r\n\r\necho '\r\n#!/bin/sh\r\n/usr/bin/x86_64-linux-gnu-ar \"$@\"\r\n' > /usr/bin/i386-linux-gnu-ar\r\nchmod +x /usr/bin/i386-linux-gnu-ar\r\n\r\necho \"\r\n    SET(CMAKE_SYSTEM_NAME Linux)\r\n\r\n    SET(CMAKE_C_COMPILER   /usr/bin/i386-linux-gnu-gcc)\r\n    SET(CMAKE_CXX_COMPILER /usr/bin/i386-linux-gnu-g++)\r\n    SET(CMAKE_AR           /usr/bin/i386-linux-gnu-ar CACHE FILEPATH \"Archiver\")\r\n\r\n    SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\r\n    SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\r\n    SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\r\n\" > /usr/local/share/toolchain.cmake\r\n\r\ncd /usr/src/gtest\r\ncmake -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/toolchain.cmake .\r\nmake install\r\ncd -\r\n\r\ngit clone --recursive https://github.com/AppImage/AppImageKit\r\ncd AppImageKit\r\ngit checkout c0ff6f738a65bfa890d5286d81d97754167237ea\r\n# The broken stuff\r\nsed -i 's|gcc|/usr/bin/i386-linux-gnu-gcc|' src/build-runtime.sh.in\r\nsed -i 's|ld |ld -m elf_i386 |' src/build-runtime.sh.in\r\nmkdir build\r\ncd build\r\n# Don't mind the pkg-config command, this is not broken, that's the proper way to do it\r\nexport PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig:/usr/share/pkgconfig\r\ncmake -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/toolchain.cmake -DUSE_SYSTEM_XZ=ON -DUSE_SYSTEM_INOTIFY_TOOLS=ON -DUSE_SYSTEM_LIBARCHIVE=ON -DUSE_SYSTEM_GTEST=ON ..\r\nmake VERBOSE=1\r\nmake install\r\n```"}}
{"actor":{"display_login":"TheAssassin"}}