1From f71b32eb8a5c173fc5733847437b9485d75bb2e5 Mon Sep 17 00:00:00 2001
2From: Leon Anavi <leon.anavi@konsulko.com>
3Date: Fri, 9 Apr 2021 14:06:36 +0300
4Subject: [PATCH] setup.py: Fix determining target platform
5
6Do not poke at the build machine to determine target platform or architecture
7pass it from environment instead for cross compiling to work
8
9Upstream-Status: Inappropriate [OE-Specific]
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
12---
13 setup.py | 11 +++++++----
14 1 file changed, 7 insertions(+), 4 deletions(-)
15
16diff --git a/setup.py b/setup.py
17index c93d419f32..71a944a9d0 100644
18--- a/setup.py
19+++ b/setup.py
20@@ -116,6 +116,9 @@ def _env_bool_value(env_name, default):
21 BUILD_WITH_BORING_SSL_ASM = _env_bool_value('GRPC_BUILD_WITH_BORING_SSL_ASM',
22                                             'True')
23
24+BORING_SSL_PLATFORM = os.environ.get('GRPC_BORING_SSL_PLATFORM',
25+                                           'True')
26+
27 # Export this environment variable to override the platform variant that will
28 # be chosen for boringssl assembly optimizations. This option is useful when
29 # crosscompiling and the host platform as obtained by distutils.utils.get_platform()
30@@ -336,13 +339,13 @@ if BUILD_WITH_BORING_SSL_ASM and not BUILD_WITH_SYSTEM_OPENSSL:
31     LINUX_X86_64 = 'linux-x86_64'
32     LINUX_ARM = 'linux-arm'
33     LINUX_AARCH64 = 'linux-aarch64'
34-    if LINUX_X86_64 == boringssl_asm_platform:
35+    if LINUX_X86_64 == BORING_SSL_PLATFORM:
36         asm_key = 'crypto_linux_x86_64'
37-    elif LINUX_ARM == boringssl_asm_platform:
38+    elif LINUX_ARM == BORING_SSL_PLATFORM:
39         asm_key = 'crypto_linux_arm'
40-    elif LINUX_AARCH64 == boringssl_asm_platform:
41+    elif LINUX_AARCH64 == BORING_SSL_PLATFORM:
42         asm_key = 'crypto_linux_aarch64'
43-    elif "mac" in boringssl_asm_platform and "x86_64" in boringssl_asm_platform:
44+    elif "mac" in boringssl_asm_platform and "x86_64" in BORING_SSL_PLATFORM:
45         asm_key = 'crypto_mac_x86_64'
46     else:
47         print("ASM Builds for BoringSSL currently not supported on:",
48--
492.17.1
50
51