x86: fix full_x86-eng build
The latest merge conflict resolution worked only for ARM, but not for x86
Both ARM and x86 builds have been tested with this fix.
Change-Id: I4ec1f1b0ea32fa86e7e2515b221133473d6550a3
NOTE: Care has been taken to not change the compiler flags for ARM builds.
In particular, when building crtbegin_so.so, the -fPIC flag is only
used for x86 (previous reports indicate that it breaks the ARM
build at runtime for obscure reasons).
diff --git a/libc/Android.mk b/libc/Android.mk
index dc5c143..ef0ee47 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -555,18 +555,24 @@
# that will call __cxa_finalize(&__dso_handle) in order to ensure that
# static C++ destructors are properly called on dlclose().
#
+
+libc_crt_target_so_cflags := $(libc_crt_target_cflags)
+ifeq ($(TARGET_ARCH),x86)
+ # This flag must be added for x86 targets, but not for ARM
+ libc_crt_target_so_cflags += -fPIC
+endif
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
@mkdir -p $(dir $@)
- $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
+ $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
ALL_GENERATED_SOURCES += $(GEN)
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
@mkdir -p $(dir $@)
- $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
+ $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
ALL_GENERATED_SOURCES += $(GEN)
-endif # TARGET_ARCH == x86
+endif # TARGET_ARCH == x86 || TARGET_ARCH == arm
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o