Skip to content

Commit f19e735

Browse files
committed
feat: FFI_PORTABLE to build a maximally portable binary
Ref: filecoin-project/lotus#12423 Builds using the same flags as rust/scripts/build-release.sh does when called from CI to build the release bundle.
1 parent a6368b9 commit f19e735

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ rm .install-filcrypto \
3434
; FFI_BUILD_FROM_SOURCE=1 FFI_USE_BLST_PORTABLE=1 make
3535
```
3636

37+
Alternatively, to build a maximally portable binary without optimizing for the current CPU, set `FFI_PORTABLE=1`:
38+
39+
```shell
40+
rm .install-filcrypto \
41+
; make clean \
42+
; FFI_BUILD_FROM_SOURCE=1 FFI_PORTABLE=1 make
43+
```
44+
3745
By default, a 'gpu' option is used in the proofs library. This feature is also used in FFI unless explicitly disabled. To disable building with the 'gpu' dependency, set `FFI_USE_GPU=0`:
3846

3947
```shell
@@ -44,7 +52,7 @@ rm .install-filcrypto \
4452

4553
#### GPU support
4654

47-
CUDA for GPU support is now enabled by default in the proofs library. This feature can optionally be replaced by OpenCL by using `FFI_USE_OPENCL=1` set in the environment when building from source. Alternatively, if the CUDA toolkit (such as `nvcc`) cannot be located in the environment, OpenCL support is used instead. To disable GPU support entirely, set `FFI_USE_GPU=0` in the environment when building from source.
55+
CUDA for GPU support is now enabled by default in the proofs library. This feature can optionally be replaced by OpenCL by using `FFI_USE_OPENCL=1` set in the environment when building from source. Using `FFI_PORTABLE=1` will also enable OpenCL support. Alternatively, if the CUDA toolkit (such as `nvcc`) cannot be located in the environment, OpenCL support is used instead. To disable GPU support entirely, set `FFI_USE_GPU=0` in the environment when building from source.
4856

4957
There is experimental support for faster C2 named "SupraSeal". To enable it, set `FFI_USE_CUDA_SUPRASEAL=1`. It's specific to CUDA and won't work with OpenCL.
5058

install-filcrypto

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ build_from_source() {
190190
if [ "${FFI_USE_GPU}" == "0" ]; then
191191
gpu_flags=""
192192
# Check if OpenCL support is specified or we're building on Darwin.
193-
elif [ "${FFI_USE_OPENCL}" == "1" ] || [ "$(uname -s)" = "Darwin" ]; then
193+
elif [ "${FFI_USE_OPENCL}" == "1" ] || [ "${FFI_PORTABLE}" == "1" ] || [ "$(uname -s)" = "Darwin" ]; then
194194
gpu_flags=",opencl"
195195
else
196196
# If GPUs are enabled and SupraSeal is not, default to CUDA support
@@ -226,7 +226,7 @@ build_from_source() {
226226

227227
additional_flags=""
228228
# Add feature specific rust flags as needed here.
229-
if [ "${FFI_USE_BLST_PORTABLE}" == "1" ]; then
229+
if [ "${FFI_USE_BLST_PORTABLE}" == "1" ] || [ "${FFI_PORTABLE}" == "1" ]; then
230230
additional_flags="${additional_flags} --no-default-features --features ${use_multicore_sdr},blst-portable${gpu_flags}${use_fixed_rows_to_discard}"
231231
else
232232
additional_flags="${additional_flags} --no-default-features --features ${use_multicore_sdr}${gpu_flags}${use_fixed_rows_to_discard}"
@@ -243,6 +243,11 @@ build_from_source() {
243243
}
244244

245245
get_release_flags() {
246+
if [ "${FFI_PORTABLE}" == "1" ]; then
247+
echo ""
248+
return
249+
fi
250+
246251
local __features=""
247252

248253
# determine where to look for CPU features

0 commit comments

Comments
 (0)