From 66e26ed6ec5b431f0b9d2fe0e8417ea5d7e37a63 Mon Sep 17 00:00:00 2001 From: lozo2010 Date: Tue, 28 Jul 2015 22:22:13 +0200 Subject: [PATCH 01/16] Remove --block --- core/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/core/Makefile b/core/Makefile index aa0d267869..eff8b8adef 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1705,7 +1705,6 @@ $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS) @echo -e ${CL_YLW}"Package OTA:"${CL_RST}" $@" $(hide) MKBOOTIMG=$(MKBOOTIMG) \ $(OTA_FROM_TARGET_SCRIPT) -v \ - --block \ $(if $(WITH_LZMA_OTA), -z) \ -p $(HOST_OUT) \ -k $(KEY_CERT_PAIR) \ From 06eb8ec297aef8bf484cd90c28577e5559bd961a Mon Sep 17 00:00:00 2001 From: David Date: Fri, 31 Jul 2015 17:27:28 +0200 Subject: [PATCH 02/16] pngquant --- core/Makefile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/Makefile b/core/Makefile index eff8b8adef..6c10ac0e58 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1031,7 +1031,13 @@ INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \ $(PDK_FUSION_SYSIMG_FILES) \ $(RECOVERY_RESOURCE_ZIP)) -FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS) +systemimage-squisher: $(INTERNAL_SYSTEMIMAGE_FILES) + @echo -e ${CL_YLW}"Optimizing PNGs to Shrink ROM Size!"${CL_RST} + $(hide) APKCERTS=$(APKCERTS_FILE) $(SQUISHER_SCRIPT) $@ + +.PHONY: systemimage-squisher + +FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS) systemimage-squisher # ----------------------------------------------------------------- # installed file list # Depending on anything that $(BUILT_SYSTEMIMAGE) depends on. @@ -1727,9 +1733,10 @@ endif bacon: otapackage $(hide) ln -f $(INTERNAL_OTA_PACKAGE_TARGET) $(SLIM_TARGET_PACKAGE) - $(hide) $(MD5SUM) $(SLIM_TARGET_PACKAGE) > $(SLIM_TARGET_PACKAGE).md5sum - @echo -e ${CL_CYN}"Package Complete: $(SLIM_TARGET_PACKAGE)"${CL_RST} - +ifdef FINISHER_SCRIPT + @echo -e ${CL_YLW}"Running finisher..."${CL_RST} + $(hide) $(FINISHER_SCRIPT) $@ +endif bootzip: bootimage $(BOOT_ZIP_FROM_IMAGE_SCRIPT) \ $(recovery_fstab) \ From 595224ed3e8bfb0674e25544da11e7de0a3373c3 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 28 Aug 2015 22:02:24 +0200 Subject: [PATCH 03/16] Automatizar compilacion --- target/product/core.mk | 3 --- target/product/generic_no_telephony.mk | 3 --- tools/releasetools/edify_generator.py | 5 ++++ tools/releasetools/ota_from_target_files | 34 +++++++++++++++--------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/target/product/core.mk b/target/product/core.mk index e7a8d3d7fa..0b33d884b9 100644 --- a/target/product/core.mk +++ b/target/product/core.mk @@ -21,7 +21,6 @@ # core_tiny.mk in addition to core_minimal.mk. PRODUCT_PACKAGES += \ - BasicDreams \ Browser \ Calculator \ Calendar \ @@ -32,8 +31,6 @@ PRODUCT_PACKAGES += \ DeskClock \ DocumentsUI \ DownloadProviderUi \ - Email \ - Exchange2 \ ExternalStorageProvider \ FusedLocation \ InputDevices \ diff --git a/target/product/generic_no_telephony.mk b/target/product/generic_no_telephony.mk index e60e63c1fa..0c38c0ccbe 100644 --- a/target/product/generic_no_telephony.mk +++ b/target/product/generic_no_telephony.mk @@ -19,10 +19,7 @@ PRODUCT_PACKAGES := \ Bluetooth \ - Camera2 \ Gallery2 \ - Email \ - Exchange2 \ MusicFX \ OneTimeInitializer \ Provision \ diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py index c566efdc12..d8c7c4913a 100644 --- a/tools/releasetools/edify_generator.py +++ b/tools/releasetools/edify_generator.py @@ -154,6 +154,11 @@ def ValidateSignatures(self, command): # Exit code 124 == abort. run_program returns raw, so left-shift 8bit self.script.append('run_program("/tmp/install/bin/otasigcheck.sh") != "31744" || abort("Can\'t install this package on top of incompatible data. Please try another package or run a factory reset");') + def FlashSuperSU(self): + self.script.append('package_extract_dir("supersu", "/tmp/supersu");') + self.script.append('run_program("/sbin/busybox", "unzip", "/tmp/supersu/supersu.zip", "META-INF/com/google/android/*", "-d", "/tmp/supersu");') + self.script.append('run_program("/sbin/busybox", "sh", "/tmp/supersu/META-INF/com/google/android/update-binary", "dummy", "1", "/tmp/supersu/supersu.zip");') + def ShowProgress(self, frac, dur): """Update the progress bar, advancing it over 'frac' over the next 'dur' seconds. 'dur' may be zero to advance it via SetProgress diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index cc64c8376d..f5b564dc96 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -593,18 +593,12 @@ else if get_stage("%(bcb_dev)s") == "3/3" then system_progress = 0.75 - script.Print(" _____________________ ") - script.Print(" / www.slimroms.eu |") - script.Print(" / |") - script.Print(" / ___________________|") - script.Print(" / / ___ ") - script.Print(" / / ___/ \ ") - script.Print(" / / / \___/____ ____ ") - script.Print(" / / | |___/ \_/ |") - script.Print(" ___________/ / | | | |") - script.Print("| / | | | | | |") - script.Print("| / | | | | | |") - script.Print("|_____________/ \___^___^___^___^___/") + script.Print("------------------------------------------") + script.Print("- NUCLEARSLIM -") + script.Print("- -") + script.Print("- BY -") + script.Print("- NuclearTeam -") + script.Print("------------------------------------------") script.Print(" ") if OPTIONS.wipe_user_data: @@ -693,6 +687,16 @@ else if get_stage("%(bcb_dev)s") == "3/3" then if block_based: script.Unmount("/system") + + + script.Print("Flashing SuperSU...") + common.ZipWriteStr(output_zip, "supersu/supersu.zip", + ""+input_zip.read("SYSTEM/addon.d/UPDATE-SuperSU.zip")) + script.Mount("/system") + script.FlashSuperSU() + + + script.ShowProgress(0.05, 5) script.WriteRawImage("/boot", "boot.img") @@ -702,6 +706,12 @@ else if get_stage("%(bcb_dev)s") == "3/3" then if OPTIONS.extra_script is not None: script.AppendExtra(OPTIONS.extra_script) + # SuperSU leave /system unmounted while we need it mounted here to avoid + # a warning from non-Multirom TWRP + if block_based: + script.Mount("/system") + + script.UnmountAll() if OPTIONS.wipe_user_data: From 98522118af73c309b17fcd3e3719f825efcd51ce Mon Sep 17 00:00:00 2001 From: David Date: Sat, 29 Aug 2015 11:36:35 +0200 Subject: [PATCH 04/16] Editar build.prop --- core/main.mk | 16 ++++++++++++++++ tools/buildinfo.sh | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core/main.mk b/core/main.mk index 4575b9ec0c..8f68733108 100644 --- a/core/main.mk +++ b/core/main.mk @@ -431,6 +431,22 @@ ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android # the cause of ANRs in the content process ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt +#añado al build.prop los tweaks de Alex +# +# tweaks BUILD.prop +# +#Performance 1.0 (libera ram y mejora autonomía de batería) +#ADDITIONAL_BUILD_PROPERTIES += sysctl -w vm.oom_kill_allocating_task=1 +#ADDITIONAL_BUILD_PROPERTIES += sysctl -w vm.vfs_cache_pressure=10 + + +# Mejora el rendimiento de la bateria +ADDITIONAL_BUILD_PROPERTIES += ro.ril.disable.power.collapse=1 +ADDITIONAL_BUILD_PROPERTIES += pm.sleep_mode=1 + +# Mejora rendimiento del touch +ADDITIONAL_BUILD_PROPERTIES += debug.performance.tuning=1 + # ------------------------------------------------------------ # Define a function that, given a list of module tags, returns # non-empty if that module should be installed in /system. diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh index 51b21cacd6..0a1e5d7ec6 100755 --- a/tools/buildinfo.sh +++ b/tools/buildinfo.sh @@ -35,10 +35,10 @@ echo "ro.product.cpu.abilist64=$TARGET_CPU_ABI_LIST_64_BIT" echo "ro.product.manufacturer=$PRODUCT_MANUFACTURER" if [ -n "$PRODUCT_DEFAULT_LANGUAGE" ] ; then - echo "ro.product.locale.language=$PRODUCT_DEFAULT_LANGUAGE" + echo "ro.product.locale.language=es" fi if [ -n "$PRODUCT_DEFAULT_REGION" ] ; then - echo "ro.product.locale.region=$PRODUCT_DEFAULT_REGION" + echo "ro.product.locale.region=ES" fi echo "ro.wifi.channels=$PRODUCT_DEFAULT_WIFI_CHANNELS" echo "ro.board.platform=$TARGET_BOARD_PLATFORM" From e4323ac21285b77391d93d37ed1310b9d51ae352 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 8 Aug 2015 16:05:16 +0200 Subject: [PATCH 05/16] Use Qualcomm Snapdragon LLVM Compiler 3.6 (https://developer.qualcomm.com/mobile-development/increase-app-performance/snapdragon-llvm-compiler-android) for Android Lollipop 5.x for devices with Qualcomm CPU As far as I know nobody has done that yet. Except me :) This changes the toolchain for CLANG from the default one which comes with Android (aCLANG) to the Qualcomm Snapdragon LLVM Compiler 3.6 (qCLANG) mentioned above. The toolchain will be used for almost all places where the default Android CLANG (aCLANG) is used for compiling TARGET MODULES. BUT ONLY if "USE_CLANG_QCOM := true" is set. Otherwise it is using aCLANG. So you can merge this commit and the build will be the same as before except you specifically define "USE_CLANG_QCOM := true"! WARNING: THIS IS NOT FULLY TESTED FOR STABILITY YET. READ CAREFULLY It is very likely that using this toolchain, especially with the optimizations flags, will introduce BUGS! I would suggest: IF YOU USE IT DONT MAKE BUG REPORTS FOR YOUR OFFICIAL ROM OR KERNEL OR ANY APPS. Make reports in the development thread. The ROM compiles, boots and starts. Also if Bionic and other modules are compiled with Qualcomm Snapdragon LLVM Compiler 3.6 (qCLANG). Androbench, Antutu, Basemark 2.0 , Geekbench 3, Vellamo are 'completing' the benchmarks. This is a work in progress. There is confirmation that it works for Sony Z Ultra and Samsung Galaxy Note 4 and after some months of testing everything seems good. At the moment this is only tested with Qualcomm Snapdragon but in theory this should also work with any Krait and even Scorpion CPU. According to Documentation there is also support for armv8/aarch64 (Snapdragon 810) and you should gain a real performance bump but support is not yet implemented! If you have a Snapdragon 810 device and want to try this out contact me please. Install instructions: 1. You have to make an account in order to download the toolchain! 2. You need to download the toolchain and extract it to {your android dir}/prebuilts/clang/linux-x86/host/* 3. Add the repo (https://github.com/mustermaxmueller/clanglibs) to your manifest. For example: 4. Replace the compiler-rt repo with this one https://github.com/mustermaxmueller/compiler-rt in your manifest For example: 5. Add my build repo https://github.com/mustermaxmueller/android_build/ or merge my changes. For example: 6. Add my frameworks_rs repo https://github.com/mustermaxmueller/android_frameworks_rs or merge my changes. For example: You need the Qualcomm Snapdragon LLVM Compiler 3.5 for this to work!!! OR Make changes to frameworks/rs/driver/runtime/build_bc_lib_internal.mk like stated here: http://forum.xda-developers.com/showpost.php?p=59626153&postcount=47 7. Change following line in following files: prebuilts/ndk/current/platforms/android-14/arch-arm/usr/include/math.h prebuilts/ndk/current/platforms/android-8/arch-arm/usr/include/math.h from #if !defined(__clang__) || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) to #if !defined(__clang__) || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 7) 8. Set "USE_CLANG_QCOM := true" e.g. in Boardconfig.mk OPTIONAL (set these options in your Boardconfig.mk): USE_CLANG_QCOM_VERBOSE := true (give extra output when compiling) USE_CLANG_QCOM_LTO := true (use LTO; not working at the moment) CLANG_QCOM_COMPILE_ART := true (compile art with qclang; not working at the moment!) CLANG_QCOM_COMPILE_BIONIC := true (compile bionic with qclang) CLANG_QCOM_COMPILE_MIXED := true (compile defined modules with qclang) CLANG_QCOM_FORCE_COMPILE_MODULES += (Here you can overwrite which modules should be compiled with qCLANG instead of GCC) CLANG_QCOM_FORCE_COMPILE_ACLANG_MODULES += (Here you can overwrite which modules should be compiled with aCLANG instead of qCLANG) CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES += (Here you can overwrite which modules shouldnt be compiled with -Ofast) 9. Add "USE_CLANG_QCOM := true" to your Boardconfig.mk/BoardconfigCommon.mk of your device. (If you want to be certain that qclang is used,also set "USE_CLANG_QCOM_VERBOSE := true" in your Boardconfig.mk and you will see the verbose output while compiling.) 10. Make a clean compile! Also delete ccache! Annotation: 1. You should only get measurable performance benefits if you compile Bionic with CLANG! 2. Documentation for the toolchain: {your android dir}/prebuilts/clang/linux-x86/host/llvm-Snapdragon_LLVM_for_Android_3.6/Snapdragon_LLVM_ARM_36_User_Guide.pdf 3. The Flags "-muse-optlibc" and "-ffuse-loops" are not Documented. (http://pastebin.com/PZtk6WHB) 4. The implementation is not beautiful but it works 5. HOST is compiled with aCLANG because qCLANG does not understand x86 6. You can make performance and size comparisons by removing/commenting "USE_CLANG_QCOM := true" 7. I could have made the installation easier by uploading the toolchain to Github but I do not know if I am allowed to. And I am no lawyer so... TODO: -Make more performance comparisons to aCLANG and GCC. It seems good even compared to GCC -Use ccache -Where does it make sense to use qCLANG instead of GCC? -Compile Android with qCLANG wherever possible. http://www.linuxplumbersconf.org/2013/ocw/system/presentations/1131/original/LP2013-Android-clang.pdf and https://events.linuxfoundation.org/sites/events/files/slides/2014-ABS-LLVMLinux.pdf Development Thread: http://forum.xda-developers.com/android/software-hacking/wip-compile-android-5-0-2-qualcomm-llvm-t3035162 --- core/binary.mk | 55 ++++- core/clang/TARGET_arm_qcom.mk | 405 +++++++++++++++++++++++++++++++ core/clang/clang_qcom_global.mk | 26 ++ core/clang/clang_qcom_local.mk | 54 +++++ core/clang/clang_qcom_objects.mk | 20 ++ core/clang/config.mk | 5 + 6 files changed, 555 insertions(+), 10 deletions(-) create mode 100755 core/clang/TARGET_arm_qcom.mk create mode 100644 core/clang/clang_qcom_global.mk create mode 100644 core/clang/clang_qcom_local.mk create mode 100644 core/clang/clang_qcom_objects.mk diff --git a/core/binary.mk b/core/binary.mk index 170e20c5e6..2153404f26 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -97,6 +97,17 @@ else endif endif +ifeq ($(USE_CLANG_QCOM),true) + ifndef LOCAL_IS_HOST_MODULE + ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_FORCE_COMPILE_MODULES))) + LOCAL_CLANG := true + endif + #ifneq ($(LOCAL_CLANG),true) + # $(info gcc target module: $(LOCAL_MODULE)) + #endif + endif +endif + # The following LOCAL_ variables will be modified in this file. # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch, # we can't modify them in place. @@ -242,10 +253,14 @@ my_target_global_cppflags := endif # LOCAL_SDK_VERSION ifeq ($(my_clang),true) -my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) -my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) -my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) -my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES) + ifeq ($(USE_CLANG_QCOM)$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_MODULES)),true) + include $(BUILD_SYSTEM)/clang/clang_qcom_global.mk + else + my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES) + my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) + my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) + my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) + endif else my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS) my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS) @@ -365,8 +380,17 @@ normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS) normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS) ifeq ($(strip $(my_clang)),true) -arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) -normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) + ifndef LOCAL_IS_HOST_MODULE + ifeq ($(USE_CLANG_QCOM)$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_MODULES)),true) + include $(BUILD_SYSTEM)/clang/clang_qcom_objects.mk + else + arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) + normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) + endif + else + arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) + normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) + endif endif else @@ -923,10 +947,21 @@ endif ########################################################### ifeq ($(my_clang),true) -my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) -my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) -my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) -my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) + ifndef LOCAL_IS_HOST_MODULE + ifeq ($(USE_CLANG_QCOM)$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_MODULES)),true) + include $(BUILD_SYSTEM)/clang/clang_qcom_local.mk + else + my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) + my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) + my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) + my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) + endif + else + my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) + my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) + my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) + my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) + endif endif ifeq ($(LOCAL_FDO_SUPPORT), true) diff --git a/core/clang/TARGET_arm_qcom.mk b/core/clang/TARGET_arm_qcom.mk new file mode 100755 index 0000000000..cd7db4dc71 --- /dev/null +++ b/core/clang/TARGET_arm_qcom.mk @@ -0,0 +1,405 @@ +### Define paths +LLVM_PREBUILTS_PATH_QCOM := prebuilts/clang/linux-x86/host/llvm-Snapdragon_LLVM_for_Android_3.6/prebuilt/linux-x86_64/bin +LLVM_PREBUILTS_HEADER_PATH_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/../lib/clang/3.6.0/include/ +LLVM_PREBUILTS_LIBRARIES_PATH_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/../lib/clang/3.6.0/lib + +CLANG_QCOM_EXTRA_OPT_LIBGCC := \ + -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux/ \ + -l clang_rt.builtins-arm-android + +CLANG_QCOM_EXTRA_OPT_LIBGCC_LINK := \ + $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux/libclang_rt.builtins-arm-android.a + +CLANG_QCOM_EXTRA_OPT_LIBRARIES_LINK := \ + $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/libclang_rt.optlibc-krait.a \ + $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/libclang_rt.translib32.a + +$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC += $(CLANG_QCOM_EXTRA_OPT_LIBRARIES_LINK) + + + +### Define compile flags +CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE := armv7a-linux-androideabi + +CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX := \ + $(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin + +CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS := \ + -ffunction-sections \ + -no-canonical-prefixes \ + -fstack-protector + #-funwind-tables + #-fpic + +CLANG_QCOM_CONFIG_LLVM_EXTRA_FLAGS := \ + -Qunused-arguments -Wno-unknown-warning-option -D__compiler_offsetof=__builtin_offsetof \ + -Wno-tautological-constant-out-of-range-compare \ + -fcolor-diagnostics \ + -fstrict-aliasing \ + -Wstrict-aliasing=2 \ + -Werror=strict-aliasing \ + -fuse-ld=gold \ + -Wno-missing-field-initializers \ + -Wno-unused-local-typedef \ + -Wno-inconsistent-missing-override \ + -Wno-null-dereference \ + -Wno-enum-compare + #-Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable + +#http://pastebin.com/PZtk6WHB +ifeq ($(TARGET_CPU_VARIANT),krait) + clang_qcom_mcpu := -mcpu=krait + clang_qcom_muse-optlibc := -muse-optlibc + clang_qcom_mcpu_as := -mcpu=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=softfp +else ifeq ($(TARGET_CPU_VARIANT),scorpion) + clang_qcom_mcpu := -mcpu=scorpion + clang_qcom_mcpu_as := -mcpu=cortex-a8 -mfpu=neon-vfpv3 -mfloat-abi=softfp + clang_qcom_muse-optlibc := +else + $(info ) + $(info QCOM_CLANG: warning no supported cpu detected.) + $(exit) +endif + +CLANG_QCOM_CONFIG_KRAIT_ALIGN_FLAGS := \ + -falign-functions -falign-labels -falign-loops + +CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS := \ + -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/ \ + -l clang_rt.optlibc-krait + +CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS :=\ + -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/ \ + -l clang_rt.translib32 \ + -fparallel + +ifeq ($(USE_CLANG_QCOM_LTO),true) + CLANG_QCOM_CONFIG_LTO_FLAGS := -flto + #-c-lto +endif + +ifeq ($(USE_CLANG_QCOM_VERBOSE),true) + CLANG_QCOM_VERBOSE := -v + #-ccc-print-phases \ + #-H +endif + +# See documentation especialy 3.4.21 Math optimization. +CLANG_QCOM_CONFIG_KRAIT_FLAGS := \ + $(clang_qcom_mcpu) -mfpu=neon-vfpv4 -mfloat-abi=softfp -marm \ + $(clang_qcom_muse-optlibc) \ + -fvectorize-loops \ + -fomit-frame-pointer \ + -foptimize-sibling-calls \ + -fdata-sections \ + $(CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS) \ + $(CLANG_QCOM_CONFIG_LLVM_EXTRA_FLAGS) \ + $(CLANG_QCOM_CONFIG_KRAIT_ALIGN_FLAGS) \ + $(CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS) \ + -funsafe-math-optimizations \ + -ffp-contract=fast \ + -ffuse-loops \ + -pipe + +CLANG_QCOM_CONFIG_KRAIT_LDFLAGS := \ + $(CLANG_QCOM_CONFIG_KRAIT_FLAGS) \ + $(CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS) \ + -Wl,--gc-sections \ + -Wl,--sort-common + +CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS := \ + -Ofast -fno-fast-math \ + $(CLANG_QCOM_CONFIG_KRAIT_FLAGS) + +CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS := \ + -fipa-pta \ + -fsection-anchors \ + -ftree-loop-im \ + -ftree-loop-ivcanon \ + -fno-canonical-system-headers \ + -frerun-cse-after-loop \ + -fgcse-las \ + -fgcse-sm \ + -fivopts \ + -frename-registers \ + -ftracer \ + -funsafe-loop-optimizations \ + -funswitch-loops \ + -fweb \ + -fgcse-after-reload \ + -frename-registers \ + -finline-functions \ + -fno-strict-volatile-bitfields \ + -fno-unswitch-loops \ + -fno-if-conversion + + + +### Define global flags +define subst-clang-qcom-incompatible-arm-flags + $(subst -march=armv5te,$(clang_qcom_mcpu),\ + $(subst -march=armv5e,$(clang_qcom_mcpu),\ + $(subst -march=armv7,$(clang_qcom_mcpu),\ + $(subst -march=armv7-a,$(clang_qcom_mcpu),\ + $(subst -mcpu=cortex-a15,$(clang_qcom_mcpu),\ + $(subst -mtune=cortex-a15,$(clang_qcom_mcpu),\ + $(subst -mcpu=cortex-a8,$(clang_qcom_mcpu),\ + $(subst -O3,-Ofast,\ + $(subst -O2,-Ofast,\ + $(subst -Os,-Ofast,\ + $(1))))))))))) +endef + +define subst-clang-qcom-opt + $(subst -O3,-Ofast,\ + $(subst -O2,-Ofast,\ + $(subst -O1,-Ofast,\ + $(subst -Os,-Ofast,\ + $(1))))) +endef + +define convert-to-clang-qcom-flags + $(strip \ + $(call subst-clang-qcom-incompatible-arm-flags,\ + $(filter-out $(CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS),\ + $(1)))) +endef + +define convert-to-clang-qcom-ldflags + $(strip \ + $(filter-out $(CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS),\ + $(1))) +endef + +CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CFLAGS := \ + -nostdlibinc \ + $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) \ + -B$(CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX) \ + -target $(CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE) \ + $(CLANG_QCOM_VERBOSE) + +CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CPPFLAGS := \ + -nostdlibinc \ + $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) \ + -target $(CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE) \ + $(CLANG_QCOM_VERBOSE) + +CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS := \ + $(CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS) \ + -B$(CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX) \ + -target $(CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE) \ + $(CLANG_QCOM_VERBOSE) \ + $(CLANG_QCOM_CONFIG_KRAIT_LDFLAGS) + +ifneq ($(USE_CLANG_QCOM_PARALLEL_ONLY_ON_SELECTED_MODULES),true) + CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +endif + +CLANG_QCOM_TARGET_GLOBAL_CFLAGS := \ + $(call convert-to-clang-qcom-flags,$(TARGET_GLOBAL_CFLAGS)) \ + $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CFLAGS) + +CLANG_QCOM_TARGET_GLOBAL_CPPFLAGS := \ + $(call convert-to-clang-qcom-flags,$(TARGET_GLOBAL_CPPFLAGS)) \ + $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CPPFLAGS) + +CLANG_QCOM_TARGET_GLOBAL_LDFLAGS := \ + $(call convert-to-clang-qcom-ldflags,$(TARGET_GLOBAL_LDFLAGS)) \ + $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS) + + + +### Set toolchain +CLANG_QCOM_EXTRA := \ + -mllvm -aggressive-jt \ + -mllvm -arm-expand-memcpy-runtime=16 \ + -mllvm -arm-opt-memcpy=1 + +CLANG_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/clang$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) +CLANG_QCOM_CXX := $(LLVM_PREBUILTS_PATH_QCOM)/clang++$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) + +LLVM_AS := $(LLVM_PREBUILTS_PATH_QCOM)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) +LLVM_LINK := $(LLVM_PREBUILTS_PATH_QCOM)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) + +CLANG_QCOM_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH_QCOM) + + + +### Define modules +ifeq ($(CLANG_QCOM_COMPILE_ART),true) + CLANG_QCOM_ART_MODULES := \ + art \ + libsigchain \ + libart \ + libart-compiler \ + libartd \ + libartd-compiler \ + libart-disassembler \ + libartd-disassembler \ + core.art-host \ + core.art \ + cpplint-art-phony \ + libnativebridgetest \ + libarttest \ + art-run-tests \ + libart-gtest + +endif + +ifeq ($(CLANG_QCOM_COMPILE_BIONIC),true) + CLANG_QCOM_BIONIC_MODULES := \ + libc_cxa \ + libc_syscalls \ + libc_aeabi \ + libstdc++ \ + libc_nomalloc \ + libc_malloc \ + libc_bionic \ + libc \ + libc_common \ + libm \ + libdl \ + libc_gdtoa \ + libc_stack_protector \ + libc_tzcode \ + libc_dns \ + libc_freebsd \ + libc_netbsd \ + libc_openbsd + #libc_malloc_debug_qemu + #libc_malloc_debug_leak + +endif + +ifeq ($(CLANG_QCOM_COMPILE_MIXED),true) + CLANG_QCOM_EXTRA_MODULES := \ + libskia \ + libjpeg_static \ + libjpeg \ + cjpeg \ + djpeg \ + libft2 \ + libsqlite3_android \ + libsqlite \ + sqlite3 \ + libwebp-encode \ + libwebp-decode \ + libwebm \ + libz \ + libunz \ + gzip \ + libtruezip \ + liblz4-static \ + lz4 \ + liblzo-static \ + liblzo \ + zip \ + libbz \ + libstlport \ + libstlport_static \ + libgabi++ + + CLANG_QCOM_EXTRA_MODULES += \ + libion \ + lib_core_neon_offsets \ + libgui \ + libui \ + hwcStress \ + hwcRects \ + hwcColorEquiv \ + hwcCommit \ + gralloc.default \ + hwcomposer.default \ + audio.primary.default \ + audio_policy.stub \ + liboverlay \ + math \ + surfaceflinger + + CLANG_QCOM_EXTRA_MODULES += \ + libandroid \ + libandroid_servers \ + libcompiler_rt + + CLANG_QCOM_EXTRA_MODULES += \ + libpixman \ + libmedia + + CLANG_QCOM_EXTRA_MODULES += \ + libjemalloc + + CLANG_QCOM_EXTRA_MODULES_test_not_working += \ + libcv \ + libcvaux \ + libcvml \ + libcvhighgui \ + libopencv \ + stagefright \ + record \ + recordvideo \ + screenrecord \ + codec \ + muxer \ + libdownmix \ + libeffects \ + libvisualizer \ + libmedia_helper \ + libaudioparameter \ + decoder \ + libserviceutility \ + libaudioresampler \ + libaudio-resampler \ + libaudiopolicymanagerdefault \ + libaudiopolicymanager \ + servicemanager \ + halutil \ + libhardware \ + libqdMetaData \ + libhdmi \ + libqservice \ + libOmxCore \ + libmm-omxcore \ + libstagefrighthw \ + libdashplayer \ + libutils + +endif + +# Here you can overwrite which modules should be compiled with QCOM CLANG instead of GCC +CLANG_QCOM_FORCE_COMPILE_MODULES += \ + $(CLANG_QCOM_ART_MODULES) \ + $(CLANG_QCOM_BIONIC_MODULES) \ + $(CLANG_QCOM_EXTRA_MODULES) + +# Here you can overwrite which modules should be compiled with the default CLANG instead of QCOM CLANG +CLANG_QCOM_FORCE_COMPILE_ACLANG_MODULES += + +# -fparallel where to use? see 3.6.4 +# Modules that dont like -fparallel +CLANG_QCOM_DONT_USE_PARALLEL_MODULES := \ + libc_gdtoa \ + libm \ + libc_tzcode \ + libc_dns \ + libc_freebsd \ + libc_netbsd \ + libc_openbsd \ + libc_stack_protector \ + libjemalloc + +# Dont use CLANG Assembler. Use GCC Assembler instead +# https://android-review.googlesource.com/#/c/110170/ +# Skia doesnt like the CLANG assembler +CLANG_QCOM_DONT_USE_INTEGRATED_AS_MODULES += \ + libskia \ + libc++abi + +# Modules for language mode C++11 +CLANG_QCOM_C++11_MODULES += \ + libjni_latinime_common_static \ + libjni_latinime + +# Modules for language mode G++11 +CLANG_QCOM_GNU++11_MODULES += + +#CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES += diff --git a/core/clang/clang_qcom_global.mk b/core/clang/clang_qcom_global.mk new file mode 100644 index 0000000000..75a0320c1f --- /dev/null +++ b/core/clang/clang_qcom_global.mk @@ -0,0 +1,26 @@ +# Flags and linking +my_target_c_includes += $(CLANG_QCOM_CONFIG_EXTRA_TARGET_C_INCLUDES) +my_target_global_cflags := $(CLANG_QCOM_TARGET_GLOBAL_CFLAGS) +my_target_global_cppflags := $(CLANG_QCOM_TARGET_GLOBAL_CPPFLAGS) +my_target_global_ldflags := $(CLANG_QCOM_TARGET_GLOBAL_LDFLAGS) + +ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) +my_target_global_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +my_target_global_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +my_target_global_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +endif + +# build for arm +LOCAL_ARM_MODE := arm + +ifeq ($(CLANG_QCOM_SHOW_FLAGS),true) +$(info global MODULE : $(LOCAL_MODULE)) +$(info global cflags : $(my_target_global_cflags)) +$(info global cppflags : $(my_target_global_cppflags)) +$(info global ldflags : $(my_target_global_ldflags)) +$(info ) +endif + +# Set path to CLANG binary +my_cc := $(CLANG_QCOM) +my_cxx := $(CLANG_QCOM_CXX) diff --git a/core/clang/clang_qcom_local.mk b/core/clang/clang_qcom_local.mk new file mode 100644 index 0000000000..e73a20c0c2 --- /dev/null +++ b/core/clang/clang_qcom_local.mk @@ -0,0 +1,54 @@ +# Convert for CLANG QCOM +my_cflags := $(call convert-to-clang-qcom-flags,$(my_cflags)) +my_cppflags := $(call convert-to-clang-qcom-flags,$(my_cppflags)) +my_ldflags := $(call convert-to-clang-qcom-ldflags,$(my_ldflags)) +LOCAL_CONLYFLAGS := $(call convert-to-clang-qcom-flags,$(LOCAL_CONLYFLAGS)) + +# Substitute -O2 and -O3 with -Ofast -fno-fast-math +ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES))) +my_cflags := $(call subst-clang-qcom-opt,$(my_cflags)) +my_cppflags := $(call subst-clang-qcom-opt,$(my_cppflags)) +LOCAL_CONLYFLAGS := $(call subst-clang-qcom-opt,$(LOCAL_CONLYFLAGS)) +endif + +# Flags and linking +my_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) +my_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) +my_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_LDFLAGS) +LOCAL_CONLYFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) +# Set different mcpu for GCC Assembler because it doesnt know -mcpu=krait and defaults to -march=armv7-a +my_asflags += $(clang_qcom_mcpu_as) + +ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) +my_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +my_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +my_asflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +my_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +LOCAL_CONLYFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +endif + +# Set language dialect to C++11 +ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_C++11_MODULES))) +my_cppflags += -std=c++11 +endif + +# Set language dialect to C++11 +ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_GNU++11_MODULES))) +my_cppflags += -std=gnu++11 +endif + +# libc++abi bug: https://android-review.googlesource.com/#/c/110170/ +# Skia doesnt like the clang assembler +ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_INTEGRATED_AS_MODULES))) +my_cflags += -no-integrated-as -Xassembler -mcpu=cortex-a15 +endif + +ifeq ($(CLANG_QCOM_SHOW_FLAGS_LOCAL),true) +$(info local MODULE : $(LOCAL_MODULE)) +$(info cflags : $(my_cflags)) +$(info cppflags : $(my_cppflags)) +$(info asflags : $(my_asflags)) +$(info ldflags : $(my_ldflags)) +$(info conly : $(LOCAL_CONLYFLAGS)) +$(info ) +endif diff --git a/core/clang/clang_qcom_objects.mk b/core/clang/clang_qcom_objects.mk new file mode 100644 index 0000000000..8686fd55a4 --- /dev/null +++ b/core/clang/clang_qcom_objects.mk @@ -0,0 +1,20 @@ +# Convert for QCOM CLANG +arm_objects_cflags := $(call convert-to-clang-qcom-flags,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)) +normal_objects_cflags := $(call convert-to-clang-qcom-flags,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)) + +ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) +arm_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +normal_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +endif + +# Add KRAIT FLAGS +arm_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) +normal_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) + +#ersetze memcpy aus libc++ mit der aus optlibc +ifeq ($(CLANG_QCOM_SHOW_FLAGS_OBJECT),true) +$(info object MODULE : $(LOCAL_MODULE)) +$(info arm_objects_cflags : $(arm_objects_cflags)) +$(info normal_objects_c : $(normal_objects_cflags)) +$(info ) +endif diff --git a/core/clang/config.mk b/core/clang/config.mk index 9c1179717b..3f766b7195 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -106,3 +106,8 @@ ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan # This allows us to use the superset of functionality that compiler-rt # provides to Clang (for supporting features like -ftrapv). COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras + +# Use Snapdragon LLVM Compiler for Android +ifeq ($(USE_CLANG_QCOM),true) +include $(BUILD_SYSTEM)/clang/TARGET_arm_qcom.mk +endif \ No newline at end of file From a21bd1764caaa675ce58ff7ca1b122d747baced6 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 29 Aug 2015 22:58:31 +0200 Subject: [PATCH 06/16] Use Qualcomm Snapdragon LLVM Compiler 3.6 (https://developer.qualcomm.com/mobile-development/increase-app-performance/snapdragon-llvm-compiler-android) for Android Lollipop 5.x for devices with Qualcomm CPU As far as I know nobody has done that yet. Except me :) This changes the toolchain for CLANG from the default one which comes with Android (aCLANG) to the Qualcomm Snapdragon LLVM Compiler 3.6 (qCLANG) mentioned above. The toolchain will be used for almost all places where the default Android CLANG (aCLANG) is used for compiling TARGET MODULES. BUT ONLY if "USE_CLANG_QCOM := true" is set. Otherwise it is using aCLANG. So you can merge this commit and the build will be the same as before except you specifically define "USE_CLANG_QCOM := true"! WARNING: THIS IS NOT FULLY TESTED FOR STABILITY YET. READ CAREFULLY It is very likely that using this toolchain, especially with the optimizations flags, will introduce BUGS! I would suggest: IF YOU USE IT DONT MAKE BUG REPORTS FOR YOUR OFFICIAL ROM OR KERNEL OR ANY APPS. Make reports in the development thread. The ROM compiles, boots and starts. Also if Bionic and other modules are compiled with Qualcomm Snapdragon LLVM Compiler 3.6 (qCLANG). Androbench, Antutu, Basemark 2.0 , Geekbench 3, Vellamo are 'completing' the benchmarks. This is a work in progress. There is confirmation that it works for Sony Z Ultra and Samsung Galaxy Note 4 and after some months of testing everything seems good. At the moment this is only tested with Qualcomm Snapdragon but in theory this should also work with any Krait and even Scorpion CPU. According to Documentation there is also support for armv8/aarch64 (Snapdragon 810) and you should gain a real performance bump but support is not yet implemented! If you have a Snapdragon 810 device and want to try this out contact me please. Install instructions: 1. You have to make an account in order to download the toolchain! 2. You need to download the toolchain and extract it to {your android dir}/prebuilts/clang/linux-x86/host/* 3. Add the repo (https://github.com/mustermaxmueller/clanglibs) to your manifest. For example: 4. Replace the compiler-rt repo with this one https://github.com/mustermaxmueller/compiler-rt in your manifest For example: 5. Add my build repo https://github.com/mustermaxmueller/android_build/ or merge my changes. For example: 6. Add my frameworks_rs repo https://github.com/mustermaxmueller/android_frameworks_rs or merge my changes. For example: You need the Qualcomm Snapdragon LLVM Compiler 3.5 for this to work!!! OR Make changes to frameworks/rs/driver/runtime/build_bc_lib_internal.mk like stated here: http://forum.xda-developers.com/showpost.php?p=59626153&postcount=47 7. Change following line in following files: prebuilts/ndk/current/platforms/android-14/arch-arm/usr/include/math.h prebuilts/ndk/current/platforms/android-8/arch-arm/usr/include/math.h from #if !defined(__clang__) || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) to #if !defined(__clang__) || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 7) 8. Set "USE_CLANG_QCOM := true" e.g. in Boardconfig.mk OPTIONAL (set these options in your Boardconfig.mk): USE_CLANG_QCOM_VERBOSE := true (give extra output when compiling) USE_CLANG_QCOM_LTO := true (use LTO; not working at the moment) CLANG_QCOM_COMPILE_ART := true (compile art with qclang; not working at the moment!) CLANG_QCOM_COMPILE_BIONIC := true (compile bionic with qclang) CLANG_QCOM_COMPILE_MIXED := true (compile defined modules with qclang) CLANG_QCOM_FORCE_COMPILE_MODULES += (Here you can overwrite which modules should be compiled with qCLANG instead of GCC) CLANG_QCOM_FORCE_COMPILE_ACLANG_MODULES += (Here you can overwrite which modules should be compiled with aCLANG instead of qCLANG) CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES += (Here you can overwrite which modules shouldnt be compiled with -Ofast) 9. Add "USE_CLANG_QCOM := true" to your Boardconfig.mk/BoardconfigCommon.mk of your device. (If you want to be certain that qclang is used,also set "USE_CLANG_QCOM_VERBOSE := true" in your Boardconfig.mk and you will see the verbose output while compiling.) 10. Make a clean compile! Also delete ccache! Annotation: 1. You should only get measurable performance benefits if you compile Bionic with CLANG! 2. Documentation for the toolchain: {your android dir}/prebuilts/clang/linux-x86/host/llvm-Snapdragon_LLVM_for_Android_3.6/Snapdragon_LLVM_ARM_36_User_Guide.pdf 3. The Flags "-muse-optlibc" and "-ffuse-loops" are not Documented. (http://pastebin.com/PZtk6WHB) 4. The implementation is not beautiful but it works 5. HOST is compiled with aCLANG because qCLANG does not understand x86 6. You can make performance and size comparisons by removing/commenting "USE_CLANG_QCOM := true" 7. I could have made the installation easier by uploading the toolchain to Github but I do not know if I am allowed to. And I am no lawyer so... TODO: -Make more performance comparisons to aCLANG and GCC. It seems good even compared to GCC -Use ccache -Where does it make sense to use qCLANG instead of GCC? -Compile Android with qCLANG wherever possible. http://www.linuxplumbersconf.org/2013/ocw/system/presentations/1131/original/LP2013-Android-clang.pdf and https://events.linuxfoundation.org/sites/events/files/slides/2014-ABS-LLVMLinux.pdf Development Thread: http://forum.xda-developers.com/android/software-hacking/wip-compile-android-5-0-2-qualcomm-llvm-t3035162 (reverted from commit e4323ac21285b77391d93d37ed1310b9d51ae352) --- core/binary.mk | 55 +---- core/clang/TARGET_arm_qcom.mk | 405 ------------------------------- core/clang/clang_qcom_global.mk | 26 -- core/clang/clang_qcom_local.mk | 54 ----- core/clang/clang_qcom_objects.mk | 20 -- core/clang/config.mk | 5 - 6 files changed, 10 insertions(+), 555 deletions(-) delete mode 100755 core/clang/TARGET_arm_qcom.mk delete mode 100644 core/clang/clang_qcom_global.mk delete mode 100644 core/clang/clang_qcom_local.mk delete mode 100644 core/clang/clang_qcom_objects.mk diff --git a/core/binary.mk b/core/binary.mk index 2153404f26..170e20c5e6 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -97,17 +97,6 @@ else endif endif -ifeq ($(USE_CLANG_QCOM),true) - ifndef LOCAL_IS_HOST_MODULE - ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_FORCE_COMPILE_MODULES))) - LOCAL_CLANG := true - endif - #ifneq ($(LOCAL_CLANG),true) - # $(info gcc target module: $(LOCAL_MODULE)) - #endif - endif -endif - # The following LOCAL_ variables will be modified in this file. # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch, # we can't modify them in place. @@ -253,14 +242,10 @@ my_target_global_cppflags := endif # LOCAL_SDK_VERSION ifeq ($(my_clang),true) - ifeq ($(USE_CLANG_QCOM)$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_MODULES)),true) - include $(BUILD_SYSTEM)/clang/clang_qcom_global.mk - else - my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES) - my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) - my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) - my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) - endif +my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) +my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) +my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) +my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES) else my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS) my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS) @@ -380,17 +365,8 @@ normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS) normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS) ifeq ($(strip $(my_clang)),true) - ifndef LOCAL_IS_HOST_MODULE - ifeq ($(USE_CLANG_QCOM)$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_MODULES)),true) - include $(BUILD_SYSTEM)/clang/clang_qcom_objects.mk - else - arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) - normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) - endif - else - arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) - normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) - endif +arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) +normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) endif else @@ -947,21 +923,10 @@ endif ########################################################### ifeq ($(my_clang),true) - ifndef LOCAL_IS_HOST_MODULE - ifeq ($(USE_CLANG_QCOM)$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_MODULES)),true) - include $(BUILD_SYSTEM)/clang/clang_qcom_local.mk - else - my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) - my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) - my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) - my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) - endif - else - my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) - my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) - my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) - my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) - endif +my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) +my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) +my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) +my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) endif ifeq ($(LOCAL_FDO_SUPPORT), true) diff --git a/core/clang/TARGET_arm_qcom.mk b/core/clang/TARGET_arm_qcom.mk deleted file mode 100755 index cd7db4dc71..0000000000 --- a/core/clang/TARGET_arm_qcom.mk +++ /dev/null @@ -1,405 +0,0 @@ -### Define paths -LLVM_PREBUILTS_PATH_QCOM := prebuilts/clang/linux-x86/host/llvm-Snapdragon_LLVM_for_Android_3.6/prebuilt/linux-x86_64/bin -LLVM_PREBUILTS_HEADER_PATH_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/../lib/clang/3.6.0/include/ -LLVM_PREBUILTS_LIBRARIES_PATH_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/../lib/clang/3.6.0/lib - -CLANG_QCOM_EXTRA_OPT_LIBGCC := \ - -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux/ \ - -l clang_rt.builtins-arm-android - -CLANG_QCOM_EXTRA_OPT_LIBGCC_LINK := \ - $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux/libclang_rt.builtins-arm-android.a - -CLANG_QCOM_EXTRA_OPT_LIBRARIES_LINK := \ - $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/libclang_rt.optlibc-krait.a \ - $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/libclang_rt.translib32.a - -$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC += $(CLANG_QCOM_EXTRA_OPT_LIBRARIES_LINK) - - - -### Define compile flags -CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE := armv7a-linux-androideabi - -CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX := \ - $(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin - -CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS := \ - -ffunction-sections \ - -no-canonical-prefixes \ - -fstack-protector - #-funwind-tables - #-fpic - -CLANG_QCOM_CONFIG_LLVM_EXTRA_FLAGS := \ - -Qunused-arguments -Wno-unknown-warning-option -D__compiler_offsetof=__builtin_offsetof \ - -Wno-tautological-constant-out-of-range-compare \ - -fcolor-diagnostics \ - -fstrict-aliasing \ - -Wstrict-aliasing=2 \ - -Werror=strict-aliasing \ - -fuse-ld=gold \ - -Wno-missing-field-initializers \ - -Wno-unused-local-typedef \ - -Wno-inconsistent-missing-override \ - -Wno-null-dereference \ - -Wno-enum-compare - #-Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable - -#http://pastebin.com/PZtk6WHB -ifeq ($(TARGET_CPU_VARIANT),krait) - clang_qcom_mcpu := -mcpu=krait - clang_qcom_muse-optlibc := -muse-optlibc - clang_qcom_mcpu_as := -mcpu=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=softfp -else ifeq ($(TARGET_CPU_VARIANT),scorpion) - clang_qcom_mcpu := -mcpu=scorpion - clang_qcom_mcpu_as := -mcpu=cortex-a8 -mfpu=neon-vfpv3 -mfloat-abi=softfp - clang_qcom_muse-optlibc := -else - $(info ) - $(info QCOM_CLANG: warning no supported cpu detected.) - $(exit) -endif - -CLANG_QCOM_CONFIG_KRAIT_ALIGN_FLAGS := \ - -falign-functions -falign-labels -falign-loops - -CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS := \ - -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/ \ - -l clang_rt.optlibc-krait - -CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS :=\ - -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/ \ - -l clang_rt.translib32 \ - -fparallel - -ifeq ($(USE_CLANG_QCOM_LTO),true) - CLANG_QCOM_CONFIG_LTO_FLAGS := -flto - #-c-lto -endif - -ifeq ($(USE_CLANG_QCOM_VERBOSE),true) - CLANG_QCOM_VERBOSE := -v - #-ccc-print-phases \ - #-H -endif - -# See documentation especialy 3.4.21 Math optimization. -CLANG_QCOM_CONFIG_KRAIT_FLAGS := \ - $(clang_qcom_mcpu) -mfpu=neon-vfpv4 -mfloat-abi=softfp -marm \ - $(clang_qcom_muse-optlibc) \ - -fvectorize-loops \ - -fomit-frame-pointer \ - -foptimize-sibling-calls \ - -fdata-sections \ - $(CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS) \ - $(CLANG_QCOM_CONFIG_LLVM_EXTRA_FLAGS) \ - $(CLANG_QCOM_CONFIG_KRAIT_ALIGN_FLAGS) \ - $(CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS) \ - -funsafe-math-optimizations \ - -ffp-contract=fast \ - -ffuse-loops \ - -pipe - -CLANG_QCOM_CONFIG_KRAIT_LDFLAGS := \ - $(CLANG_QCOM_CONFIG_KRAIT_FLAGS) \ - $(CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS) \ - -Wl,--gc-sections \ - -Wl,--sort-common - -CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS := \ - -Ofast -fno-fast-math \ - $(CLANG_QCOM_CONFIG_KRAIT_FLAGS) - -CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS := \ - -fipa-pta \ - -fsection-anchors \ - -ftree-loop-im \ - -ftree-loop-ivcanon \ - -fno-canonical-system-headers \ - -frerun-cse-after-loop \ - -fgcse-las \ - -fgcse-sm \ - -fivopts \ - -frename-registers \ - -ftracer \ - -funsafe-loop-optimizations \ - -funswitch-loops \ - -fweb \ - -fgcse-after-reload \ - -frename-registers \ - -finline-functions \ - -fno-strict-volatile-bitfields \ - -fno-unswitch-loops \ - -fno-if-conversion - - - -### Define global flags -define subst-clang-qcom-incompatible-arm-flags - $(subst -march=armv5te,$(clang_qcom_mcpu),\ - $(subst -march=armv5e,$(clang_qcom_mcpu),\ - $(subst -march=armv7,$(clang_qcom_mcpu),\ - $(subst -march=armv7-a,$(clang_qcom_mcpu),\ - $(subst -mcpu=cortex-a15,$(clang_qcom_mcpu),\ - $(subst -mtune=cortex-a15,$(clang_qcom_mcpu),\ - $(subst -mcpu=cortex-a8,$(clang_qcom_mcpu),\ - $(subst -O3,-Ofast,\ - $(subst -O2,-Ofast,\ - $(subst -Os,-Ofast,\ - $(1))))))))))) -endef - -define subst-clang-qcom-opt - $(subst -O3,-Ofast,\ - $(subst -O2,-Ofast,\ - $(subst -O1,-Ofast,\ - $(subst -Os,-Ofast,\ - $(1))))) -endef - -define convert-to-clang-qcom-flags - $(strip \ - $(call subst-clang-qcom-incompatible-arm-flags,\ - $(filter-out $(CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS),\ - $(1)))) -endef - -define convert-to-clang-qcom-ldflags - $(strip \ - $(filter-out $(CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS),\ - $(1))) -endef - -CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CFLAGS := \ - -nostdlibinc \ - $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) \ - -B$(CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX) \ - -target $(CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE) \ - $(CLANG_QCOM_VERBOSE) - -CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CPPFLAGS := \ - -nostdlibinc \ - $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) \ - -target $(CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE) \ - $(CLANG_QCOM_VERBOSE) - -CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS := \ - $(CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS) \ - -B$(CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX) \ - -target $(CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE) \ - $(CLANG_QCOM_VERBOSE) \ - $(CLANG_QCOM_CONFIG_KRAIT_LDFLAGS) - -ifneq ($(USE_CLANG_QCOM_PARALLEL_ONLY_ON_SELECTED_MODULES),true) - CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -endif - -CLANG_QCOM_TARGET_GLOBAL_CFLAGS := \ - $(call convert-to-clang-qcom-flags,$(TARGET_GLOBAL_CFLAGS)) \ - $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CFLAGS) - -CLANG_QCOM_TARGET_GLOBAL_CPPFLAGS := \ - $(call convert-to-clang-qcom-flags,$(TARGET_GLOBAL_CPPFLAGS)) \ - $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CPPFLAGS) - -CLANG_QCOM_TARGET_GLOBAL_LDFLAGS := \ - $(call convert-to-clang-qcom-ldflags,$(TARGET_GLOBAL_LDFLAGS)) \ - $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS) - - - -### Set toolchain -CLANG_QCOM_EXTRA := \ - -mllvm -aggressive-jt \ - -mllvm -arm-expand-memcpy-runtime=16 \ - -mllvm -arm-opt-memcpy=1 - -CLANG_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/clang$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) -CLANG_QCOM_CXX := $(LLVM_PREBUILTS_PATH_QCOM)/clang++$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) - -LLVM_AS := $(LLVM_PREBUILTS_PATH_QCOM)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) -LLVM_LINK := $(LLVM_PREBUILTS_PATH_QCOM)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) - -CLANG_QCOM_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH_QCOM) - - - -### Define modules -ifeq ($(CLANG_QCOM_COMPILE_ART),true) - CLANG_QCOM_ART_MODULES := \ - art \ - libsigchain \ - libart \ - libart-compiler \ - libartd \ - libartd-compiler \ - libart-disassembler \ - libartd-disassembler \ - core.art-host \ - core.art \ - cpplint-art-phony \ - libnativebridgetest \ - libarttest \ - art-run-tests \ - libart-gtest - -endif - -ifeq ($(CLANG_QCOM_COMPILE_BIONIC),true) - CLANG_QCOM_BIONIC_MODULES := \ - libc_cxa \ - libc_syscalls \ - libc_aeabi \ - libstdc++ \ - libc_nomalloc \ - libc_malloc \ - libc_bionic \ - libc \ - libc_common \ - libm \ - libdl \ - libc_gdtoa \ - libc_stack_protector \ - libc_tzcode \ - libc_dns \ - libc_freebsd \ - libc_netbsd \ - libc_openbsd - #libc_malloc_debug_qemu - #libc_malloc_debug_leak - -endif - -ifeq ($(CLANG_QCOM_COMPILE_MIXED),true) - CLANG_QCOM_EXTRA_MODULES := \ - libskia \ - libjpeg_static \ - libjpeg \ - cjpeg \ - djpeg \ - libft2 \ - libsqlite3_android \ - libsqlite \ - sqlite3 \ - libwebp-encode \ - libwebp-decode \ - libwebm \ - libz \ - libunz \ - gzip \ - libtruezip \ - liblz4-static \ - lz4 \ - liblzo-static \ - liblzo \ - zip \ - libbz \ - libstlport \ - libstlport_static \ - libgabi++ - - CLANG_QCOM_EXTRA_MODULES += \ - libion \ - lib_core_neon_offsets \ - libgui \ - libui \ - hwcStress \ - hwcRects \ - hwcColorEquiv \ - hwcCommit \ - gralloc.default \ - hwcomposer.default \ - audio.primary.default \ - audio_policy.stub \ - liboverlay \ - math \ - surfaceflinger - - CLANG_QCOM_EXTRA_MODULES += \ - libandroid \ - libandroid_servers \ - libcompiler_rt - - CLANG_QCOM_EXTRA_MODULES += \ - libpixman \ - libmedia - - CLANG_QCOM_EXTRA_MODULES += \ - libjemalloc - - CLANG_QCOM_EXTRA_MODULES_test_not_working += \ - libcv \ - libcvaux \ - libcvml \ - libcvhighgui \ - libopencv \ - stagefright \ - record \ - recordvideo \ - screenrecord \ - codec \ - muxer \ - libdownmix \ - libeffects \ - libvisualizer \ - libmedia_helper \ - libaudioparameter \ - decoder \ - libserviceutility \ - libaudioresampler \ - libaudio-resampler \ - libaudiopolicymanagerdefault \ - libaudiopolicymanager \ - servicemanager \ - halutil \ - libhardware \ - libqdMetaData \ - libhdmi \ - libqservice \ - libOmxCore \ - libmm-omxcore \ - libstagefrighthw \ - libdashplayer \ - libutils - -endif - -# Here you can overwrite which modules should be compiled with QCOM CLANG instead of GCC -CLANG_QCOM_FORCE_COMPILE_MODULES += \ - $(CLANG_QCOM_ART_MODULES) \ - $(CLANG_QCOM_BIONIC_MODULES) \ - $(CLANG_QCOM_EXTRA_MODULES) - -# Here you can overwrite which modules should be compiled with the default CLANG instead of QCOM CLANG -CLANG_QCOM_FORCE_COMPILE_ACLANG_MODULES += - -# -fparallel where to use? see 3.6.4 -# Modules that dont like -fparallel -CLANG_QCOM_DONT_USE_PARALLEL_MODULES := \ - libc_gdtoa \ - libm \ - libc_tzcode \ - libc_dns \ - libc_freebsd \ - libc_netbsd \ - libc_openbsd \ - libc_stack_protector \ - libjemalloc - -# Dont use CLANG Assembler. Use GCC Assembler instead -# https://android-review.googlesource.com/#/c/110170/ -# Skia doesnt like the CLANG assembler -CLANG_QCOM_DONT_USE_INTEGRATED_AS_MODULES += \ - libskia \ - libc++abi - -# Modules for language mode C++11 -CLANG_QCOM_C++11_MODULES += \ - libjni_latinime_common_static \ - libjni_latinime - -# Modules for language mode G++11 -CLANG_QCOM_GNU++11_MODULES += - -#CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES += diff --git a/core/clang/clang_qcom_global.mk b/core/clang/clang_qcom_global.mk deleted file mode 100644 index 75a0320c1f..0000000000 --- a/core/clang/clang_qcom_global.mk +++ /dev/null @@ -1,26 +0,0 @@ -# Flags and linking -my_target_c_includes += $(CLANG_QCOM_CONFIG_EXTRA_TARGET_C_INCLUDES) -my_target_global_cflags := $(CLANG_QCOM_TARGET_GLOBAL_CFLAGS) -my_target_global_cppflags := $(CLANG_QCOM_TARGET_GLOBAL_CPPFLAGS) -my_target_global_ldflags := $(CLANG_QCOM_TARGET_GLOBAL_LDFLAGS) - -ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) -my_target_global_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -my_target_global_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -my_target_global_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -endif - -# build for arm -LOCAL_ARM_MODE := arm - -ifeq ($(CLANG_QCOM_SHOW_FLAGS),true) -$(info global MODULE : $(LOCAL_MODULE)) -$(info global cflags : $(my_target_global_cflags)) -$(info global cppflags : $(my_target_global_cppflags)) -$(info global ldflags : $(my_target_global_ldflags)) -$(info ) -endif - -# Set path to CLANG binary -my_cc := $(CLANG_QCOM) -my_cxx := $(CLANG_QCOM_CXX) diff --git a/core/clang/clang_qcom_local.mk b/core/clang/clang_qcom_local.mk deleted file mode 100644 index e73a20c0c2..0000000000 --- a/core/clang/clang_qcom_local.mk +++ /dev/null @@ -1,54 +0,0 @@ -# Convert for CLANG QCOM -my_cflags := $(call convert-to-clang-qcom-flags,$(my_cflags)) -my_cppflags := $(call convert-to-clang-qcom-flags,$(my_cppflags)) -my_ldflags := $(call convert-to-clang-qcom-ldflags,$(my_ldflags)) -LOCAL_CONLYFLAGS := $(call convert-to-clang-qcom-flags,$(LOCAL_CONLYFLAGS)) - -# Substitute -O2 and -O3 with -Ofast -fno-fast-math -ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES))) -my_cflags := $(call subst-clang-qcom-opt,$(my_cflags)) -my_cppflags := $(call subst-clang-qcom-opt,$(my_cppflags)) -LOCAL_CONLYFLAGS := $(call subst-clang-qcom-opt,$(LOCAL_CONLYFLAGS)) -endif - -# Flags and linking -my_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) -my_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) -my_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_LDFLAGS) -LOCAL_CONLYFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) -# Set different mcpu for GCC Assembler because it doesnt know -mcpu=krait and defaults to -march=armv7-a -my_asflags += $(clang_qcom_mcpu_as) - -ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) -my_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -my_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -my_asflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -my_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -LOCAL_CONLYFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -endif - -# Set language dialect to C++11 -ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_C++11_MODULES))) -my_cppflags += -std=c++11 -endif - -# Set language dialect to C++11 -ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_GNU++11_MODULES))) -my_cppflags += -std=gnu++11 -endif - -# libc++abi bug: https://android-review.googlesource.com/#/c/110170/ -# Skia doesnt like the clang assembler -ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_INTEGRATED_AS_MODULES))) -my_cflags += -no-integrated-as -Xassembler -mcpu=cortex-a15 -endif - -ifeq ($(CLANG_QCOM_SHOW_FLAGS_LOCAL),true) -$(info local MODULE : $(LOCAL_MODULE)) -$(info cflags : $(my_cflags)) -$(info cppflags : $(my_cppflags)) -$(info asflags : $(my_asflags)) -$(info ldflags : $(my_ldflags)) -$(info conly : $(LOCAL_CONLYFLAGS)) -$(info ) -endif diff --git a/core/clang/clang_qcom_objects.mk b/core/clang/clang_qcom_objects.mk deleted file mode 100644 index 8686fd55a4..0000000000 --- a/core/clang/clang_qcom_objects.mk +++ /dev/null @@ -1,20 +0,0 @@ -# Convert for QCOM CLANG -arm_objects_cflags := $(call convert-to-clang-qcom-flags,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)) -normal_objects_cflags := $(call convert-to-clang-qcom-flags,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)) - -ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) -arm_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -normal_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -endif - -# Add KRAIT FLAGS -arm_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) -normal_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) - -#ersetze memcpy aus libc++ mit der aus optlibc -ifeq ($(CLANG_QCOM_SHOW_FLAGS_OBJECT),true) -$(info object MODULE : $(LOCAL_MODULE)) -$(info arm_objects_cflags : $(arm_objects_cflags)) -$(info normal_objects_c : $(normal_objects_cflags)) -$(info ) -endif diff --git a/core/clang/config.mk b/core/clang/config.mk index 3f766b7195..9c1179717b 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -106,8 +106,3 @@ ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan # This allows us to use the superset of functionality that compiler-rt # provides to Clang (for supporting features like -ftrapv). COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras - -# Use Snapdragon LLVM Compiler for Android -ifeq ($(USE_CLANG_QCOM),true) -include $(BUILD_SYSTEM)/clang/TARGET_arm_qcom.mk -endif \ No newline at end of file From c07cd68b38599a6d2551ae1fd90901e449bbb99a Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 8 Aug 2015 16:05:16 +0200 Subject: [PATCH 07/16] Use Qualcomm Snapdragon LLVM Compiler 3.6 (https://developer.qualcomm.com/mobile-development/increase-app-performance/snapdragon-llvm-compiler-android) for Android Lollipop 5.x for devices with Qualcomm CPU As far as I know nobody has done that yet. Except me :) This changes the toolchain for CLANG from the default one which comes with Android (aCLANG) to the Qualcomm Snapdragon LLVM Compiler 3.6 (qCLANG) mentioned above. The toolchain will be used for almost all places where the default Android CLANG (aCLANG) is used for compiling TARGET MODULES. BUT ONLY if "USE_CLANG_QCOM := true" is set. Otherwise it is using aCLANG. So you can merge this commit and the build will be the same as before except you specifically define "USE_CLANG_QCOM := true"! WARNING: THIS IS NOT FULLY TESTED FOR STABILITY YET. READ CAREFULLY It is very likely that using this toolchain, especially with the optimizations flags, will introduce BUGS! I would suggest: IF YOU USE IT DONT MAKE BUG REPORTS FOR YOUR OFFICIAL ROM OR KERNEL OR ANY APPS. Make reports in the development thread. The ROM compiles, boots and starts. Also if Bionic and other modules are compiled with Qualcomm Snapdragon LLVM Compiler 3.6 (qCLANG). Androbench, Antutu, Basemark 2.0 , Geekbench 3, Vellamo are 'completing' the benchmarks. This is a work in progress. There is confirmation that it works for Sony Z Ultra and Samsung Galaxy Note 4 and after some months of testing everything seems good. At the moment this is only tested with Qualcomm Snapdragon but in theory this should also work with any Krait and even Scorpion CPU. According to Documentation there is also support for armv8/aarch64 (Snapdragon 810) and you should gain a real performance bump but support is not yet implemented! If you have a Snapdragon 810 device and want to try this out contact me please. Install instructions: 1. You have to make an account in order to download the toolchain! 2. You need to download the toolchain and extract it to {your android dir}/prebuilts/clang/linux-x86/host/* 3. Add the repo (https://github.com/mustermaxmueller/clanglibs) to your manifest. For example: 4. Replace the compiler-rt repo with this one https://github.com/mustermaxmueller/compiler-rt in your manifest For example: 5. Add my build repo https://github.com/mustermaxmueller/android_build/ or merge my changes. For example: 6. Add my frameworks_rs repo https://github.com/mustermaxmueller/android_frameworks_rs or merge my changes. For example: You need the Qualcomm Snapdragon LLVM Compiler 3.5 for this to work!!! OR Make changes to frameworks/rs/driver/runtime/build_bc_lib_internal.mk like stated here: http://forum.xda-developers.com/showpost.php?p=59626153&postcount=47 7. Change following line in following files: prebuilts/ndk/current/platforms/android-14/arch-arm/usr/include/math.h prebuilts/ndk/current/platforms/android-8/arch-arm/usr/include/math.h from #if !defined(__clang__) || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) to #if !defined(__clang__) || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 7) 8. Set "USE_CLANG_QCOM := true" e.g. in Boardconfig.mk OPTIONAL (set these options in your Boardconfig.mk): USE_CLANG_QCOM_VERBOSE := true (give extra output when compiling) USE_CLANG_QCOM_LTO := true (use LTO; not working at the moment) CLANG_QCOM_COMPILE_ART := true (compile art with qclang; not working at the moment!) CLANG_QCOM_COMPILE_BIONIC := true (compile bionic with qclang) CLANG_QCOM_COMPILE_MIXED := true (compile defined modules with qclang) CLANG_QCOM_FORCE_COMPILE_MODULES += (Here you can overwrite which modules should be compiled with qCLANG instead of GCC) CLANG_QCOM_FORCE_COMPILE_ACLANG_MODULES += (Here you can overwrite which modules should be compiled with aCLANG instead of qCLANG) CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES += (Here you can overwrite which modules shouldnt be compiled with -Ofast) 9. Add "USE_CLANG_QCOM := true" to your Boardconfig.mk/BoardconfigCommon.mk of your device. (If you want to be certain that qclang is used,also set "USE_CLANG_QCOM_VERBOSE := true" in your Boardconfig.mk and you will see the verbose output while compiling.) 10. Make a clean compile! Also delete ccache! Annotation: 1. You should only get measurable performance benefits if you compile Bionic with CLANG! 2. Documentation for the toolchain: {your android dir}/prebuilts/clang/linux-x86/host/llvm-Snapdragon_LLVM_for_Android_3.6/Snapdragon_LLVM_ARM_36_User_Guide.pdf 3. The Flags "-muse-optlibc" and "-ffuse-loops" are not Documented. (http://pastebin.com/PZtk6WHB) 4. The implementation is not beautiful but it works 5. HOST is compiled with aCLANG because qCLANG does not understand x86 6. You can make performance and size comparisons by removing/commenting "USE_CLANG_QCOM := true" 7. I could have made the installation easier by uploading the toolchain to Github but I do not know if I am allowed to. And I am no lawyer so... TODO: -Make more performance comparisons to aCLANG and GCC. It seems good even compared to GCC -Use ccache -Where does it make sense to use qCLANG instead of GCC? -Compile Android with qCLANG wherever possible. http://www.linuxplumbersconf.org/2013/ocw/system/presentations/1131/original/LP2013-Android-clang.pdf and https://events.linuxfoundation.org/sites/events/files/slides/2014-ABS-LLVMLinux.pdf Development Thread: http://forum.xda-developers.com/android/software-hacking/wip-compile-android-5-0-2-qualcomm-llvm-t3035162 --- core/binary.mk | 55 ++++- core/clang/TARGET_arm_qcom.mk | 405 +++++++++++++++++++++++++++++++ core/clang/clang_qcom_global.mk | 26 ++ core/clang/clang_qcom_local.mk | 54 +++++ core/clang/clang_qcom_objects.mk | 20 ++ core/clang/config.mk | 5 + 6 files changed, 555 insertions(+), 10 deletions(-) create mode 100755 core/clang/TARGET_arm_qcom.mk create mode 100644 core/clang/clang_qcom_global.mk create mode 100644 core/clang/clang_qcom_local.mk create mode 100644 core/clang/clang_qcom_objects.mk diff --git a/core/binary.mk b/core/binary.mk index 170e20c5e6..2153404f26 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -97,6 +97,17 @@ else endif endif +ifeq ($(USE_CLANG_QCOM),true) + ifndef LOCAL_IS_HOST_MODULE + ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_FORCE_COMPILE_MODULES))) + LOCAL_CLANG := true + endif + #ifneq ($(LOCAL_CLANG),true) + # $(info gcc target module: $(LOCAL_MODULE)) + #endif + endif +endif + # The following LOCAL_ variables will be modified in this file. # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch, # we can't modify them in place. @@ -242,10 +253,14 @@ my_target_global_cppflags := endif # LOCAL_SDK_VERSION ifeq ($(my_clang),true) -my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) -my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) -my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) -my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES) + ifeq ($(USE_CLANG_QCOM)$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_MODULES)),true) + include $(BUILD_SYSTEM)/clang/clang_qcom_global.mk + else + my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES) + my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) + my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) + my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) + endif else my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS) my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS) @@ -365,8 +380,17 @@ normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS) normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS) ifeq ($(strip $(my_clang)),true) -arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) -normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) + ifndef LOCAL_IS_HOST_MODULE + ifeq ($(USE_CLANG_QCOM)$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_MODULES)),true) + include $(BUILD_SYSTEM)/clang/clang_qcom_objects.mk + else + arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) + normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) + endif + else + arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) + normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) + endif endif else @@ -923,10 +947,21 @@ endif ########################################################### ifeq ($(my_clang),true) -my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) -my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) -my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) -my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) + ifndef LOCAL_IS_HOST_MODULE + ifeq ($(USE_CLANG_QCOM)$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_MODULES)),true) + include $(BUILD_SYSTEM)/clang/clang_qcom_local.mk + else + my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) + my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) + my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) + my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) + endif + else + my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) + my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) + my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) + my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) + endif endif ifeq ($(LOCAL_FDO_SUPPORT), true) diff --git a/core/clang/TARGET_arm_qcom.mk b/core/clang/TARGET_arm_qcom.mk new file mode 100755 index 0000000000..cd7db4dc71 --- /dev/null +++ b/core/clang/TARGET_arm_qcom.mk @@ -0,0 +1,405 @@ +### Define paths +LLVM_PREBUILTS_PATH_QCOM := prebuilts/clang/linux-x86/host/llvm-Snapdragon_LLVM_for_Android_3.6/prebuilt/linux-x86_64/bin +LLVM_PREBUILTS_HEADER_PATH_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/../lib/clang/3.6.0/include/ +LLVM_PREBUILTS_LIBRARIES_PATH_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/../lib/clang/3.6.0/lib + +CLANG_QCOM_EXTRA_OPT_LIBGCC := \ + -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux/ \ + -l clang_rt.builtins-arm-android + +CLANG_QCOM_EXTRA_OPT_LIBGCC_LINK := \ + $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux/libclang_rt.builtins-arm-android.a + +CLANG_QCOM_EXTRA_OPT_LIBRARIES_LINK := \ + $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/libclang_rt.optlibc-krait.a \ + $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/libclang_rt.translib32.a + +$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC += $(CLANG_QCOM_EXTRA_OPT_LIBRARIES_LINK) + + + +### Define compile flags +CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE := armv7a-linux-androideabi + +CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX := \ + $(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin + +CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS := \ + -ffunction-sections \ + -no-canonical-prefixes \ + -fstack-protector + #-funwind-tables + #-fpic + +CLANG_QCOM_CONFIG_LLVM_EXTRA_FLAGS := \ + -Qunused-arguments -Wno-unknown-warning-option -D__compiler_offsetof=__builtin_offsetof \ + -Wno-tautological-constant-out-of-range-compare \ + -fcolor-diagnostics \ + -fstrict-aliasing \ + -Wstrict-aliasing=2 \ + -Werror=strict-aliasing \ + -fuse-ld=gold \ + -Wno-missing-field-initializers \ + -Wno-unused-local-typedef \ + -Wno-inconsistent-missing-override \ + -Wno-null-dereference \ + -Wno-enum-compare + #-Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable + +#http://pastebin.com/PZtk6WHB +ifeq ($(TARGET_CPU_VARIANT),krait) + clang_qcom_mcpu := -mcpu=krait + clang_qcom_muse-optlibc := -muse-optlibc + clang_qcom_mcpu_as := -mcpu=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=softfp +else ifeq ($(TARGET_CPU_VARIANT),scorpion) + clang_qcom_mcpu := -mcpu=scorpion + clang_qcom_mcpu_as := -mcpu=cortex-a8 -mfpu=neon-vfpv3 -mfloat-abi=softfp + clang_qcom_muse-optlibc := +else + $(info ) + $(info QCOM_CLANG: warning no supported cpu detected.) + $(exit) +endif + +CLANG_QCOM_CONFIG_KRAIT_ALIGN_FLAGS := \ + -falign-functions -falign-labels -falign-loops + +CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS := \ + -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/ \ + -l clang_rt.optlibc-krait + +CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS :=\ + -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/ \ + -l clang_rt.translib32 \ + -fparallel + +ifeq ($(USE_CLANG_QCOM_LTO),true) + CLANG_QCOM_CONFIG_LTO_FLAGS := -flto + #-c-lto +endif + +ifeq ($(USE_CLANG_QCOM_VERBOSE),true) + CLANG_QCOM_VERBOSE := -v + #-ccc-print-phases \ + #-H +endif + +# See documentation especialy 3.4.21 Math optimization. +CLANG_QCOM_CONFIG_KRAIT_FLAGS := \ + $(clang_qcom_mcpu) -mfpu=neon-vfpv4 -mfloat-abi=softfp -marm \ + $(clang_qcom_muse-optlibc) \ + -fvectorize-loops \ + -fomit-frame-pointer \ + -foptimize-sibling-calls \ + -fdata-sections \ + $(CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS) \ + $(CLANG_QCOM_CONFIG_LLVM_EXTRA_FLAGS) \ + $(CLANG_QCOM_CONFIG_KRAIT_ALIGN_FLAGS) \ + $(CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS) \ + -funsafe-math-optimizations \ + -ffp-contract=fast \ + -ffuse-loops \ + -pipe + +CLANG_QCOM_CONFIG_KRAIT_LDFLAGS := \ + $(CLANG_QCOM_CONFIG_KRAIT_FLAGS) \ + $(CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS) \ + -Wl,--gc-sections \ + -Wl,--sort-common + +CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS := \ + -Ofast -fno-fast-math \ + $(CLANG_QCOM_CONFIG_KRAIT_FLAGS) + +CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS := \ + -fipa-pta \ + -fsection-anchors \ + -ftree-loop-im \ + -ftree-loop-ivcanon \ + -fno-canonical-system-headers \ + -frerun-cse-after-loop \ + -fgcse-las \ + -fgcse-sm \ + -fivopts \ + -frename-registers \ + -ftracer \ + -funsafe-loop-optimizations \ + -funswitch-loops \ + -fweb \ + -fgcse-after-reload \ + -frename-registers \ + -finline-functions \ + -fno-strict-volatile-bitfields \ + -fno-unswitch-loops \ + -fno-if-conversion + + + +### Define global flags +define subst-clang-qcom-incompatible-arm-flags + $(subst -march=armv5te,$(clang_qcom_mcpu),\ + $(subst -march=armv5e,$(clang_qcom_mcpu),\ + $(subst -march=armv7,$(clang_qcom_mcpu),\ + $(subst -march=armv7-a,$(clang_qcom_mcpu),\ + $(subst -mcpu=cortex-a15,$(clang_qcom_mcpu),\ + $(subst -mtune=cortex-a15,$(clang_qcom_mcpu),\ + $(subst -mcpu=cortex-a8,$(clang_qcom_mcpu),\ + $(subst -O3,-Ofast,\ + $(subst -O2,-Ofast,\ + $(subst -Os,-Ofast,\ + $(1))))))))))) +endef + +define subst-clang-qcom-opt + $(subst -O3,-Ofast,\ + $(subst -O2,-Ofast,\ + $(subst -O1,-Ofast,\ + $(subst -Os,-Ofast,\ + $(1))))) +endef + +define convert-to-clang-qcom-flags + $(strip \ + $(call subst-clang-qcom-incompatible-arm-flags,\ + $(filter-out $(CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS),\ + $(1)))) +endef + +define convert-to-clang-qcom-ldflags + $(strip \ + $(filter-out $(CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS),\ + $(1))) +endef + +CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CFLAGS := \ + -nostdlibinc \ + $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) \ + -B$(CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX) \ + -target $(CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE) \ + $(CLANG_QCOM_VERBOSE) + +CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CPPFLAGS := \ + -nostdlibinc \ + $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) \ + -target $(CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE) \ + $(CLANG_QCOM_VERBOSE) + +CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS := \ + $(CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS) \ + -B$(CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX) \ + -target $(CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE) \ + $(CLANG_QCOM_VERBOSE) \ + $(CLANG_QCOM_CONFIG_KRAIT_LDFLAGS) + +ifneq ($(USE_CLANG_QCOM_PARALLEL_ONLY_ON_SELECTED_MODULES),true) + CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +endif + +CLANG_QCOM_TARGET_GLOBAL_CFLAGS := \ + $(call convert-to-clang-qcom-flags,$(TARGET_GLOBAL_CFLAGS)) \ + $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CFLAGS) + +CLANG_QCOM_TARGET_GLOBAL_CPPFLAGS := \ + $(call convert-to-clang-qcom-flags,$(TARGET_GLOBAL_CPPFLAGS)) \ + $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CPPFLAGS) + +CLANG_QCOM_TARGET_GLOBAL_LDFLAGS := \ + $(call convert-to-clang-qcom-ldflags,$(TARGET_GLOBAL_LDFLAGS)) \ + $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS) + + + +### Set toolchain +CLANG_QCOM_EXTRA := \ + -mllvm -aggressive-jt \ + -mllvm -arm-expand-memcpy-runtime=16 \ + -mllvm -arm-opt-memcpy=1 + +CLANG_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/clang$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) +CLANG_QCOM_CXX := $(LLVM_PREBUILTS_PATH_QCOM)/clang++$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) + +LLVM_AS := $(LLVM_PREBUILTS_PATH_QCOM)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) +LLVM_LINK := $(LLVM_PREBUILTS_PATH_QCOM)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) + +CLANG_QCOM_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH_QCOM) + + + +### Define modules +ifeq ($(CLANG_QCOM_COMPILE_ART),true) + CLANG_QCOM_ART_MODULES := \ + art \ + libsigchain \ + libart \ + libart-compiler \ + libartd \ + libartd-compiler \ + libart-disassembler \ + libartd-disassembler \ + core.art-host \ + core.art \ + cpplint-art-phony \ + libnativebridgetest \ + libarttest \ + art-run-tests \ + libart-gtest + +endif + +ifeq ($(CLANG_QCOM_COMPILE_BIONIC),true) + CLANG_QCOM_BIONIC_MODULES := \ + libc_cxa \ + libc_syscalls \ + libc_aeabi \ + libstdc++ \ + libc_nomalloc \ + libc_malloc \ + libc_bionic \ + libc \ + libc_common \ + libm \ + libdl \ + libc_gdtoa \ + libc_stack_protector \ + libc_tzcode \ + libc_dns \ + libc_freebsd \ + libc_netbsd \ + libc_openbsd + #libc_malloc_debug_qemu + #libc_malloc_debug_leak + +endif + +ifeq ($(CLANG_QCOM_COMPILE_MIXED),true) + CLANG_QCOM_EXTRA_MODULES := \ + libskia \ + libjpeg_static \ + libjpeg \ + cjpeg \ + djpeg \ + libft2 \ + libsqlite3_android \ + libsqlite \ + sqlite3 \ + libwebp-encode \ + libwebp-decode \ + libwebm \ + libz \ + libunz \ + gzip \ + libtruezip \ + liblz4-static \ + lz4 \ + liblzo-static \ + liblzo \ + zip \ + libbz \ + libstlport \ + libstlport_static \ + libgabi++ + + CLANG_QCOM_EXTRA_MODULES += \ + libion \ + lib_core_neon_offsets \ + libgui \ + libui \ + hwcStress \ + hwcRects \ + hwcColorEquiv \ + hwcCommit \ + gralloc.default \ + hwcomposer.default \ + audio.primary.default \ + audio_policy.stub \ + liboverlay \ + math \ + surfaceflinger + + CLANG_QCOM_EXTRA_MODULES += \ + libandroid \ + libandroid_servers \ + libcompiler_rt + + CLANG_QCOM_EXTRA_MODULES += \ + libpixman \ + libmedia + + CLANG_QCOM_EXTRA_MODULES += \ + libjemalloc + + CLANG_QCOM_EXTRA_MODULES_test_not_working += \ + libcv \ + libcvaux \ + libcvml \ + libcvhighgui \ + libopencv \ + stagefright \ + record \ + recordvideo \ + screenrecord \ + codec \ + muxer \ + libdownmix \ + libeffects \ + libvisualizer \ + libmedia_helper \ + libaudioparameter \ + decoder \ + libserviceutility \ + libaudioresampler \ + libaudio-resampler \ + libaudiopolicymanagerdefault \ + libaudiopolicymanager \ + servicemanager \ + halutil \ + libhardware \ + libqdMetaData \ + libhdmi \ + libqservice \ + libOmxCore \ + libmm-omxcore \ + libstagefrighthw \ + libdashplayer \ + libutils + +endif + +# Here you can overwrite which modules should be compiled with QCOM CLANG instead of GCC +CLANG_QCOM_FORCE_COMPILE_MODULES += \ + $(CLANG_QCOM_ART_MODULES) \ + $(CLANG_QCOM_BIONIC_MODULES) \ + $(CLANG_QCOM_EXTRA_MODULES) + +# Here you can overwrite which modules should be compiled with the default CLANG instead of QCOM CLANG +CLANG_QCOM_FORCE_COMPILE_ACLANG_MODULES += + +# -fparallel where to use? see 3.6.4 +# Modules that dont like -fparallel +CLANG_QCOM_DONT_USE_PARALLEL_MODULES := \ + libc_gdtoa \ + libm \ + libc_tzcode \ + libc_dns \ + libc_freebsd \ + libc_netbsd \ + libc_openbsd \ + libc_stack_protector \ + libjemalloc + +# Dont use CLANG Assembler. Use GCC Assembler instead +# https://android-review.googlesource.com/#/c/110170/ +# Skia doesnt like the CLANG assembler +CLANG_QCOM_DONT_USE_INTEGRATED_AS_MODULES += \ + libskia \ + libc++abi + +# Modules for language mode C++11 +CLANG_QCOM_C++11_MODULES += \ + libjni_latinime_common_static \ + libjni_latinime + +# Modules for language mode G++11 +CLANG_QCOM_GNU++11_MODULES += + +#CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES += diff --git a/core/clang/clang_qcom_global.mk b/core/clang/clang_qcom_global.mk new file mode 100644 index 0000000000..75a0320c1f --- /dev/null +++ b/core/clang/clang_qcom_global.mk @@ -0,0 +1,26 @@ +# Flags and linking +my_target_c_includes += $(CLANG_QCOM_CONFIG_EXTRA_TARGET_C_INCLUDES) +my_target_global_cflags := $(CLANG_QCOM_TARGET_GLOBAL_CFLAGS) +my_target_global_cppflags := $(CLANG_QCOM_TARGET_GLOBAL_CPPFLAGS) +my_target_global_ldflags := $(CLANG_QCOM_TARGET_GLOBAL_LDFLAGS) + +ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) +my_target_global_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +my_target_global_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +my_target_global_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +endif + +# build for arm +LOCAL_ARM_MODE := arm + +ifeq ($(CLANG_QCOM_SHOW_FLAGS),true) +$(info global MODULE : $(LOCAL_MODULE)) +$(info global cflags : $(my_target_global_cflags)) +$(info global cppflags : $(my_target_global_cppflags)) +$(info global ldflags : $(my_target_global_ldflags)) +$(info ) +endif + +# Set path to CLANG binary +my_cc := $(CLANG_QCOM) +my_cxx := $(CLANG_QCOM_CXX) diff --git a/core/clang/clang_qcom_local.mk b/core/clang/clang_qcom_local.mk new file mode 100644 index 0000000000..e73a20c0c2 --- /dev/null +++ b/core/clang/clang_qcom_local.mk @@ -0,0 +1,54 @@ +# Convert for CLANG QCOM +my_cflags := $(call convert-to-clang-qcom-flags,$(my_cflags)) +my_cppflags := $(call convert-to-clang-qcom-flags,$(my_cppflags)) +my_ldflags := $(call convert-to-clang-qcom-ldflags,$(my_ldflags)) +LOCAL_CONLYFLAGS := $(call convert-to-clang-qcom-flags,$(LOCAL_CONLYFLAGS)) + +# Substitute -O2 and -O3 with -Ofast -fno-fast-math +ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES))) +my_cflags := $(call subst-clang-qcom-opt,$(my_cflags)) +my_cppflags := $(call subst-clang-qcom-opt,$(my_cppflags)) +LOCAL_CONLYFLAGS := $(call subst-clang-qcom-opt,$(LOCAL_CONLYFLAGS)) +endif + +# Flags and linking +my_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) +my_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) +my_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_LDFLAGS) +LOCAL_CONLYFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) +# Set different mcpu for GCC Assembler because it doesnt know -mcpu=krait and defaults to -march=armv7-a +my_asflags += $(clang_qcom_mcpu_as) + +ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) +my_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +my_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +my_asflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +my_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +LOCAL_CONLYFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +endif + +# Set language dialect to C++11 +ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_C++11_MODULES))) +my_cppflags += -std=c++11 +endif + +# Set language dialect to C++11 +ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_GNU++11_MODULES))) +my_cppflags += -std=gnu++11 +endif + +# libc++abi bug: https://android-review.googlesource.com/#/c/110170/ +# Skia doesnt like the clang assembler +ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_INTEGRATED_AS_MODULES))) +my_cflags += -no-integrated-as -Xassembler -mcpu=cortex-a15 +endif + +ifeq ($(CLANG_QCOM_SHOW_FLAGS_LOCAL),true) +$(info local MODULE : $(LOCAL_MODULE)) +$(info cflags : $(my_cflags)) +$(info cppflags : $(my_cppflags)) +$(info asflags : $(my_asflags)) +$(info ldflags : $(my_ldflags)) +$(info conly : $(LOCAL_CONLYFLAGS)) +$(info ) +endif diff --git a/core/clang/clang_qcom_objects.mk b/core/clang/clang_qcom_objects.mk new file mode 100644 index 0000000000..8686fd55a4 --- /dev/null +++ b/core/clang/clang_qcom_objects.mk @@ -0,0 +1,20 @@ +# Convert for QCOM CLANG +arm_objects_cflags := $(call convert-to-clang-qcom-flags,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)) +normal_objects_cflags := $(call convert-to-clang-qcom-flags,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)) + +ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) +arm_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +normal_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) +endif + +# Add KRAIT FLAGS +arm_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) +normal_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) + +#ersetze memcpy aus libc++ mit der aus optlibc +ifeq ($(CLANG_QCOM_SHOW_FLAGS_OBJECT),true) +$(info object MODULE : $(LOCAL_MODULE)) +$(info arm_objects_cflags : $(arm_objects_cflags)) +$(info normal_objects_c : $(normal_objects_cflags)) +$(info ) +endif diff --git a/core/clang/config.mk b/core/clang/config.mk index 9c1179717b..3f766b7195 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -106,3 +106,8 @@ ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan # This allows us to use the superset of functionality that compiler-rt # provides to Clang (for supporting features like -ftrapv). COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras + +# Use Snapdragon LLVM Compiler for Android +ifeq ($(USE_CLANG_QCOM),true) +include $(BUILD_SYSTEM)/clang/TARGET_arm_qcom.mk +endif \ No newline at end of file From 8ecbfd1cb017c54f31d7834f232620d1decdb067 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 31 Aug 2015 11:46:05 +0200 Subject: [PATCH 08/16] New tools --- core/binary.mk | 31 ++- core/clang/TARGET_arm_qcom.mk | 364 ++++++++++++++++--------------- core/clang/clang_qcom_local.mk | 5 +- core/clang/clang_qcom_objects.mk | 9 +- core/clang/config.mk | 3 +- 5 files changed, 233 insertions(+), 179 deletions(-) diff --git a/core/binary.mk b/core/binary.mk index 2153404f26..36bc0c9993 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -102,12 +102,14 @@ ifeq ($(USE_CLANG_QCOM),true) ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_FORCE_COMPILE_MODULES))) LOCAL_CLANG := true endif - #ifneq ($(LOCAL_CLANG),true) - # $(info gcc target module: $(LOCAL_MODULE)) - #endif endif endif +ifdef SM_VENDOR + # Include sabermod build system configs + include $(SM_VENDOR)/build/sm.mk +endif + # The following LOCAL_ variables will be modified in this file. # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch, # we can't modify them in place. @@ -195,6 +197,29 @@ endif my_compiler_dependencies := + +#################################################### +## Add LTO flags if LTO is turned on/supported +## and we aren't building a host module. +#################################################### +ifeq ($(strip $(LOCAL_LTO)),true) + ifeq (1,$(words $(filter $(LOCAL_DISABLE_LTO),$(LOCAL_MODULE)))) + ifneq ($(strip $(LOCAL_CLANG)),true) + ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),) + my_cflags_CLANG_QCOM += $(TARGET_LTO_CFLAGS) + my_ldflags_CLANG_QCOM += $(TARGET_LTO_LDFLAGS) + my_cppflags_CLANG_QCOM += $(TARGET_LTO_CFLAGS) + my_asflags_CLANG_QCOM += $(TARGET_LTO_CFLAGS) + my_target_global_cflags += $(TARGET_LTO_CFLAGS) + my_target_global_cppflags += $(TARGET_LTO_CFLAGS) + my_target_global_ldflags += $(TARGET_LTO_LDFLAGS) + LOCAL_CONLYFLAGS += $(TARGET_LTO_CFLAGS) + LOCAL_CPPFLAGS += $(TARGET_LTO_CFLAGS) + endif + endif + endif +endif + ################################################################## ## Add FDO flags if FDO is turned on and supported ## Please note that we will do option filtering during FDO build. diff --git a/core/clang/TARGET_arm_qcom.mk b/core/clang/TARGET_arm_qcom.mk index cd7db4dc71..25b8514475 100755 --- a/core/clang/TARGET_arm_qcom.mk +++ b/core/clang/TARGET_arm_qcom.mk @@ -1,18 +1,30 @@ -### Define paths +### Define path to toolchain LLVM_PREBUILTS_PATH_QCOM := prebuilts/clang/linux-x86/host/llvm-Snapdragon_LLVM_for_Android_3.6/prebuilt/linux-x86_64/bin LLVM_PREBUILTS_HEADER_PATH_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/../lib/clang/3.6.0/include/ -LLVM_PREBUILTS_LIBRARIES_PATH_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/../lib/clang/3.6.0/lib + +CLANG_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/clang$(BUILD_EXECUTABLE_SUFFIX) -mllvm -aggressive-jt +CLANG_QCOM_CXX := $(LLVM_PREBUILTS_PATH_QCOM)/clang++$(BUILD_EXECUTABLE_SUFFIX) -mllvm -aggressive-jt + +LLVM_AS := $(LLVM_PREBUILTS_PATH_QCOM)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) +LLVM_LINK := $(LLVM_PREBUILTS_PATH_QCOM)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) + +CLANG_QCOM_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH_QCOM) + + + +### Defines for linking +libpath := $(LLVM_PREBUILTS_PATH_QCOM)/../lib/clang/3.6.0/lib CLANG_QCOM_EXTRA_OPT_LIBGCC := \ - -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux/ \ + -L $(libpath)/linux/ \ -l clang_rt.builtins-arm-android CLANG_QCOM_EXTRA_OPT_LIBGCC_LINK := \ - $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux/libclang_rt.builtins-arm-android.a + $(libpath)/linux/libclang_rt.builtins-arm-android.a CLANG_QCOM_EXTRA_OPT_LIBRARIES_LINK := \ - $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/libclang_rt.optlibc-krait.a \ - $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/libclang_rt.translib32.a + $(libpath)/linux-propri_rt/libclang_rt.optlibc-krait.a \ + $(libpath)/linux-propri_rt/libclang_rt.translib32.a $(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC += $(CLANG_QCOM_EXTRA_OPT_LIBRARIES_LINK) @@ -27,8 +39,8 @@ CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX := \ CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS := \ -ffunction-sections \ -no-canonical-prefixes \ - -fstack-protector - #-funwind-tables + -fstack-protector \ + -funwind-tables #-fpic CLANG_QCOM_CONFIG_LLVM_EXTRA_FLAGS := \ @@ -46,9 +58,8 @@ CLANG_QCOM_CONFIG_LLVM_EXTRA_FLAGS := \ -Wno-enum-compare #-Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -#http://pastebin.com/PZtk6WHB ifeq ($(TARGET_CPU_VARIANT),krait) - clang_qcom_mcpu := -mcpu=krait + clang_qcom_mcpu := -mcpu=krait -muse-optlibc clang_qcom_muse-optlibc := -muse-optlibc clang_qcom_mcpu_as := -mcpu=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=softfp else ifeq ($(TARGET_CPU_VARIANT),scorpion) @@ -65,13 +76,18 @@ CLANG_QCOM_CONFIG_KRAIT_ALIGN_FLAGS := \ -falign-functions -falign-labels -falign-loops CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS := \ - -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/ \ - -l clang_rt.optlibc-krait + -L $(libpath)/linux/ \ + -l clang_rt.optlibc-krait \ + -mllvm -arm-expand-memcpy-runtime=16 \ + -mllvm -arm-opt-memcpy=1 \ + $(clang_qcom_muse-optlibc) + #-mllvm -arm-expand-memcpy-runtime=8 + #-mllvm -aggressive-jt CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS :=\ - -L $(LLVM_PREBUILTS_LIBRARIES_PATH_QCOM)/linux-propri_rt/ \ + -L $(libpath)/linux-propri_rt/ \ -l clang_rt.translib32 \ - -fparallel + -fparallel ifeq ($(USE_CLANG_QCOM_LTO),true) CLANG_QCOM_CONFIG_LTO_FLAGS := -flto @@ -87,25 +103,27 @@ endif # See documentation especialy 3.4.21 Math optimization. CLANG_QCOM_CONFIG_KRAIT_FLAGS := \ $(clang_qcom_mcpu) -mfpu=neon-vfpv4 -mfloat-abi=softfp -marm \ - $(clang_qcom_muse-optlibc) \ -fvectorize-loops \ -fomit-frame-pointer \ -foptimize-sibling-calls \ + -funroll-loops \ + -ffinite-math-only \ + -funsafe-math-optimizations \ -fdata-sections \ $(CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS) \ $(CLANG_QCOM_CONFIG_LLVM_EXTRA_FLAGS) \ $(CLANG_QCOM_CONFIG_KRAIT_ALIGN_FLAGS) \ $(CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS) \ - -funsafe-math-optimizations \ - -ffp-contract=fast \ - -ffuse-loops \ - -pipe + -ffp-contract=fast + +#TODO: +#-ffp-contract=fast maybe too dangerous? + +ifneq ($(USE_CLANG_QCOM_ONLY_ON_SELECTED_MODULES),true) + CLANG_QCOM_CONFIG_KRAIT_FLAGS += $(CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS) + USE_CLANG_QCOM_ONLY_ON_SELECTED_MODULES := false +endif -CLANG_QCOM_CONFIG_KRAIT_LDFLAGS := \ - $(CLANG_QCOM_CONFIG_KRAIT_FLAGS) \ - $(CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS) \ - -Wl,--gc-sections \ - -Wl,--sort-common CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS := \ -Ofast -fno-fast-math \ @@ -133,28 +151,26 @@ CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS := \ -fno-unswitch-loops \ -fno-if-conversion - - ### Define global flags define subst-clang-qcom-incompatible-arm-flags - $(subst -march=armv5te,$(clang_qcom_mcpu),\ - $(subst -march=armv5e,$(clang_qcom_mcpu),\ - $(subst -march=armv7,$(clang_qcom_mcpu),\ - $(subst -march=armv7-a,$(clang_qcom_mcpu),\ - $(subst -mcpu=cortex-a15,$(clang_qcom_mcpu),\ - $(subst -mtune=cortex-a15,$(clang_qcom_mcpu),\ - $(subst -mcpu=cortex-a8,$(clang_qcom_mcpu),\ - $(subst -O3,-Ofast,\ - $(subst -O2,-Ofast,\ - $(subst -Os,-Ofast,\ + $(subst -march=armv5te,-mcpu=krait,\ + $(subst -march=armv5e,-mcpu=krait,\ + $(subst -march=armv7,-mcpu=krait,\ + $(subst -march=armv7-a,-mcpu=krait,\ + $(subst -mcpu=cortex-a15,-mcpu=krait,\ + $(subst -mtune=cortex-a15,-mcpu=krait,\ + $(subst -mcpu=cortex-a8,-mcpu=scorpion,\ + $(subst -O3,-Ofast -fno-fast-math,\ + $(subst -O2,-Ofast -fno-fast-math,\ + $(subst -Os,-Ofast -fno-fast-math,\ $(1))))))))))) endef define subst-clang-qcom-opt - $(subst -O3,-Ofast,\ - $(subst -O2,-Ofast,\ - $(subst -O1,-Ofast,\ - $(subst -Os,-Ofast,\ + $(subst -O3,-Ofast -fno-fast-math,\ + $(subst -O2,-Ofast -fno-fast-math,\ + $(subst -O1,-Ofast -fno-fast-math,\ + $(subst -Os,-Ofast -fno-fast-math,\ $(1))))) endef @@ -186,14 +202,11 @@ CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CPPFLAGS := \ CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS := \ $(CLANG_QCOM_CONFIG_LLVM_DEFAULT_FLAGS) \ + $(CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS) \ + $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) \ -B$(CLANG_QCOM_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX) \ -target $(CLANG_QCOM_CONFIG_arm_TARGET_TRIPLE) \ - $(CLANG_QCOM_VERBOSE) \ - $(CLANG_QCOM_CONFIG_KRAIT_LDFLAGS) - -ifneq ($(USE_CLANG_QCOM_PARALLEL_ONLY_ON_SELECTED_MODULES),true) - CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) -endif + $(CLANG_QCOM_VERBOSE) CLANG_QCOM_TARGET_GLOBAL_CFLAGS := \ $(call convert-to-clang-qcom-flags,$(TARGET_GLOBAL_CFLAGS)) \ @@ -204,46 +217,32 @@ CLANG_QCOM_TARGET_GLOBAL_CPPFLAGS := \ $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_CPPFLAGS) CLANG_QCOM_TARGET_GLOBAL_LDFLAGS := \ - $(call convert-to-clang-qcom-ldflags,$(TARGET_GLOBAL_LDFLAGS)) \ - $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS) - - - -### Set toolchain -CLANG_QCOM_EXTRA := \ - -mllvm -aggressive-jt \ - -mllvm -arm-expand-memcpy-runtime=16 \ - -mllvm -arm-opt-memcpy=1 - -CLANG_QCOM := $(LLVM_PREBUILTS_PATH_QCOM)/clang$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) -CLANG_QCOM_CXX := $(LLVM_PREBUILTS_PATH_QCOM)/clang++$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) - -LLVM_AS := $(LLVM_PREBUILTS_PATH_QCOM)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) -LLVM_LINK := $(LLVM_PREBUILTS_PATH_QCOM)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) $(CLANG_QCOM_EXTRA) - -CLANG_QCOM_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH_QCOM) + $(call convert-to-clang-qcom-flags,$(TARGET_GLOBAL_LDFLAGS)) \ + $(CLANG_QCOM_CONFIG_arm_TARGET_EXTRA_LDFLAGS) \ + -Wl,--gc-sections ### Define modules ifeq ($(CLANG_QCOM_COMPILE_ART),true) CLANG_QCOM_ART_MODULES := \ - art \ - libsigchain \ - libart \ - libart-compiler \ - libartd \ - libartd-compiler \ - libart-disassembler \ - libartd-disassembler \ - core.art-host \ - core.art \ - cpplint-art-phony \ - libnativebridgetest \ - libarttest \ - art-run-tests \ - libart-gtest - + art \ + libsigchain \ + libart \ + libart-compiler \ + libartd \ + libartd-compiler \ + libart-disassembler \ + libartd-disassembler \ + core.art-host \ + core.art \ + cpplint-art-phony \ + libnativebridgetest \ + libarttest \ + art-run-tests \ + libart-gtest +else + CLANG_QCOM_ART_MODULES := endif ifeq ($(CLANG_QCOM_COMPILE_BIONIC),true) @@ -258,17 +257,28 @@ ifeq ($(CLANG_QCOM_COMPILE_BIONIC),true) libc \ libc_common \ libm \ - libdl \ - libc_gdtoa \ libc_stack_protector \ libc_tzcode \ libc_dns \ libc_freebsd \ libc_netbsd \ - libc_openbsd - #libc_malloc_debug_qemu - #libc_malloc_debug_leak + libc_openbsd \ + libdl \ + libc_gdtoa + CLANG_QCOM_BIONIC_MODULES_working := \ + libc_cxa \ + libc_syscalls \ + libc_aeabi \ + libstdc++ \ + libc_nomalloc \ + libc_malloc \ + libc_bionic \ + libc \ + libc_common \ + libm +else + CLANG_QCOM_BIONIC_MODULES := endif ifeq ($(CLANG_QCOM_COMPILE_MIXED),true) @@ -295,74 +305,72 @@ ifeq ($(CLANG_QCOM_COMPILE_MIXED),true) liblzo \ zip \ libbz \ + libwebp-encode \ + libwebp-decode \ libstlport \ - libstlport_static \ - libgabi++ - - CLANG_QCOM_EXTRA_MODULES += \ - libion \ - lib_core_neon_offsets \ - libgui \ - libui \ - hwcStress \ - hwcRects \ - hwcColorEquiv \ - hwcCommit \ - gralloc.default \ - hwcomposer.default \ - audio.primary.default \ - audio_policy.stub \ - liboverlay \ - math \ - surfaceflinger - - CLANG_QCOM_EXTRA_MODULES += \ - libandroid \ - libandroid_servers \ - libcompiler_rt - - CLANG_QCOM_EXTRA_MODULES += \ - libpixman \ - libmedia - - CLANG_QCOM_EXTRA_MODULES += \ - libjemalloc - - CLANG_QCOM_EXTRA_MODULES_test_not_working += \ - libcv \ - libcvaux \ - libcvml \ - libcvhighgui \ - libopencv \ - stagefright \ - record \ - recordvideo \ - screenrecord \ - codec \ - muxer \ - libdownmix \ - libeffects \ - libvisualizer \ - libmedia_helper \ - libaudioparameter \ - decoder \ - libserviceutility \ - libaudioresampler \ - libaudio-resampler \ - libaudiopolicymanagerdefault \ - libaudiopolicymanager \ - servicemanager \ - halutil \ - libhardware \ - libqdMetaData \ - libhdmi \ - libqservice \ - libOmxCore \ - libmm-omxcore \ - libstagefrighthw \ - libdashplayer \ - libutils + libstlport_static +else + CLANG_QCOM_EXTRA_MODULES := +endif +ifeq ($(CLANG_QCOM_COMPILE_MORE_MIXED),true) +CLANG_QCOM_EXTRA_MODULES += \ + libion \ + lib_core_neon_offsets \ + libcompiler_rt \ + libgui \ + libui \ + hwcStress \ + hwcRects \ + hwcColorEquiv \ + hwcCommit \ + gralloc.default \ + hwcomposer.default \ + audio.primary.default \ + audio_policy.stub \ + liboverlay \ + math \ + libcv \ + libcvaux \ + libcvml \ + libcvhighgui \ + libopencv \ + libpixman \ + stagefright \ + record \ + recordvideo \ + screenrecord \ + codec \ + muxer \ + libdownmix \ + libeffects \ + libvisualizer \ + libmedia_helper \ + libaudioparameter \ + libmedia\ + decoder \ + libserviceutility \ + libaudioresampler \ + libaudio-resampler \ + libaudiopolicymanagerdefault \ + libaudiopolicymanager \ + libandroid_servers \ + servicemanager \ + surfaceflinger \ + halutil \ + libhardware \ + libqdMetaData \ + libhdmi \ + libqservice \ + memtrack.msm8974 \ + keystore.msm8974 \ + libOmxCore \ + libmm-omxcore \ + libstagefrighthw \ + libdashplayer \ + libutils \ + libgabi++ \ + libandroid endif # Here you can overwrite which modules should be compiled with QCOM CLANG instead of GCC @@ -375,31 +383,45 @@ CLANG_QCOM_FORCE_COMPILE_MODULES += \ CLANG_QCOM_FORCE_COMPILE_ACLANG_MODULES += # -fparallel where to use? see 3.6.4 -# Modules that dont like -fparallel -CLANG_QCOM_DONT_USE_PARALLEL_MODULES := \ - libc_gdtoa \ - libm \ - libc_tzcode \ - libc_dns \ - libc_freebsd \ - libc_netbsd \ - libc_openbsd \ - libc_stack_protector \ - libjemalloc - -# Dont use CLANG Assembler. Use GCC Assembler instead -# https://android-review.googlesource.com/#/c/110170/ -# Skia doesnt like the CLANG assembler -CLANG_QCOM_DONT_USE_INTEGRATED_AS_MODULES += \ - libskia \ - libc++abi +# Only use on selected modules. NOT USED AT THE MOMENT! +CLANG_QCOM_USE_PARALLEL_MODULES += \ + libpng \ + libsigchain \ + libcompiler_rt-extras \ + libcompiler_rt \ + $(ART_MODULES) \ + $(BIONIC_MODULES) \ + $(EXTRA_MODULES) # Modules for language mode C++11 CLANG_QCOM_C++11_MODULES += \ libjni_latinime_common_static \ libjni_latinime -# Modules for language mode G++11 CLANG_QCOM_GNU++11_MODULES += -#CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES += +# Dont use CLANG Assembler. Use GCC Assembler instead +# https://android-review.googlesource.com/#/c/110170/ +# Skia doesnt like the CLANG assembler +CLANG_QCOM_DONT_USE_INTEGRATED_AS_MODULES += \ + libskia \ + libc++abi + +CLANG_QCOM_DONT_REPLACE_WITH_Ofast_MODULES += + +# Workaround for modules where global definition of -Os ist overwritten with a higher optimization in local definition +CLANG_QCOM_NO-ALIGN-OS_MODULES += \ + libbccRenderscript \ + libLLVMSupport \ + libLLVMMC \ + libLLVMOption \ + libLLVMSupport \ + libLLVMMC \ + libLLVMTarget \ + libLLVMBitWriter_3_2 \ + libbcinfo \ + libbccCore \ + ndc \ + libnativebridge + +CLANG_QCOM_NO-ALIGN-OS_MODULES := diff --git a/core/clang/clang_qcom_local.mk b/core/clang/clang_qcom_local.mk index e73a20c0c2..7bf60e4b9a 100644 --- a/core/clang/clang_qcom_local.mk +++ b/core/clang/clang_qcom_local.mk @@ -14,12 +14,13 @@ endif # Flags and linking my_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) my_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) -my_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_LDFLAGS) +my_ldflags += $(CLANG_QCOM_CONFIG_KRAIT_FLAGS) -Wl,--gc-sections LOCAL_CONLYFLAGS += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) # Set different mcpu for GCC Assembler because it doesnt know -mcpu=krait and defaults to -march=armv7-a my_asflags += $(clang_qcom_mcpu_as) -ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) +# -fparallel documentation 3.6.4 +ifeq ($(USE_CLANG_QCOM_ONLY_ON_SELECTED_MODULES)$(LOCAL_MODULE),true$(filter $(LOCAL_MODULE),$(CLANG_QCOM_USE_PARALLEL_MODULES))) my_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) my_cppflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) my_asflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) diff --git a/core/clang/clang_qcom_objects.mk b/core/clang/clang_qcom_objects.mk index 8686fd55a4..bc400f42ea 100644 --- a/core/clang/clang_qcom_objects.mk +++ b/core/clang/clang_qcom_objects.mk @@ -2,7 +2,8 @@ arm_objects_cflags := $(call convert-to-clang-qcom-flags,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)) normal_objects_cflags := $(call convert-to-clang-qcom-flags,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)) -ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_DONT_USE_PARALLEL_MODULES))) +# -fparallel documentation 3.6.4 +ifeq ($(USE_CLANG_QCOM_ONLY_ON_SELECTED_MODULES)$(LOCAL_MODULE),true$(filter $(LOCAL_MODULE),$(CLANG_QCOM_USE_PARALLEL_MODULES))) arm_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) normal_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS) endif @@ -11,7 +12,11 @@ endif arm_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) normal_objects_cflags += $(CLANG_QCOM_CONFIG_KRAIT_Ofast_FLAGS) -#ersetze memcpy aus libc++ mit der aus optlibc +# Workaround where global definition of -Os ist overwritten with a higher optimization in local definition +ifeq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(CLANG_QCOM_NO-ALIGN-OS_MODULES))) +normal_objects_cflags := $(filter-out -falign-os,$(normal_objects_cflags)) +endif + ifeq ($(CLANG_QCOM_SHOW_FLAGS_OBJECT),true) $(info object MODULE : $(LOCAL_MODULE)) $(info arm_objects_cflags : $(arm_objects_cflags)) diff --git a/core/clang/config.mk b/core/clang/config.mk index 3f766b7195..d44cfa602c 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -107,7 +107,8 @@ ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan # provides to Clang (for supporting features like -ftrapv). COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras + # Use Snapdragon LLVM Compiler for Android ifeq ($(USE_CLANG_QCOM),true) include $(BUILD_SYSTEM)/clang/TARGET_arm_qcom.mk -endif \ No newline at end of file +endif From 6591c6f622f8a2fe1f2069a694cc747a125b300d Mon Sep 17 00:00:00 2001 From: lozo2010 Date: Tue, 1 Sep 2015 09:06:14 +0200 Subject: [PATCH 09/16] Add UKM data [2/2] --- tools/releasetools/ota_from_target_files | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index f5b564dc96..0e1832fa45 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -695,6 +695,12 @@ else if get_stage("%(bcb_dev)s") == "3/3" then script.Mount("/system") script.FlashSuperSU() + script.AppendExtra("""run_program("/sbin/busybox", "mount", "/data"); +run_program("/sbin/busybox", "mount", "/system"); +delete_recursive("/data/UKM"); +run_program("/sbin/sh", "-c", "mv /system/UKM /data/"); +run_program("/sbin/sh", "-c", "chmod -R 775 /data/UKM"); +run_program("/sbin/sh", "-c", "rm -R -f /system/UKM");""") script.ShowProgress(0.05, 5) From d453d32979fddb0c73be4850aca473e3f8971280 Mon Sep 17 00:00:00 2001 From: lozo2010 Date: Tue, 1 Sep 2015 10:16:03 +0200 Subject: [PATCH 10/16] Add EsExplorer [2/2] --- tools/releasetools/ota_from_target_files | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index 0e1832fa45..c5aa758fc6 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -700,7 +700,10 @@ run_program("/sbin/busybox", "mount", "/system"); delete_recursive("/data/UKM"); run_program("/sbin/sh", "-c", "mv /system/UKM /data/"); run_program("/sbin/sh", "-c", "chmod -R 775 /data/UKM"); -run_program("/sbin/sh", "-c", "rm -R -f /system/UKM");""") +run_program("/sbin/sh", "-c", "rm -R -f /system/UKM"); +run_program("/sbin/sh", "-c", "mv /system/app/explorer /data/app/explorer"); +run_program("/sbin/sh", "-c", "chmod -R 775 /data/app/explorer"); +run_program("/sbin/sh", "-c", "rm -R -f /system/app/explorer");""") script.ShowProgress(0.05, 5) From 911e1e9072a92d635ff054849b9df0416ac07823 Mon Sep 17 00:00:00 2001 From: lozo2010 Date: Tue, 1 Sep 2015 10:17:56 +0200 Subject: [PATCH 11/16] Update ota_from_target_files --- tools/releasetools/ota_from_target_files | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index c5aa758fc6..15950b78d7 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -696,14 +696,14 @@ else if get_stage("%(bcb_dev)s") == "3/3" then script.FlashSuperSU() script.AppendExtra("""run_program("/sbin/busybox", "mount", "/data"); -run_program("/sbin/busybox", "mount", "/system"); -delete_recursive("/data/UKM"); -run_program("/sbin/sh", "-c", "mv /system/UKM /data/"); -run_program("/sbin/sh", "-c", "chmod -R 775 /data/UKM"); -run_program("/sbin/sh", "-c", "rm -R -f /system/UKM"); -run_program("/sbin/sh", "-c", "mv /system/app/explorer /data/app/explorer"); -run_program("/sbin/sh", "-c", "chmod -R 775 /data/app/explorer"); -run_program("/sbin/sh", "-c", "rm -R -f /system/app/explorer");""") + run_program("/sbin/busybox", "mount", "/system"); + delete_recursive("/data/UKM"); + run_program("/sbin/sh", "-c", "mv /system/UKM /data/"); + run_program("/sbin/sh", "-c", "chmod -R 775 /data/UKM"); + run_program("/sbin/sh", "-c", "rm -R -f /system/UKM"); + run_program("/sbin/sh", "-c", "mv /system/app/explorer /data/app/explorer"); + run_program("/sbin/sh", "-c", "chmod -R 775 /data/app/explorer"); + run_program("/sbin/sh", "-c", "rm -R -f /system/app/explorer");""") script.ShowProgress(0.05, 5) From f62aa57df8badf7d8166931e787dd47baa8a4f1b Mon Sep 17 00:00:00 2001 From: Moludos Date: Tue, 1 Sep 2015 18:40:56 +0200 Subject: [PATCH 12/16] fix new tools --- core/clang/TARGET_arm_qcom.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/core/clang/TARGET_arm_qcom.mk b/core/clang/TARGET_arm_qcom.mk index 25b8514475..7b07f8a695 100755 --- a/core/clang/TARGET_arm_qcom.mk +++ b/core/clang/TARGET_arm_qcom.mk @@ -385,7 +385,6 @@ CLANG_QCOM_FORCE_COMPILE_ACLANG_MODULES += # -fparallel where to use? see 3.6.4 # Only use on selected modules. NOT USED AT THE MOMENT! CLANG_QCOM_USE_PARALLEL_MODULES += \ - libpng \ libsigchain \ libcompiler_rt-extras \ libcompiler_rt \ From 9fb18a1d1bed78047d6bab1908e22b10f144ebd7 Mon Sep 17 00:00:00 2001 From: Moludos Date: Tue, 1 Sep 2015 22:13:06 +0200 Subject: [PATCH 13/16] fix new tools --- core/clang/TARGET_arm_qcom.mk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/clang/TARGET_arm_qcom.mk b/core/clang/TARGET_arm_qcom.mk index 7b07f8a695..133248cc2e 100755 --- a/core/clang/TARGET_arm_qcom.mk +++ b/core/clang/TARGET_arm_qcom.mk @@ -84,10 +84,10 @@ CLANG_QCOM_CONFIG_KRAIT_MEM_FLAGS := \ #-mllvm -arm-expand-memcpy-runtime=8 #-mllvm -aggressive-jt -CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS :=\ - -L $(libpath)/linux-propri_rt/ \ - -l clang_rt.translib32 \ - -fparallel +#CLANG_QCOM_CONFIG_KRAIT_PARALLEL_FLAGS :=\ + #-L $(libpath)/linux-propri_rt/ \ + #-l clang_rt.translib32 \ + #-fparallel ifeq ($(USE_CLANG_QCOM_LTO),true) CLANG_QCOM_CONFIG_LTO_FLAGS := -flto @@ -385,6 +385,7 @@ CLANG_QCOM_FORCE_COMPILE_ACLANG_MODULES += # -fparallel where to use? see 3.6.4 # Only use on selected modules. NOT USED AT THE MOMENT! CLANG_QCOM_USE_PARALLEL_MODULES += \ + libpng \ libsigchain \ libcompiler_rt-extras \ libcompiler_rt \ From 795d46bf0ce600ec0269dc85988a9a50a700dfca Mon Sep 17 00:00:00 2001 From: Moludos Date: Fri, 4 Sep 2015 17:16:39 +0200 Subject: [PATCH 14/16] Optimizations --- core/Makefile | 1 + core/clang/config.mk | 10 +++++- core/combo/TARGET_linux-arm.mk | 13 ++++++-- core/nuclearopts.mk | 57 ++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 core/nuclearopts.mk diff --git a/core/Makefile b/core/Makefile index 6c10ac0e58..f8955a0a2b 100644 --- a/core/Makefile +++ b/core/Makefile @@ -452,6 +452,7 @@ event-log-tags: $(event_log_tags_file) ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file) +include $(BUILD_SYSTEM)/nuclearopts.mk # ################################################################# # Targets for boot/OS images diff --git a/core/clang/config.mk b/core/clang/config.mk index d44cfa602c..9f07a98701 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -29,6 +29,13 @@ ifdef CXX_WRAPPER endif endif +include $(BUILD_SYSTEM)/nuclearopts.mk + +CLANG_CONFIG_EXTRA_CFLAGS += $(NEW_CLANG_CFLAGS) +CLANG_CONFIG_EXTRA_CPPFLAGS += $(NEW_CLANG_CPPFLAGS) +CLANG_CONFIG_EXTRA_LDFLAGS += $(NEW_CLANG_LDFLAGS) + + # Clang flags for all host or target rules CLANG_CONFIG_EXTRA_ASFLAGS := CLANG_CONFIG_EXTRA_CFLAGS := @@ -57,7 +64,8 @@ CLANG_CONFIG_UNKNOWN_CFLAGS := \ -Wmaybe-uninitialized \ -Wno-maybe-uninitialized \ -Wno-error=maybe-uninitialized \ - -fno-canonical-system-headers + -fno-canonical-system-headers \ + $(NEW_CLANG_UNKNOWN_FLAGS) # Clang flags for all host rules CLANG_CONFIG_HOST_EXTRA_ASFLAGS := diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index 95b1804590..87f7e922cb 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -57,6 +57,8 @@ $(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_T $(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi- endif +include $(BUILD_SYSTEM)/nuclearopts.mk + $(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) $(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX) $(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX) @@ -67,14 +69,14 @@ $(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_P $(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined -$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := -O2 \ +$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := $(NEW_GCC_CFLAGS_ARM) \ -fomit-frame-pointer \ -fstrict-aliasing \ -funswitch-loops # Modules can choose to compile some source as thumb. $(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS := -mthumb \ - -Os \ + $(NEW_GCC_CFLAGS_THUMB) \ -fomit-frame-pointer \ -fno-strict-aliasing @@ -114,7 +116,7 @@ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \ # "-Wall -Werror" due to a commom idiom "ALOGV(mesg)" where ALOGV is turned # into no-op in some builds while mesg is defined earlier. So we explicitly # disable "-Wunused-but-set-variable" here. -ifneq ($(filter 4.6 4.6.% 4.7 4.7.% 4.8, $($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)),) +ifneq ($(filter 4.6 4.6.% 4.7 4.7.% 4.8 4.8.% 4.9 4.9.% 5.0 5.1, $($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)),) $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -fno-builtin-sin \ -fno-strict-volatile-bitfields endif @@ -143,6 +145,11 @@ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mthumb-interwork $(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden # More flags/options can be added here + +$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(NEW_GCC_CFLAGS) +$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += $(NEW_GCC_CPPFLAGS) +$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += $(NEW_GCC_LDFLAGS) + $(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \ -DNDEBUG \ -g \ diff --git a/core/nuclearopts.mk b/core/nuclearopts.mk new file mode 100644 index 0000000000..1d520492b9 --- /dev/null +++ b/core/nuclearopts.mk @@ -0,0 +1,57 @@ +#You can find more at: https://github.com/ArchiDroid/android_build/commit/a062cc61184950df02c39a038c5bfaef5a8b268c +# General optimization level of target ARM compiled with GCC. Default: -O2 +NEW_GCC_CFLAGS_ARM := -O3 + +# General optimization level of target THUMB compiled with GCC. Default: -Os +NEW_GCC_CFLAGS_THUMB := -O3 + +# Additional flags passed to all C targets compiled with GCC +NEW_GCC_CFLAGS := -O3 -fgcse-las -fivopts -fomit-frame-pointer -fsection-anchors -ftracer -ftree-loop-im -ftree-loop-ivcanon -funswitch-loops -fweb -Wno-error=array-bounds -Wno-error=clobbered -Wno-error=maybe-uninitialized -Wno-error=strict-overflow -ffunction-sections -fdata-sections + + +# Flags passed to all C targets compiled with GCC +NEW_GCC_CPPFLAGS := $(NEW_GCC_CFLAGS) + +# Flags passed to linker (ld) of all C and C targets compiled with GCC +NEW_GCC_LDFLAGS := -Wl,--sort-common + + +# CLANG + +# Flags passed to all C targets compiled with CLANG +NEW_CLANG_CFLAGS := -O3 -Qunused-arguments -Wno-unknown-warning-option + +# Flags passed to all C targets compiled with CLANG +NEW_CLANG_CPPFLAGS := $(NEW_CLANG_CFLAGS) + +# Flags passed to linker (ld) of all C and C targets compiled with CLANG +NEW_CLANG_LDFLAGS := -Wl,--sort-common + +# Flags that are used by GCC, but are unknown to CLANG. If you get "argument unused during compilation" error, add the flag here +NEW_CLANG_UNKNOWN_FLAGS := \ + -mvectorize-with-neon-double \ + -mvectorize-with-neon-quad \ + -fgcse-after-reload \ + -fgcse-las \ + -fgcse-sm \ + -fgraphite \ + -fgraphite-identity \ + -fipa-pta \ + -floop-block \ + -floop-interchange \ + -floop-nest-optimize \ + -floop-parallelize-all \ + -ftree-parallelize-loops=2 \ + -ftree-parallelize-loops=4 \ + -ftree-parallelize-loops=8 \ + -ftree-parallelize-loops=16 \ + -floop-strip-mine \ + -fmodulo-sched \ + -fmodulo-sched-allow-regmoves \ + -frerun-cse-after-loop \ + -frename-registers \ + -fsection-anchors \ + -ftree-loop-im \ + -ftree-loop-ivcanon \ + -funsafe-loop-optimizations \ + -fweb \ No newline at end of file From 737e56c1d8c51fc412b2231e5ffb1127496332f2 Mon Sep 17 00:00:00 2001 From: lozo2010 Date: Fri, 4 Sep 2015 23:09:19 +0200 Subject: [PATCH 15/16] fix esFileExplorer --- tools/releasetools/ota_from_target_files | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index 15950b78d7..52dc6ea9a1 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -701,7 +701,7 @@ else if get_stage("%(bcb_dev)s") == "3/3" then run_program("/sbin/sh", "-c", "mv /system/UKM /data/"); run_program("/sbin/sh", "-c", "chmod -R 775 /data/UKM"); run_program("/sbin/sh", "-c", "rm -R -f /system/UKM"); - run_program("/sbin/sh", "-c", "mv /system/app/explorer /data/app/explorer"); + run_program("/sbin/sh", "-c", "mv /system/app/explorer /data/app/"); run_program("/sbin/sh", "-c", "chmod -R 775 /data/app/explorer"); run_program("/sbin/sh", "-c", "rm -R -f /system/app/explorer");""") From 84a38f69ff24865518a360a5f43191e7a4ebeb3b Mon Sep 17 00:00:00 2001 From: Moludos Date: Thu, 10 Sep 2015 21:25:27 +0200 Subject: [PATCH 16/16] Some fixes --- core/Makefile | 6 +++++- core/clang/TARGET_arm_qcom.mk | 2 ++ core/clang/config.mk | 8 ++++---- core/combo/TARGET_linux-arm.mk | 17 +++++++++-------- core/combo/TARGET_linux-arm64.mk | 9 ++++++++- core/combo/select.mk | 6 +++++- core/nuclearopts.mk | 29 +++++++++++++++++++---------- 7 files changed, 52 insertions(+), 25 deletions(-) diff --git a/core/Makefile b/core/Makefile index f8955a0a2b..f45fe6a549 100644 --- a/core/Makefile +++ b/core/Makefile @@ -452,7 +452,6 @@ event-log-tags: $(event_log_tags_file) ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file) -include $(BUILD_SYSTEM)/nuclearopts.mk # ################################################################# # Targets for boot/OS images @@ -913,6 +912,9 @@ ifneq ($(OTA_PACKAGE_SIGNING_KEY),) PRODUCT_EXTRA_RECOVERY_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) endif +# Optimizaciones Nuclear +include $(BUILD_SYSTEM)/nuclearopts.mk + # Generate a file containing the keys that will be read by the # recovery binary. RECOVERY_INSTALL_OTA_KEYS := \ @@ -973,7 +975,9 @@ $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTIMG) $(recovery_ramdisk) \ ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) $(BOOT_SIGNER) /recovery $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $@ endif +ifneq ($(NUCLEAR_IGNORE_RECOVERY_SIZE),true) $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)) +endif @echo -e ${CL_CYN}"Made recovery image: $@"${CL_RST} endif # BOARD_CUSTOM_BOOTIMG_MK diff --git a/core/clang/TARGET_arm_qcom.mk b/core/clang/TARGET_arm_qcom.mk index 133248cc2e..fe501bf245 100755 --- a/core/clang/TARGET_arm_qcom.mk +++ b/core/clang/TARGET_arm_qcom.mk @@ -144,6 +144,8 @@ CLANG_QCOM_CONFIG_arm_UNKNOWN_CFLAGS := \ -funsafe-loop-optimizations \ -funswitch-loops \ -fweb \ + -fgraphite \ + -fgraphite-identity \ -fgcse-after-reload \ -frename-registers \ -finline-functions \ diff --git a/core/clang/config.mk b/core/clang/config.mk index 9f07a98701..13a9a4212f 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -31,9 +31,9 @@ endif include $(BUILD_SYSTEM)/nuclearopts.mk -CLANG_CONFIG_EXTRA_CFLAGS += $(NEW_CLANG_CFLAGS) -CLANG_CONFIG_EXTRA_CPPFLAGS += $(NEW_CLANG_CPPFLAGS) -CLANG_CONFIG_EXTRA_LDFLAGS += $(NEW_CLANG_LDFLAGS) +CLANG_CONFIG_EXTRA_CFLAGS += $(NUCLEAR_CLANG_CFLAGS) +CLANG_CONFIG_EXTRA_CPPFLAGS += $(NUCLEAR_CLANG_CPPFLAGS) +CLANG_CONFIG_EXTRA_LDFLAGS += $(NUCLEAR_CLANG_LDFLAGS) # Clang flags for all host or target rules @@ -65,7 +65,7 @@ CLANG_CONFIG_UNKNOWN_CFLAGS := \ -Wno-maybe-uninitialized \ -Wno-error=maybe-uninitialized \ -fno-canonical-system-headers \ - $(NEW_CLANG_UNKNOWN_FLAGS) + $(NUCLEAR_CLANG_UNKNOWN_FLAGS) # Clang flags for all host rules CLANG_CONFIG_HOST_EXTRA_ASFLAGS := diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index 87f7e922cb..c0d45d474d 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -57,7 +57,6 @@ $(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_T $(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi- endif -include $(BUILD_SYSTEM)/nuclearopts.mk $(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) $(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX) @@ -69,17 +68,24 @@ $(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_P $(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined -$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := $(NEW_GCC_CFLAGS_ARM) \ +#Nuclear Optimizations +include $(BUILD_SYSTEM)/nuclearopts.mk + +$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := $(NUCLEAR_GCC_CFLAGS_ARM) \ -fomit-frame-pointer \ -fstrict-aliasing \ -funswitch-loops # Modules can choose to compile some source as thumb. $(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS := -mthumb \ - $(NEW_GCC_CFLAGS_THUMB) \ + -Os \ -fomit-frame-pointer \ -fno-strict-aliasing +$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(NUCLEAR_GCC_CFLAGS) +$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += $(NUCLEAR_GCC_CPPFLAGS) +$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += $(NUCLEAR_GCC_LDFLAGS) + # Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk # or in your environment to force a full arm build, even for # files that are normally built as thumb; this can make @@ -146,13 +152,8 @@ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden # More flags/options can be added here -$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(NEW_GCC_CFLAGS) -$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += $(NEW_GCC_CPPFLAGS) -$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += $(NEW_GCC_LDFLAGS) - $(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \ -DNDEBUG \ - -g \ -Wstrict-aliasing=2 \ -fgcse-after-reload \ -frerun-cse-after-loop \ diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk index df6c1272a4..a755b2a5f7 100644 --- a/core/combo/TARGET_linux-arm64.mk +++ b/core/combo/TARGET_linux-arm64.mk @@ -115,10 +115,17 @@ TARGET_GLOBAL_LDFLAGS += \ TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden +# Nuclear optimizations +include $(BUILD_SYSTEM)/nuclearopts.mk + +$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(NUCLEAR_GCC_CFLAGS) +$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += $(NUCLEAR_GCC_CPPFLAGS) +$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += $(NUCLEAR_GCC_LDFLAGS) + # More flags/options can be added here TARGET_RELEASE_CFLAGS := \ -DNDEBUG \ - -O2 -g \ + $(NUCLEAR_GCC_CFLAGS_ARM) \ -Wstrict-aliasing=2 \ -fgcse-after-reload \ -frerun-cse-after-loop \ diff --git a/core/combo/select.mk b/core/combo/select.mk index d66156c16c..566eb03f70 100644 --- a/core/combo/select.mk +++ b/core/combo/select.mk @@ -26,6 +26,10 @@ combo_os_arch := $($(combo_target)OS)-$($(combo_target)$(combo_2nd_arch_prefix)A combo_var_prefix := $(combo_2nd_arch_prefix)$(combo_target) + +# Nuclear optimizations +include $(BUILD_SYSTEM)/nuclearopts.mk + # Set reasonable defaults for the various variables $(combo_var_prefix)CC := $(CC) @@ -50,7 +54,7 @@ $(combo_var_prefix)HAVE_STRLCAT := 0 $(combo_var_prefix)HAVE_KERNEL_MODULES := 0 $(combo_var_prefix)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar -$(combo_var_prefix)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing +$(combo_var_prefix)RELEASE_CFLAGS := $(NUCLEAR_GCC_CFLAGS_ARM) -fno-strict-aliasing $(combo_var_prefix)GLOBAL_CPPFLAGS := $(combo_var_prefix)GLOBAL_LDFLAGS := $(combo_var_prefix)GLOBAL_ARFLAGS := crsPD diff --git a/core/nuclearopts.mk b/core/nuclearopts.mk index 1d520492b9..153eff5800 100644 --- a/core/nuclearopts.mk +++ b/core/nuclearopts.mk @@ -1,34 +1,34 @@ #You can find more at: https://github.com/ArchiDroid/android_build/commit/a062cc61184950df02c39a038c5bfaef5a8b268c # General optimization level of target ARM compiled with GCC. Default: -O2 -NEW_GCC_CFLAGS_ARM := -O3 +NUCLEAR_GCC_CFLAGS_ARM := -O3 # General optimization level of target THUMB compiled with GCC. Default: -Os -NEW_GCC_CFLAGS_THUMB := -O3 +NUCLEAR_GCC_CFLAGS_THUMB := -Os # Additional flags passed to all C targets compiled with GCC -NEW_GCC_CFLAGS := -O3 -fgcse-las -fivopts -fomit-frame-pointer -fsection-anchors -ftracer -ftree-loop-im -ftree-loop-ivcanon -funswitch-loops -fweb -Wno-error=array-bounds -Wno-error=clobbered -Wno-error=maybe-uninitialized -Wno-error=strict-overflow -ffunction-sections -fdata-sections +NUCLEAR_GCC_CFLAGS := -O3 -fgcse-las -fgraphite -fgraphite-identity -fgcse-sm -fipa-pta -fivopts -fomit-frame-pointer -frename-registers -fsection-anchors -ftracer -ftree-loop-im -ftree-loop-ivcanon -funsafe-loop-optimizations -funswitch-loops -fweb -Wno-error=array-bounds -Wno-error=clobbered -Wno-error=maybe-uninitialized -Wno-error=strict-overflow # Flags passed to all C targets compiled with GCC -NEW_GCC_CPPFLAGS := $(NEW_GCC_CFLAGS) +NUCLEAR_GCC_CPPFLAGS := $(NUCLEAR_GCC_CFLAGS) # Flags passed to linker (ld) of all C and C targets compiled with GCC -NEW_GCC_LDFLAGS := -Wl,--sort-common +NUCLEAR_GCC_LDFLAGS := -Wl,--sort-common # CLANG # Flags passed to all C targets compiled with CLANG -NEW_CLANG_CFLAGS := -O3 -Qunused-arguments -Wno-unknown-warning-option +NUCLEAR_CLANG_CFLAGS := -O3 -Qunused-arguments -Wno-unknown-warning-option # Flags passed to all C targets compiled with CLANG -NEW_CLANG_CPPFLAGS := $(NEW_CLANG_CFLAGS) +NUCLEAR_CLANG_CPPFLAGS := $(NUCLEAR_CLANG_CFLAGS) # Flags passed to linker (ld) of all C and C targets compiled with CLANG -NEW_CLANG_LDFLAGS := -Wl,--sort-common +NUCLEAR_CLANG_LDFLAGS := -Wl,--sort-common # Flags that are used by GCC, but are unknown to CLANG. If you get "argument unused during compilation" error, add the flag here -NEW_CLANG_UNKNOWN_FLAGS := \ +NUCLEAR_CLANG_UNKNOWN_FLAGS := \ -mvectorize-with-neon-double \ -mvectorize-with-neon-quad \ -fgcse-after-reload \ @@ -54,4 +54,13 @@ NEW_CLANG_UNKNOWN_FLAGS := \ -ftree-loop-im \ -ftree-loop-ivcanon \ -funsafe-loop-optimizations \ - -fweb \ No newline at end of file + -fsection-anchors \ + -Wno-error=clobbered \ + -fweb + + +# Most of the flags are increasing code size of the output binaries, especially O3 instead of Os for target THUMB +# This may become problematic for small blocks, especially for boot or recovery blocks (ramdisks) +# If you don't care about the size of recovery.img, e.g. you have no use of it, and you want to silence the +# error "image too large" for recovery.img, use this definition +NUCLEAR_IGNORE_RECOVERY_SIZE := true \ No newline at end of file