From 3ee408c5e671d3c58fd2e9b99fb49c137bfe8d62 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 4 Jul 2014 03:45:42 +0200 Subject: [PATCH 1/6] Fix mupdf build. HOSTCC means we need HOSTCFLAGS or bad things happen when you feed arm arches to an x86 GCC ;). --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 21d14982f..db35d8a5c 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,7 @@ $(PNG_LIB): $(CRENGINE_LIB) # we generate a dynamic library from the static library: $(MUPDF_LIB): $(JPEG_LIB) $(FREETYPE_LIB) $(MAKE) -j$(PROCESSORS) -C mupdf generate build="release" CC="$(HOSTCC)" \ + CFLAGS="$(HOSTCFLAGS)" \ OS="Other" verbose=1 $(MAKE) -j$(PROCESSORS) -C mupdf \ LDFLAGS="-L../$(OUTPUT_DIR)" \ From 2c09dd519cd5b0907f8611996e1bb80dbcbe6b8d Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 4 Jul 2014 03:47:53 +0200 Subject: [PATCH 2/6] Introduce per-target CFLAGS. This rids us of the legacy Kindle compat crap we don't need on the K5. There's still a few things to check though: * I'm using a 'perfect' K5 TC, so that works, but depending on the TC used for Kindle builds on the buildbot, we may need to reintroduce some compat flags. * I'm mostly sure every Kobo we care about runs on an A8, but if a valid target kobo device doesn't, fix this. * I have no idea what we want to do for Android, so go with generic armv6, and hope the TC defaults to sane stuff. (This also introduces a couple of extra targets, some of them mostly for my own use, so I don't have to monkey patch each time, and some to get rid of legacy stuff on Kindles). --- Makefile.defs | 56 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/Makefile.defs b/Makefile.defs index 20ab59a4b..0cfa97fc1 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -22,6 +22,12 @@ endif # set CC CXX AR LD RANLIB ifeq ($(TARGET), kindle) CHOST?=arm-linux-gnueabi +else ifeq ($(TARGET), kindle5) + CHOST?=arm-kindle5-linux-gnueabi +else ifeq ($(TARGET), kindlepw2) + CHOST?=arm-kindlepw2-linux-gnueabi +else ifeq ($(TARGET), kindle-legacy) + CHOST?=arm-kindle-linux-gnueabi else ifeq ($(TARGET), kobo) CHOST?=arm-linux-gnueabihf else ifeq ($(TARGET), android) @@ -58,6 +64,9 @@ PROCESSORS:=$(shell grep processor /proc/cpuinfo|wc -l) BASE_CFLAGS:=-O2 -ffast-math -pipe -fomit-frame-pointer # Use this for debugging: #BASE_CFLAGS:=-O0 -g +# For ricers. +#BASE_CFLAGS:=-O3 -ffast-math -pipe -fomit-frame-pointer -frename-registers -fweb + # Misc GCC tricks to ensure backward compatibility with the K2, # even when using a fairly recent TC (Linaro/MG). # NOTE: -mno-unaligned-access is needed for TC based on Linaro 4.6/4.7 @@ -67,14 +76,44 @@ BASE_CFLAGS:=-O2 -ffast-math -pipe -fomit-frame-pointer # fixup (echo 2 > /proc/cpu/alignment) in the launch script, # but that's terribly ugly, and might severly nerf performance... # That said, MG 2012.03 is still using GCC 4.6.3, so we're good ;). -ARM_BACKWARD_COMPAT_CFLAGS:=-fno-stack-protector -U_FORTIFY_SOURCE -D_GNU_SOURCE -fno-finite-math-only -ARM_BACKWARD_COMPAT_CXXFLAGS:=-fno-use-cxa-atexit -ARM_ARCH:=-march=armv6j -mtune=arm1136jf-s -mfpu=vfp -marm - +KINDLE_LEGACY_COMPAT_CFLAGS:=-fno-stack-protector -U_FORTIFY_SOURCE -D_GNU_SOURCE -fno-finite-math-only +KINDLE_LEGACY_COMPAT_CXXFLAGS:=-fno-use-cxa-atexit +ARMV6_1136_ARCH:=-march=armv6j -mtune=arm1136jf-s -mfpu=vfp -marm + +# Generic armv6 +ARMV6_GENERIC_ARCH:=march=armv6 -mtune=generic-armv6 +# Cortex A8 (Kindle Touch, PW1, Most Kobos) +ARMV7_A8_ARCH:=-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mthumb +# Cortex A9 (Kindle PW2) +ARMV7_A9_ARCH:=-march=armv7-a -mtune=cortex-a9 -mfpu=neon -mthumb +# Android. FIXME: What do we want here? armv6? armv7? ARM? THUMB? Which FPU? +ANDROID_ARCH:=-march=armv6 -mtune=generic-armv6 + +# Use target-specific CFLAGS ifeq ($(TARGET), kobo) - ARM_ARCH += -mfloat-abi=hard + ARM_ARCH:=$(ARMV7_A8_ARCH) + ARM_ARCH+=-mfloat-abi=hard +else ifeq ($(TARGET), kindle) + # FIXME: Will possibly need compat flags, depending on how far away from an actual Kindle the TC used by the buildbot is... + ARM_ARCH:=$(ARMV7_A8_ARCH) + ARM_ARCH+=-mfloat-abi=softfp +else ifeq ($(TARGET), kindle5) + ARM_ARCH:=$(ARMV7_A8_ARCH) + ARM_ARCH+=-mfloat-abi=softfp +else ifeq ($(TARGET), kindlepw2) + ARM_ARCH:=$(ARMV7_A9_ARCH) + ARM_ARCH+=-mfloat-abi=softfp +else ifeq ($(TARGET), kindle-legacy) + ARM_ARCH:=$(KINDLE_LEGACY_COMPAT_CFLAGS) $(KINDLE_LEGACY_COMPAT_CXXFLAGS) $(ARMV6_1136_ARCH) + ARM_ARCH+=-mfloat-abi=softfp +else ifeq ($(TARGET), android) + ARM_ARCH:=$(ANDROID_ARCH) + # FIXME: is this accurate on Android? + ARM_ARCH+=-mfloat-abi=softfp else - ARM_ARCH += -mfloat-abi=softfp + # Defaults to generic crap + ARM_ARCH:=$(ARMV6_GENERIC_ARCH) + ARM_ARCH+=-mfloat-abi=softfp endif HOST_ARCH:=-march=native @@ -117,9 +156,8 @@ else CC:=$(strip $(CCACHE) $(CC)) CXX:=$(strip $(CCACHE) $(CXX)) AR:=$(strip $(CCACHE) $(AR)) - CFLAGS+= $(ARM_ARCH) $(ARM_BACKWARD_COMPAT_CFLAGS) - CXXFLAGS+= $(ARM_ARCH) $(ARM_BACKWARD_COMPAT_CFLAGS) \ - $(ARM_BACKWARD_COMPAT_CXXFLAGS) + CFLAGS+= $(ARM_ARCH) + CXXFLAGS+= $(ARM_ARCH) endif # set a flag that C code can differenciate on for Kobo code From a2798439d8c6b1119bfbacfd0ac4ff71d95c1a9f Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 4 Jul 2014 03:59:21 +0200 Subject: [PATCH 3/6] Forgot to comment that. --- Makefile.defs | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.defs b/Makefile.defs index 0cfa97fc1..de32e82a3 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -91,6 +91,7 @@ ANDROID_ARCH:=-march=armv6 -mtune=generic-armv6 # Use target-specific CFLAGS ifeq ($(TARGET), kobo) + # FIXME: I *think* all the Kobos we care about at least run on an A8... ARM_ARCH:=$(ARMV7_A8_ARCH) ARM_ARCH+=-mfloat-abi=hard else ifeq ($(TARGET), kindle) From ec0e54d200e935e1f4012aa81eba2c7bfc4bf4e5 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 4 Jul 2014 16:58:09 +0200 Subject: [PATCH 4/6] Kill one FIXME. Confirmed that the earliest Kobo Touch device was running on an A8. Note that if we ever care about the first non-touch one, that won't do. --- Makefile.defs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.defs b/Makefile.defs index de32e82a3..87cedba36 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -82,7 +82,7 @@ ARMV6_1136_ARCH:=-march=armv6j -mtune=arm1136jf-s -mfpu=vfp -marm # Generic armv6 ARMV6_GENERIC_ARCH:=march=armv6 -mtune=generic-armv6 -# Cortex A8 (Kindle Touch, PW1, Most Kobos) +# Cortex A8 (Kindle Touch, PW1, Kobos since the Touch) ARMV7_A8_ARCH:=-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mthumb # Cortex A9 (Kindle PW2) ARMV7_A9_ARCH:=-march=armv7-a -mtune=cortex-a9 -mfpu=neon -mthumb @@ -91,7 +91,7 @@ ANDROID_ARCH:=-march=armv6 -mtune=generic-armv6 # Use target-specific CFLAGS ifeq ($(TARGET), kobo) - # FIXME: I *think* all the Kobos we care about at least run on an A8... + # NOTE: If we only care about Kobos w/ a Touch screen, we're good. ARM_ARCH:=$(ARMV7_A8_ARCH) ARM_ARCH+=-mfloat-abi=hard else ifeq ($(TARGET), kindle) From 5bc5d41f297089623728903d2c403c4f98087171 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 4 Jul 2014 17:02:51 +0200 Subject: [PATCH 5/6] Possibly properly fix mupdf build --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index db35d8a5c..9afdff519 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ $(PNG_LIB): $(CRENGINE_LIB) # we generate a dynamic library from the static library: $(MUPDF_LIB): $(JPEG_LIB) $(FREETYPE_LIB) $(MAKE) -j$(PROCESSORS) -C mupdf generate build="release" CC="$(HOSTCC)" \ - CFLAGS="$(HOSTCFLAGS)" \ + XCFLAGS="$(HOSTCFLAGS)" \ OS="Other" verbose=1 $(MAKE) -j$(PROCESSORS) -C mupdf \ LDFLAGS="-L../$(OUTPUT_DIR)" \ From 247f0f8d33a61fc828c811332759e709cd70de9e Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 4 Jul 2014 17:19:53 +0200 Subject: [PATCH 6/6] Really fix mupdf build. The buildsystem always picks up what's in the env, so if the CFLAGS in our env has march flags for the wrong arch => kablooey. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9afdff519..121db7424 100644 --- a/Makefile +++ b/Makefile @@ -91,8 +91,8 @@ $(PNG_LIB): $(CRENGINE_LIB) # by default, mupdf compiles to a static library: # we generate a dynamic library from the static library: $(MUPDF_LIB): $(JPEG_LIB) $(FREETYPE_LIB) - $(MAKE) -j$(PROCESSORS) -C mupdf generate build="release" CC="$(HOSTCC)" \ - XCFLAGS="$(HOSTCFLAGS)" \ + env CFLAGS="$(HOSTCFLAGS)" \ + $(MAKE) -j$(PROCESSORS) -C mupdf generate build="release" CC="$(HOSTCC)" \ OS="Other" verbose=1 $(MAKE) -j$(PROCESSORS) -C mupdf \ LDFLAGS="-L../$(OUTPUT_DIR)" \