From c4fe2a1311d4bde21ed84280559b43f35e41c32a Mon Sep 17 00:00:00 2001 From: Javernaut Date: Mon, 20 Apr 2020 16:33:11 +0300 Subject: [PATCH] Choosing between gnu and llvm binutils --- scripts/export-build-variables.sh | 19 ++++++++++++++----- scripts/ffmpeg/build.sh | 1 + scripts/parse-arguments.sh | 25 ++++++++++++++++--------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/scripts/export-build-variables.sh b/scripts/export-build-variables.sh index f18b5fc..963c234 100755 --- a/scripts/export-build-variables.sh +++ b/scripts/export-build-variables.sh @@ -54,7 +54,12 @@ export TARGET_TRIPLE_MACHINE_CC=$TARGET_TRIPLE_MACHINE_CC export CPU_FAMILY=$CPU_FAMILY # Common prefix for ld, as, etc. -export CROSS_PREFIX=${TARGET_TRIPLE_MACHINE_BINUTILS}-linux-${TARGET_TRIPLE_OS}- +if [ $DESIRED_BINUTILS = "gnu" ] ; then + export CROSS_PREFIX=${TARGET_TRIPLE_MACHINE_BINUTILS}-linux-${TARGET_TRIPLE_OS}- +else + export CROSS_PREFIX=llvm- +fi + export CROSS_PREFIX_WITH_PATH=${TOOLCHAIN_PATH}/bin/${CROSS_PREFIX} # Exporting Binutils paths, if passing just CROSS_PREFIX_WITH_PATH is not enough @@ -62,10 +67,6 @@ export CROSS_PREFIX_WITH_PATH=${TOOLCHAIN_PATH}/bin/${CROSS_PREFIX} export FAM_ADDR2LINE=${CROSS_PREFIX_WITH_PATH}addr2line export FAM_AR=${CROSS_PREFIX_WITH_PATH}ar export FAM_AS=${CROSS_PREFIX_WITH_PATH}as -export FAM_DWP=${CROSS_PREFIX_WITH_PATH}dwp -export FAM_ELFEDIT=${CROSS_PREFIX_WITH_PATH}elfedit -export FAM_GPROF=${CROSS_PREFIX_WITH_PATH}gprof -export FAM_LD=${CROSS_PREFIX_WITH_PATH}ld export FAM_NM=${CROSS_PREFIX_WITH_PATH}nm export FAM_OBJCOPY=${CROSS_PREFIX_WITH_PATH}objcopy export FAM_OBJDUMP=${CROSS_PREFIX_WITH_PATH}objdump @@ -79,6 +80,14 @@ export TARGET=${TARGET_TRIPLE_MACHINE_CC}-linux-${TARGET_TRIPLE_OS}${ANDROID_PLA # The name for compiler is slightly different, so it is defined separatly. export FAM_CC=${TOOLCHAIN_PATH}/bin/${TARGET}-clang export FAM_CXX=${FAM_CC}++ + +if [ $DESIRED_BINUTILS = "gnu" ] ; then + export FAM_LD=${CROSS_PREFIX_WITH_PATH}ld +else + # If desired binutils has to be 'llvm', then use clang as linker. + export FAM_LD=${FAM_CC} +fi + # TODO consider abondaning this strategy of defining the name of the clang wrapper # in favour of just passing -mstackrealign and -fno-addrsig depending on # ANDROID_ABI, ANDROID_PLATFORM and NDK's version diff --git a/scripts/ffmpeg/build.sh b/scripts/ffmpeg/build.sh index dc793da..a39dbcf 100755 --- a/scripts/ffmpeg/build.sh +++ b/scripts/ffmpeg/build.sh @@ -29,6 +29,7 @@ DEP_LD_FLAGS="-L${BUILD_DIR_EXTERNAL}/${ANDROID_ABI}/lib $FFMPEG_EXTRA_LD_FLAGS" --sysroot=${SYSROOT_PATH} \ --cross-prefix=${CROSS_PREFIX_WITH_PATH} \ --cc=${FAM_CC} \ + --ld=${FAM_LD} \ --extra-cflags="-O3 -fPIC $DEP_CFLAGS" \ --extra-ldflags="$DEP_LD_FLAGS" \ --enable-shared \ diff --git a/scripts/parse-arguments.sh b/scripts/parse-arguments.sh index 20be61d..5756530 100755 --- a/scripts/parse-arguments.sh +++ b/scripts/parse-arguments.sh @@ -10,10 +10,10 @@ ABIS_TO_BUILD=() API_LEVEL=16 SOURCE_TYPE=TAR SOURCE_VALUE=4.2.2 +BINUTILS=gnu EXTERNAL_LIBRARIES=() -for argument in "$@" -do +for argument in "$@"; do case $argument in # Build for only specified ABIs (separated by comma) --target-abis=*|-abis=*) @@ -38,43 +38,49 @@ do # Use this value as Android platform version during compilation. --android-api-level=*|-android=*) API_LEVEL="${argument#*=}" - shift ;; # Checkout the particular tag in the FFmpeg's git repository --source-git-tag=*) SOURCE_TYPE=GIT_TAG SOURCE_VALUE="${argument#*=}" - shift ;; # Checkout the particular branch in the FFmpeg's git repository --source-git-branch=*) SOURCE_TYPE=GIT_BRANCH SOURCE_VALUE="${argument#*=}" - shift ;; # Download the particular tar archive by its version --source-tar=*) SOURCE_TYPE=TAR SOURCE_VALUE="${argument#*=}" - shift + ;; + # Which binutils to use (gnu or llvm) + --binutils=*) + binutils_value="${argument#*=}" + case $binutils_value in + gnu|llvm) + BINUTILS=$binutils_value + ;; + *) + echo "Unknown binutils: $binutils_value" + ;; + esac ;; # Arguments below enable certain external libraries to build into FFmpeg --enable-libaom|-aom) EXTERNAL_LIBRARIES+=( "libaom" ) - shift ;; --enable-libdav1d|-dav1d) EXTERNAL_LIBRARIES+=( "libdav1d" ) - shift ;; --enable-libmp3lame|-mp3lame) EXTERNAL_LIBRARIES+=( "libmp3lame" ) - shift ;; *) echo "Unknown argument $argument" ;; esac + shift done # if ABIS_TO_BUILD list is empty, then fill it with all supported ABIs @@ -97,3 +103,4 @@ export FFMPEG_EXTERNAL_LIBRARIES=${EXTERNAL_LIBRARIES[@]} # Desired Android API level to use during compilation # Will be replaced with 21 for 64bit ABIs if the value is less than 21 export DESIRED_ANDROID_API_LEVEL=${API_LEVEL} +export DESIRED_BINUTILS=${BINUTILS}