Add documentations about compiler_prefix and toolchain_prefix

Related to: COMPMID-4985

Signed-off-by: SiCongLi <sicong.li@arm.com>
Change-Id: I5f2bd81abd6c90e6bf53068e21f751cdcc5732af
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7346
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
diff --git a/SConstruct b/SConstruct
index fedf856..13da026 100644
--- a/SConstruct
+++ b/SConstruct
@@ -117,8 +117,8 @@
     ListVariable("custom_options", "Custom options that can be used to turn on/off features", "none", ["disable_mmla_fp"]),
     ListVariable("data_type_support", "Enable a list of data types to support", "all", ["qasymm8", "qasymm8_signed", "qsymm16", "fp16", "fp32", "integer"]),
     ListVariable("data_layout_support", "Enable a list of data layout to support", "all", ["nhwc", "nchw"]),
-    ("toolchain_prefix", "Override the toolchain prefix", ""),
-    ("compiler_prefix", "Override the compiler prefix", ""),
+    ("toolchain_prefix", "Override the toolchain prefix; used by all toolchain components: compilers, linker, assembler etc.", ""),
+    ("compiler_prefix", "Override the compiler prefix; used by just compilers (CC,CXX); further overrides toolchain_prefix for compilers; if left empty, SCons only uses toolchain_prefix; this is for when the compiler prefixes are different from that of the linkers, archivers etc.", ""),
     ("extra_cxx_flags", "Extra CXX flags to be appended to the build command", ""),
     ("extra_link_flags", "Extra LD flags to be appended to the build command", ""),
     ("compiler_cache", "Command to prefix to the C and C++ compiler (e.g ccache)", ""),
@@ -270,7 +270,6 @@
         env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2'])
 
 # Add architecture specific flags
-prefix = ""
 if env['multi_isa']:
     # assert arch version is v8
     if 'v8' not in env['arch']:
@@ -321,49 +320,49 @@
             env.Append(LINKFLAGS = ['-m64'])
 
 # Define toolchain
-prefix = ""
+# The reason why we distinguish toolchain_prefix from compiler_prefix is for cases where the linkers/archivers use a
+# different prefix than the compilers. An example is the NDK r20 toolchain
+toolchain_prefix = ""
 if 'x86' not in env['arch']:
     if env['estate'] == '32':
         if env['os'] == 'linux':
-            prefix = "arm-linux-gnueabihf-" if 'v7' in env['arch'] else "armv8l-linux-gnueabihf-"
+            toolchain_prefix = "arm-linux-gnueabihf-" if 'v7' in env['arch'] else "armv8l-linux-gnueabihf-"
         elif env['os'] == 'bare_metal':
-            prefix = "arm-eabi-"
+            toolchain_prefix = "arm-eabi-"
         elif env['os'] == 'android':
-            prefix = "arm-linux-androideabi-"
+            toolchain_prefix = "arm-linux-androideabi-"
         elif env['os'] == 'tizen':
-            prefix = "armv7l-tizen-linux-gnueabi-"
+            toolchain_prefix = "armv7l-tizen-linux-gnueabi-"
     elif env['estate'] == '64' and 'v8' in env['arch']:
         if env['os'] == 'linux':
-            prefix = "aarch64-linux-gnu-"
+            toolchain_prefix = "aarch64-linux-gnu-"
         elif env['os'] == 'bare_metal':
-            prefix = "aarch64-elf-"
+            toolchain_prefix = "aarch64-elf-"
         elif env['os'] == 'android':
-            prefix = "aarch64-linux-android-"
+            toolchain_prefix = "aarch64-linux-android-"
         elif env['os'] == 'tizen':
-            prefix = "aarch64-tizen-linux-gnu-"
+            toolchain_prefix = "aarch64-tizen-linux-gnu-"
 
 if env['build'] == 'native':
-    prefix = ""
+    toolchain_prefix = ""
 
 if env["toolchain_prefix"] != "":
-    prefix = env["toolchain_prefix"]
+    toolchain_prefix = env["toolchain_prefix"]
 
-compiler_prefix = prefix
+compiler_prefix = toolchain_prefix
 if env["compiler_prefix"] != "":
     compiler_prefix = env["compiler_prefix"]
 
 env['CC'] = env['compiler_cache']+ " " + compiler_prefix + c_compiler
 env['CXX'] = env['compiler_cache']+ " " + compiler_prefix + cpp_compiler
-env['LD'] = prefix + "ld"
-env['AS'] = prefix + "as"
-
-
+env['LD'] = toolchain_prefix + "ld"
+env['AS'] = toolchain_prefix + "as"
 if env['os'] == 'windows':
     env['AR'] = "LIB"
 else:
-    env['AR'] = prefix + "ar"
+    env['AR'] = toolchain_prefix + "ar"
+env['RANLIB'] = toolchain_prefix + "ranlib"
 
-env['RANLIB'] = prefix + "ranlib"
 
 if not GetOption("help"):
     try: