-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
README: add cross-compile #607
Conversation
Signed-off-by: Zhang fei <zhangfei@iscas.ac.cn>
Hello! Thank you very much for this initiative! I would be keen to move this to the actual documentation and keep the main README as light as possible. There is a section on cross-compilation here. Maybe we could add a section before that specifically for Linux and point to it from the main README? The changes look fine though, I'll just make a few comments, let's just make sure to not repeat information that is not already there. Cheers! |
README.md
Outdated
@@ -190,6 +190,51 @@ ctest --test-dir build -j | |||
|
|||
For more detailed build instructions please refer to the [dedicated section on CMake](./docs/1-user-guide/build-with-cmake) or to [our web page][build_info_url]. | |||
|
|||
## How to CROSS-COMPILE SLEEF | |||
Two methods are used for cross-compiling SLEEF. Here are examples of cross-compiling SLEEF for the arm architecture on a platform with X86 architecture and Linux OS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add that both rely on existing toolchain files provided in the toolchains/
directory.
README.md
Outdated
|
||
### Method 2 | ||
|
||
No need to compile the native SLEEF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add "If running via an emulator like QEMU there is ..."
README.md
Outdated
@@ -190,6 +190,51 @@ ctest --test-dir build -j | |||
|
|||
For more detailed build instructions please refer to the [dedicated section on CMake](./docs/1-user-guide/build-with-cmake) or to [our web page][build_info_url]. | |||
|
|||
## How to CROSS-COMPILE SLEEF | |||
Two methods are used for cross-compiling SLEEF. Here are examples of cross-compiling SLEEF for the arm architecture on a platform with X86 architecture and Linux OS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AArch64
README.md
Outdated
@@ -190,6 +190,51 @@ ctest --test-dir build -j | |||
|
|||
For more detailed build instructions please refer to the [dedicated section on CMake](./docs/1-user-guide/build-with-cmake) or to [our web page][build_info_url]. | |||
|
|||
## How to CROSS-COMPILE SLEEF | |||
Two methods are used for cross-compiling SLEEF. Here are examples of cross-compiling SLEEF for the arm architecture on a platform with X86 architecture and Linux OS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
say x86_64
Signed-off-by: Zhang fei <zhangfei@iscas.ac.cn>
Hi, @blapie I have made the changes according to your suggestions, could you please review it again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great thanks! Just left some nitty comments.
You don't have to but if you could maybe change the commands in the iOS section to match yours (ie use cmake), that would be great:
# Build natively first
cmake -S . -B build-native
cmake --build build-native -j --clean-first
# Then cross-compile for iOS
cmake -S . -B build-cross -DCMAKE_TOOLCHAIN_FILE=./toolchains/ios.toolchain.cmake -DNATIVE_BUILD_DIR=$(pwd)/build-native -DSLEEF_DISABLE_MPFR=TRUE -DSLEEF_DISABLE_SSL=TRUE
and
# Build natively first
cmake -S . -B build-native
cmake --build build-native -j --clean-first
# Then cross-compile for Android
cmake -S . -B build-cross -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk-r21d/build/cmake/android.toolchain.cmake -DNATIVE_BUILD_DIR=$(pwd)/build-native -DANDROID_ABI=arm64-v8a
docs/1-user-guide/README.md
Outdated
Here are examples of cross-compiling SLEEF for the AArch64 on a platform with | ||
x86_64 and Linux OS: | ||
|
||
<h3 id="method1">Method1</h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method 1
docs/1-user-guide/README.md
Outdated
cmake --build build -j --clean-first | ||
``` | ||
|
||
<h3 id="method2">Method2</h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method 2
Signed-off-by: Zhang fei <zhangfei@iscas.ac.cn>
@blapie The changes have been made, please review. |
Thank you very much, will merge when precommit tests are green. |
Currently, the SLEEF documentation lacks detailed instructions on how to perform cross-compilation, which leads users to search for related issues or CI build processes to solve problems when they encounter errors. Here are some issues encountered during cross-compilation:
Therefore, I have added instructions on how to perform cross-compilation in the README. The first method involves incorporating the SLEEF binaries that have been built natively; the second method is similar to the current SLEEF CI testing process of "Setup QEMU," and by setting the environment variable
SLEEF_TARGET_EXEC_USE_QEMU
, it allows for the compilation and execution of files like mkrename and mkalias for the target architecture without first compiling a native SLEEF. This approach is taken because SLEEF is often integrated as part of other software, such as pytorch/third_party/sleef. By introducing this method, it can reduce the need to provide a native SLEEF directory for these software packages.