sleef icon indicating copy to clipboard operation
sleef copied to clipboard

Unable to crosscompile without first building natively

Open xsacha opened this issue 5 years ago • 11 comments

I feel there's something wrong with the usage of the build tool when I have to make a complete native build prior to cross compiling. I found this script which shows the correct way to cross compile this repository: https://github.com/shibatch/sleef/blob/master/travis/before_script.aarch64-gcc.sh

The alternative, which other repositories are able to do, is to use CMake commands where possible to replace executing binaries. Also, you can create host binaries where need be and use them directly.

The mkrename binary is something that could be done fully in CMake, for example.

xsacha avatar Mar 12 '19 01:03 xsacha

It is because we migrated from makefile to cmake that the building process is not fully optimized for cmake. I was also considering replacing generators like mkrename to python scripts, but I haven’t done it because generators are not the main reason we are building natively before starting cross compiling. It’s tester. SLEEF depends on libmpfr for testing. If we don’t need to test after compilation, then we can substitute generators with scripts.

shibatch avatar Mar 12 '19 01:03 shibatch

It'll also be nice to have some instructions for cross-compilation. I spent a few hours yesterday before getting all the right ingredients in place (a pointer in the README to the travis script and maybe a mention of the NATIVE_BUILD_DIR variable would have been enought for me....)

yuyichao avatar Mar 12 '19 17:03 yuyichao

Could you explain why you need cross compilation? Generally speaking, cross compilation is not easy. It requires many bug-workarounds.

shibatch avatar Mar 13 '19 03:03 shibatch

Need cross compilation so I can compile this for iOS and Android. None of the other repositories have any issues doing this.

xsacha avatar Mar 13 '19 04:03 xsacha

iOS and Android would be worth supporting officially. Let me think.

shibatch avatar Mar 13 '19 05:03 shibatch

Android is supported by Travis. @xsacha Are you interested in also contributing CI setting for Android, and possibly iOS?

https://docs.travis-ci.com/user/languages/android/

shibatch avatar Mar 13 '19 05:03 shibatch

I know it's supported by travis and it's supported by this repository but it's just silly the way it forces you to compile a native build prior to cross compiling. That needs to be fixed.

Specifically, there should be a way to use the rename feature without compiling a binary to generate those files.

xsacha avatar Mar 13 '19 06:03 xsacha

I would say it is not a large problem that cross compilation requires a prior native build. In order to do testing, this is a necessary process. Are you thinking about the case where sleef has to be built as a submodule of another project?

shibatch avatar Mar 13 '19 06:03 shibatch

Yes, specifically, I am building sleef as a component of pytorch which is built as a component of another project. Build tools do not usually assume you have to build a package natively prior to cross compiling and then provide the native directory to the CMake in order to build it.

I have over 100 CMake packages in a single project being cross-compiled for iOS, Android, Windows and Linux and this is the first one that has required this.

Note that OpenBLAS did have a similar issue where it required natively built programs (although, not the library itself like in this instance). I fixed that with a PR here: https://github.com/xianyi/OpenBLAS/pull/1279

This project will need similar work.

xsacha avatar Mar 13 '19 06:03 xsacha

Okay, I understand. I will try to fix the problem.

shibatch avatar Mar 13 '19 06:03 shibatch

I have a proposal for the build of sleef as a submodule. The pull request is https://github.com/shibatch/sleef/pull/252.

nicolone avatar Apr 15 '19 10:04 nicolone