From fe1b1f6d94c196f086122613277ff95062a7e834 Mon Sep 17 00:00:00 2001 From: SiCong Li Date: Thu, 19 May 2022 18:58:31 +0100 Subject: Allow clearer suppression of toolchain and compiler prefixes Currently it is counterintuitive to disable toolchain prefixes: we need to pass an empty space to it; passing an empty string would not disable prefixes but instead instruct the build script to use a set of default prefixes. With this patch we restore the intuitive approach of passing an empty string "" to disable the prefix. Resolves COMPMID-5353, COMPMID-5380 Signed-off-by: SiCong Li Change-Id: I2fe84689df9093cf6baf507dde44ca5ebf61023b Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7686 Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice Comments-Addressed: Arm Jenkins --- SConstruct | 38 ++++++++++++++-------- docs/user_guide/how_to_build_and_run_examples.dox | 14 +++++++- docs/user_guide/release_version_and_change_log.dox | 7 ++++ 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/SConstruct b/SConstruct index 0f5df59dae..b0b5649a5c 100644 --- a/SConstruct +++ b/SConstruct @@ -118,8 +118,8 @@ vars.AddVariables( 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; 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.", ""), + ("toolchain_prefix", "Override the toolchain prefix; used by all toolchain components: compilers, linker, assembler etc. If unspecified, use default(auto) prefixes; if passed an empty string '' prefixes would be disabled", "auto"), + ("compiler_prefix", "Override the compiler prefix; used by just compilers (CC,CXX); further overrides toolchain_prefix for compilers; this is for when the compiler prefixes are different from that of the linkers, archivers etc. If unspecified, this is the same as toolchain_prefix; if passed an empty string '' prefixes would be disabled", "auto"), ("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)", ""), @@ -323,35 +323,42 @@ else: # NONE "multi_isa" builds # Define toolchain # 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 = "" +auto_toolchain_prefix = "" if 'x86' not in env['arch']: if env['estate'] == '32': if env['os'] == 'linux': - toolchain_prefix = "arm-linux-gnueabihf-" if 'v7' in env['arch'] else "armv8l-linux-gnueabihf-" + auto_toolchain_prefix = "arm-linux-gnueabihf-" if 'v7' in env['arch'] else "armv8l-linux-gnueabihf-" elif env['os'] == 'bare_metal': - toolchain_prefix = "arm-eabi-" + auto_toolchain_prefix = "arm-eabi-" elif env['os'] == 'android': - toolchain_prefix = "arm-linux-androideabi-" + auto_toolchain_prefix = "arm-linux-androideabi-" elif env['os'] == 'tizen': - toolchain_prefix = "armv7l-tizen-linux-gnueabi-" + auto_toolchain_prefix = "armv7l-tizen-linux-gnueabi-" elif env['estate'] == '64' and 'v8' in env['arch']: if env['os'] == 'linux': - toolchain_prefix = "aarch64-linux-gnu-" + auto_toolchain_prefix = "aarch64-linux-gnu-" elif env['os'] == 'bare_metal': - toolchain_prefix = "aarch64-elf-" + auto_toolchain_prefix = "aarch64-elf-" elif env['os'] == 'android': - toolchain_prefix = "aarch64-linux-android-" + auto_toolchain_prefix = "aarch64-linux-android-" elif env['os'] == 'tizen': - toolchain_prefix = "aarch64-tizen-linux-gnu-" + auto_toolchain_prefix = "aarch64-tizen-linux-gnu-" if env['build'] == 'native': toolchain_prefix = "" -if env["toolchain_prefix"] != "": +if env["toolchain_prefix"] == "": + toolchain_prefix = "" +elif env["toolchain_prefix"] == "auto": + toolchain_prefix = auto_toolchain_prefix +else: toolchain_prefix = env["toolchain_prefix"] -compiler_prefix = toolchain_prefix -if env["compiler_prefix"] != "": +if env["compiler_prefix"] == "": + compiler_prefix = "" +elif env["compiler_prefix"] == "auto": + compiler_prefix = toolchain_prefix +else: compiler_prefix = env["compiler_prefix"] env['CC'] = env['compiler_cache']+ " " + compiler_prefix + c_compiler @@ -364,6 +371,9 @@ else: env['AR'] = toolchain_prefix + "ar" env['RANLIB'] = toolchain_prefix + "ranlib" +print("Using compilers:") +print("CC", env['CC']) +print("CXX", env['CXX']) if not GetOption("help"): try: diff --git a/docs/user_guide/how_to_build_and_run_examples.dox b/docs/user_guide/how_to_build_and_run_examples.dox index ea71f6345e..ed4c6a4029 100644 --- a/docs/user_guide/how_to_build_and_run_examples.dox +++ b/docs/user_guide/how_to_build_and_run_examples.dox @@ -391,9 +391,21 @@ For NDK r18 or older, here is a guide to Download the NDK package for your development platform, without the need to launch the make_standalone_toolchain.py script. You can find all the prebuilt binaries inside $NDK/toolchains/llvm/prebuilt/$OS_ARCH/bin/. -@attention the building script will look for a binary named "aarch64-linux-android-clang++", while the prebuilt binaries will have their API version as a suffix to their filename (e.g. "aarch64-linux-android21-clang++"). You should copy/rename the binary removing this suffix, or - alternatively - create an alias for it. +@parblock +@attention The building script will look for a binary named "aarch64-linux-android-clang++", while the prebuilt binaries will have their API version as a suffix to their filename (e.g. "aarch64-linux-android21-clang++"). You can instruct scons to use the correct version by using a combination of the toolchain_prefix and the "CC" "CXX" environment variables. +@attention For this particular example, you can specify: + CC=clang CXX=clang++ scons toolchain_prefix=aarch64-linux-android21- + +@attention or: + + CC=aarch64-linux-android21-clang CXX=aarch64-linux-android21-clang++ scons toolchain_prefix="" + +@endparblock + +@parblock @attention We used to use gnustl but as of NDK r17 it is deprecated so we switched to libc++ +@endparblock @note Make sure to add the toolchains to your PATH: diff --git a/docs/user_guide/release_version_and_change_log.dox b/docs/user_guide/release_version_and_change_log.dox index 3632b27680..ac6577bae7 100644 --- a/docs/user_guide/release_version_and_change_log.dox +++ b/docs/user_guide/release_version_and_change_log.dox @@ -41,6 +41,13 @@ If there is more than one release in a month then an extra sequential number is @section S2_2_changelog Changelog +v22.08 Public major release + - Build flag change: toolchain_prefix, compiler_prefix: + - Use empty string "" to suppress any prefixes + - Use "auto" to use default (auto) prefixes chosen by the build script. This is the default behavior when unspecified + - Any other string will be used as custom prefixes to the compiler and the rest of toolchain tools + - The default behaviour when prefix is unspecified does not change, but its signifier has been changed from empty string "" to "auto" + v22.05 Public major release - Various bug fixes. - Various optimizations. -- cgit v1.2.1