It seems that KindlePDFViewer is one of those that don't honour CPPFLAGS - There's no mention of CPPFLAGS in Makefile, so I added -D_GNU_SOURCE to CFLAGs:
Code:
-CFLAGS:=-O3 $(SYSROOT)
+CFLAGS:=-O3 -D_GNU_SOURCE $(SYSROOT)
That seemed to help only partially - before, I had:
Code:
117: 0000b134 0 FUNC GLOBAL DEFAULT UND __isoc99_sscanf@GLIBC_2.7 (10)
224: 0000b5d8 0 FUNC GLOBAL DEFAULT UND __isoc99_fscanf@GLIBC_2.7 (10)
and now I have:
Code:
223: 0000b5a4 0 FUNC GLOBAL DEFAULT UND __isoc99_fscanf@GLIBC_2.7 (11)
I also tried -std=gnu90 instead of -D_GNU_SOURCE, but it didn't help at all:
Code:
117: 0000b134 0 FUNC GLOBAL DEFAULT UND __isoc99_sscanf@GLIBC_2.7 (10)
224: 0000b5d8 0 FUNC GLOBAL DEFAULT UND __isoc99_fscanf@GLIBC_2.7 (10)
-std=gnu99 was the same.
grep -r "isoc99" returns nothing, while grep -r "sscanf" . and grep -r "fscanf" . return quite a bit (which I believe was to be expected).
On another note, I tried adding -fno-use-cxa-atexit to CXXFLAGS in Makefile, but it seemed it had no effect:
Code:
Version needs section '.gnu.version_r' contains 6 entries:
Addr: 0x000000000000a334 Offset: 0x002334 Link: 5 (.dynstr)
000000: Version: 1 File: libgcc_s.so.1 Cnt: 2
0x0010: Name: GCC_3.0 Flags: none Version: 11
0x0020: Name: GCC_3.5 Flags: none Version: 8
0x0030: Version: 1 File: libdl.so.2 Cnt: 1
0x0040: Name: GLIBC_2.4 Flags: none Version: 7
0x0050: Version: 1 File: libstdc++.so.6 Cnt: 3
0x0060: Name: CXXABI_1.3 Flags: none Version: 9
0x0070: Name: CXXABI_ARM_1.3.3 Flags: none Version: 6
0x0080: Name: GLIBCXX_3.4 Flags: none Version: 5
0x0090: Version: 1 File: libc.so.6 Cnt: 2
0x00a0: Name: GLIBC_2.7 Flags: none Version: 10
0x00b0: Name: GLIBC_2.4 Flags: none Version: 4
0x00c0: Version: 1 File: libpthread.so.0 Cnt: 1
0x00d0: Name: GLIBC_2.4 Flags: none Version: 3
0x00e0: Version: 1 File: libm.so.6 Cnt: 1
0x00f0: Name: GLIBC_2.4 Flags: none Version: 2
16: 0000ac84 0 FUNC GLOBAL DEFAULT UND __aeabi_atexit@CXXABI_ARM_1.3.3 (6)
grep -r "atexit" . returns:
Code:
./mupdf/fitz/memento.c://int atexit(void (*)(void));
./mupdf/fitz/memento.c: atexit(Memento_fin);
./mupdf/fitz/memento.c: * just exit to avoid the JIT (and get the usual atexit handling). */
./mupdf/thirdparty/jbig2dec/memento.c:int atexit(void (*)(void));
./mupdf/thirdparty/jbig2dec/memento.c: atexit(Memento_fin);
./mupdf/thirdparty/jbig2dec/memento.c: * just exit to avoid the JIT (and get the usual atexit handling). */
I once again tried compiling it with your Makefile (keeping only HOST:=arm-none-linux-gnueabi unchanged. As far as I can see, all env settings that you use in x-compile.sh are also stated explicitly in the Makefile, so it should work without me fiddling with my env. Or so I thought. I got this:
Code:
Version needs section '.gnu.version_r' contains 6 entries:
Addr: 0x000000000000a8fc Offset: 0x0028fc Link: 5 (.dynstr)
000000: Version: 1 File: libgcc_s.so.1 Cnt: 2
0x0010: Name: GCC_3.0 Flags: none Version: 12
0x0020: Name: GCC_3.5 Flags: none Version: 9
0x0030: Version: 1 File: libdl.so.2 Cnt: 1
0x0040: Name: GLIBC_2.4 Flags: none Version: 8
0x0050: Version: 1 File: libstdc++.so.6 Cnt: 3
0x0060: Name: CXXABI_1.3 Flags: none Version: 10
0x0070: Name: CXXABI_ARM_1.3.3 Flags: none Version: 7
0x0080: Name: GLIBCXX_3.4 Flags: none Version: 5
0x0090: Version: 1 File: libc.so.6 Cnt: 2
0x00a0: Name: GLIBC_2.7 Flags: none Version: 11
0x00b0: Name: GLIBC_2.4 Flags: none Version: 4
0x00c0: Version: 1 File: libpthread.so.0 Cnt: 1
0x00d0: Name: GLIBC_2.4 Flags: none Version: 3
0x00e0: Version: 1 File: libm.so.6 Cnt: 2
0x00f0: Name: GLIBC_2.15 Flags: none Version: 6
0x0100: Name: GLIBC_2.4 Flags: none Version: 2
But, just to be sure, I did this:
Code:
export ARCH_FLAGS="-march=armv6j -mtune=arm1136jf-s -mfpu=vfp"
export NOLTO_CFLAGS="-O2 -ffast-math ${ARCH_FLAGS} -pipe -fomit-frame-pointer -fno-stack-protector -U_FORTIFY_SOURCE"
export BASE_CFLAGS="${NOLTO_CFLAGS}"
export CFLAGS="${BASE_CFLAGS}"
export CXXFLAGS="${BASE_CFLAGS}"
export BASE_LDFLAGS="-Wl,-O1 -Wl,--as-needed"
export LDFLAGS="${BASE_LDFLAGS}"
and then got this!
Code:
Version needs section '.gnu.version_r' contains 6 entries:
Addr: 0x000000000000a8ec Offset: 0x0028ec Link: 5 (.dynstr)
000000: Version: 1 File: libgcc_s.so.1 Cnt: 2
0x0010: Name: GCC_3.0 Flags: none Version: 11
0x0020: Name: GCC_3.5 Flags: none Version: 8
0x0030: Version: 1 File: libdl.so.2 Cnt: 1
0x0040: Name: GLIBC_2.4 Flags: none Version: 7
0x0050: Version: 1 File: libstdc++.so.6 Cnt: 2
0x0060: Name: CXXABI_1.3 Flags: none Version: 9
0x0070: Name: GLIBCXX_3.4 Flags: none Version: 5
0x0080: Version: 1 File: libc.so.6 Cnt: 2
0x0090: Name: GLIBC_2.7 Flags: none Version: 10
0x00a0: Name: GLIBC_2.4 Flags: none Version: 4
0x00b0: Version: 1 File: libpthread.so.0 Cnt: 1
0x00c0: Name: GLIBC_2.4 Flags: none Version: 3
0x00d0: Version: 1 File: libm.so.6 Cnt: 2
0x00e0: Name: GLIBC_2.15 Flags: none Version: 6
0x00f0: Name: GLIBC_2.4 Flags: none Version: 2
Further experiments revealed that to get rid of CXXABI_ARM_1.3.3, you need to have both -fno-use-cxa-atexit added to CXXFLAGS in Makefile AND env CXXFLAGS defined. Even export CXXFLAGS= will work. I added -D_GNU_SOURCE to CFLAGS in Makefile, and that got rid of GLIBC_2.7. I don't know what caused that GLIBC_2.15. It didn't come up with my Makefiles.
Combining the two approaches, I reverted to default Makefile and changed it like this:
Code:
-CFLAGS:=-O3 $(SYSROOT)
-CXXFLAGS:=-O3 $(SYSROOT)
+CFLAGS:=-O3 -D_GNU_SOURCE $(SYSROOT)
+CXXFLAGS:=-O3 -fno-use-cxa-atexit $(SYSROOT)
with env CXXFLAGS set to "-O3 -D_GNU_SOURCE", and CPPFLAGS, CFLAGS not defined, I got this:
Code:
Version needs section '.gnu.version_r' contains 6 entries:
Addr: 0x000000000000a304 Offset: 0x002304 Link: 5 (.dynstr)
000000: Version: 1 File: libgcc_s.so.1 Cnt: 2
0x0010: Name: GCC_3.0 Flags: none Version: 9
0x0020: Name: GCC_3.5 Flags: none Version: 7
0x0030: Version: 1 File: libdl.so.2 Cnt: 1
0x0040: Name: GLIBC_2.4 Flags: none Version: 6
0x0050: Version: 1 File: libstdc++.so.6 Cnt: 2
0x0060: Name: CXXABI_1.3 Flags: none Version: 8
0x0070: Name: GLIBCXX_3.4 Flags: none Version: 5
0x0080: Version: 1 File: libc.so.6 Cnt: 2
0x0090: Name: GLIBC_2.7 Flags: none Version: 10
0x00a0: Name: GLIBC_2.4 Flags: none Version: 4
0x00b0: Version: 1 File: libpthread.so.0 Cnt: 1
0x00c0: Name: GLIBC_2.4 Flags: none Version: 3
0x00d0: Version: 1 File: libm.so.6 Cnt: 1
0x00e0: Name: GLIBC_2.4 Flags: none Version: 2
223: 0000b584 0 FUNC GLOBAL DEFAULT UND __isoc99_fscanf@GLIBC_2.7 (10)
As you can see, we still have a problem with that GLIBC_2.7. I thought maybe similar approach to above would work, so I typed export CFLAGS=. This gave:
Code:
kai771@Ubuntu-12:~/kindlepdfviewer$ make thirdparty
make -C mupdf CC="gcc" build/debug/cmapdump
make[1]: Entering directory `/home/kai771/kindlepdfviewer/mupdf'
MKDIR build/debug
CC build/debug/cmapdump.o
scripts/cmapdump.c:1:0: error: bad value (armv6) for -march= switch
make[1]: *** [build/debug/cmapdump.o] Error 1
make[1]: Leaving directory `/home/kai771/kindlepdfviewer/mupdf'
make: *** [mupdf/cmapdump.host] Error 2
It took me quite some time (and reading man make
) to realise why this happened. Having env variable defined, causes make to export it to sub-makes. And it exported wrong value (the one with -march flag).
It also explains why defining env CXXFLAGS worked above.
Realizing this, I concluded that default Makefile was broken - it didn't pass CFLAGS and CXXFLAGS properly.
I made following changes to Makefile:
Code:
-CFLAGS:=-O3 $(SYSROOT)
-CXXFLAGS:=-O3 $(SYSROOT)
+CFLAGS:=-O3 -D_GNU_SOURCE $(SYSROOT)
+CXXFLAGS:=-O3 -fno-use-cxa-atexit $(SYSROOT)
# use this for debugging:
#CFLAGS:=-O0 -g
+BASE_CFLAGS:= $(CFLAGS)
$(MUPDFDIR)/fontdump.host:
- make -C mupdf CC="$(HOSTCC)" $(MUPDFTARGET)/fontdump
+ CFLAGS="$(BASE_CFLAGS)" make -C mupdf CC="$(HOSTCC)" $(MUPDFTARGET)/fontdump
cp -a $(MUPDFLIBDIR)/fontdump $(MUPDFDIR)/fontdump.host
make -C mupdf clean
$(MUPDFDIR)/cmapdump.host:
- make -C mupdf CC="$(HOSTCC)" $(MUPDFTARGET)/cmapdump
+ CFLAGS="$(BASE_CFLAGS)" make -C mupdf CC="$(HOSTCC)" $(MUPDFTARGET)/cmapdump
cp -a $(MUPDFLIBDIR)/cmapdump $(MUPDFDIR)/cmapdump.host
make -C mupdf clean
else
- cd $(DJVUDIR)/build && ../configure --disable-desktopfiles --disable-shared --enable-static --host=$(HOST) --disable-xmltools --disable-desktopfiles
+ cd $(DJVUDIR)/build && CXXFLAGS="$(CXXFLAGS)" ../configure --disable-desktopfiles --disable-shared --enable-static --host=$(HOST) --disable-xmltools --disable-desktopfiles
endif
make -C $(DJVUDIR)/build
$(CRENGINELIBS):
cd $(KPVCRLIGDIR) && rm -rf CMakeCache.txt CMakeFiles && \
- CFLAGS="$(CFLAGS)" CC="$(CC)" CXX="$(CXX)" cmake . && \
+ CFLAGS="$(CFLAGS)" CC="$(CC)" CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" cmake . && \
make
else
- make -C $(LUADIR) CC="$(HOSTCC)" HOST_CC="$(HOSTCC) -m32" CROSS="$(HOST)-" TARGET_FLAGS="$(SYSROOT) -DLUAJIT_NO_LOG2 -DLUAJIT_NO_EXP2"
+ CFLAGS="$(BASE_CFLAGS)" make -C $(LUADIR) CC="$(HOSTCC)" HOST_CC="$(HOSTCC) -m32" CROSS="$(HOST)-" TARGET_FLAGS="$(SYSROOT) -DLUAJIT_NO_LOG2 -DLUAJIT_NO_EXP2"
endif
and now everything works properly. So, you were right from the beginning - it just took some time to sink in
!. Only two flags are necessary: -D_GNU_SOURCE in CFLAGS and -fno-use-cxa-atexit to CXXFLAGS. I tested this Makefile with 2007q3 also, both arm and emu - it doesn't impede the building process at all, so I suggest making them default. The rest of your flags don't seem necessary, but as you said it, they might come up in some rare cases. I'm attaching a fixed Makefile.
Thanks a lot for all of your help. I really learned a lot.