[PATCH] D29050: [zorg] Add AOSP builder

Pengxuan Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 15:52:52 PST 2017


pzheng added a comment.

Here is the patch I use to enable building AOSP with a non-AOSP-version Clang.

diff --git a/build/core/binary.mk b/build/core/binary.mk
index 4db3d51..0246ea5 100644

- a/build/core/binary.mk

+++ b/build/core/binary.mk
@@ -371,6 +371,13 @@ ifeq ($(my_clang),false)

  endif

endif

+my_target_clang := $(strip $(LOCAL_TARGET_CLANG))
+ifneq ($(strip $(TARGET_CLANG)),)
+    ifeq ($(my_target_clang),)
+        my_target_clang := true
+    endif
+endif
+

1. clang is enabled by default for host builds
2. enable it unless we've specifically disabled clang above ifdef LOCAL_IS_HOST_MODULE

@@ -528,6 +535,22 @@ my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBA
 my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
 my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
 my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
+    ifeq ($(my_target_clang),true)
+        ifeq ($(strip $(my_cc)),)
+            ifeq ($(strip $(TIMEOUT)),)
+                my_cc := $(TARGET_CLANG)/clang
+            else
+                my_cc := ulimit -t $(TIMEOUT); $(TARGET_CLANG)/clang
+            endif
+        endif
+        ifeq ($(strip $(my_cxx)),)
+            ifeq ($(strip $(TIMEOUT)),)
+                my_cxx := $(TARGET_CLANG)/clang++
+            else
+                my_cxx := ulimit -t $(TIMEOUT); $(TARGET_CLANG)/clang++
+            endif
+        endif
+    endif
else
 my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS)
 my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
diff --git a/build/core/clear_vars.mk b/build/core/clear_vars.mk
index 6e61d15..8cccb52 100644

- a/build/core/clear_vars.mk

+++ b/build/core/clear_vars.mk
@@ -23,6 +23,7 @@ LOCAL_CFLAGS:=
 LOCAL_CHECKED_MODULE:=
 LOCAL_C_INCLUDES:=
 LOCAL_CLANG:=
+LOCAL_TARGET_CLANG:=
 LOCAL_CLANG_ASFLAGS:=
 LOCAL_CLANG_CFLAGS:=
 LOCAL_CLANG_CONLYFLAGS:=
diff --git a/build/core/definitions.mk b/build/core/definitions.mk
index dd53e7e..9ede127 100644

- a/build/core/definitions.mk

+++ b/build/core/definitions.mk
@@ -1220,7 +1220,6 @@ endef

  1.
1. Commands for running gcc to compile a C++ file ########################################################### - define transform-cpp-to-o-compiler-args 	$(c-includes) \ 	-c \

@@ -1234,7 +1233,8 @@ define transform-cpp-to-o-compiler-args

  	$(PRIVATE_CPPFLAGS) \
  	$(PRIVATE_DEBUG_CFLAGS) \
  	$(PRIVATE_CFLAGS_NO_OVERRIDE) \

- $(PRIVATE_CPPFLAGS_NO_OVERRIDE)

+	$(PRIVATE_CPPFLAGS_NO_OVERRIDE) \
+	$(if $(findstring clang,$(PRIVATE_CXX)),$(TARGET_FLAGS))
endef

define clang-tidy-cpp
@@ -1282,7 +1282,8 @@ $(call transform-c-or-s-to-o-compiler-args, \

  $(PRIVATE_CFLAGS) \
  $(PRIVATE_CONLYFLAGS) \
  $(PRIVATE_DEBUG_CFLAGS) \

- $(PRIVATE_CFLAGS_NO_OVERRIDE))

+  $(PRIVATE_CFLAGS_NO_OVERRIDE)) \
+  $(if $(findstring clang,$(PRIVATE_CC)),$(TARGET_FLAGS))
endef

define clang-tidy-c


https://reviews.llvm.org/D29050





More information about the llvm-commits mailing list