kill TF_POOLABLE, step 2: remove dead code
[LibreOffice.git] / README.cross
blob8241ea752a2a32f8e0a77e7aec14ff8c04a01932
1 Cross-compiling LibreOffice
2 ===========================
4 Notes on cross-compiling LibreOffice, originally written by Tor
5 Lillqvist <tlillqvist@novell.com> <tml@iki.fi> in May, 2011, for later
6 history see git log.
8 Cross-compilation of LibreOffice completely is not possible yet. Much
9 work has been done, "baby steps" for some platforms, much more for
10 others, but a lot remains. For iOS and Android this work is highly
11 experimental and done mostly in my own spare time just for the hacking
12 pleasure. No promise, explicit or implied, is given that it will ever
13 be finished.
15 Searching for information about cross-compilation of OpenOffice.org
16 (the predecessor of LibreOffice) you will find information about what
17 actually was not cross-compilation, but using QEMU.
19 My cross-compilation experimentation is going on for four platforms:
20 Windows, iOS, Android and PowerPC Mac OS X. I work on the master
21 branch of LibreOffice. Some other people have talked about setting up
22 a separate branch for Android work, or even separate clones at
23 github. I am not interested in that.
26 General
27 -------
29 In GNU Autoconf terminology, "build" is the platform on which you are
30 running a build on some software and "host" is the platform on which
31 the software you are building will run. Only in the specific case of
32 building compilers and other programming tools is the term "target"
33 used to indicate the platform for which the tools your are building
34 will produce code. As LibreOffice is not a compiler, the "target" term
35 should not be used in the context of cross-compilation.
37 (For a case where all three of "build", "host" and "target" are
38 different: consider a gcc cross-compiler running on Windows, producing
39 code for Android, where the cross-compiler itself was built on
40 Linux. (This is a real case.) An interesting tidbit is that such
41 configurations are called "Canadian Cross".)
43 Even though the LibreOffice build mechanism is highly unorthodox, the
44 configure script takes the normal --build and --host options like any
45 GNU Autoconf -based configure script. To cross-compile, you basically
46 need just to specify a suitable --host option and things should work
47 out nicely. In practise, some more details might be needed. See
48 examples below.
51 What is so hard, then?
52 ----------------------
54 Despite the fact that the configure script takes normal --build and
55 --host options, that is just the beginning. In practise a lot of work
56 was necessary to separate tests for "host" and "build" platforms in
57 the configure script. See the git log for details. And the reasonably
58 "standard" configure.in is just the top level; when we get down to the
59 actual makefilery used to build the bits of LibreOffice, it gets much
60 worse.
63 Windows
64 -------
66 There is some support in LibreOffice already (from OpenOffice.org) for
67 building it locally on Windows but with the GNU tool-chain, i.e. what
68 is commonly known as MinGW. But as far as I know, that work has never
69 attempted cross-compilation.
71 This OOo-originated MinGW support attempts to support both running
72 Cygwin gcc in its -mno-cygwin mode, and a native MinGW compiler.  The
73 -mno-cygwin mechanism in the Cygwin gcc is rapidly being obsoleted, if
74 it isn't already, and I have not attempted to try to keep it working;
75 in fact I have activly cleaned out mechanisms related to this. Ditto
76 for native MinGW. If one compiles natively on Windows, just use
77 Microsoft's compiler. OOo/LO has been built for Windows all the time
78 using that.
80 In my opinion, the only case where it makes sense to use MinGW is for
81 cross-compilation. There is just too much crack on Windows anyway, and
82 it is a semi-miracle (well, make that the result of years of work)
83 that the MSVC build under Cygwin works as nicely as it does.
85 MinGW is available as cross-build toolchains pre-packaged in more or
86 less official packages for many Linux distros including Debian, Fedora
87 and openSUSE. Personally I use the mingw32 packages in the openSUSE
88 Build Service, running on openSUSE:
90 http://download.opensuse.org/repositories/windows:/mingw:/win32/
92 [You can install it like:
94 zypper ar http://download.opensuse.org/repositories/windows:/mingw:/win32/SLE_11_SP1/windows:mingw:win32.repo
95 zypper in mingw32-cross-gcc mingw32-cross-gcc-c++ mingw32-python-devel \
96     mingw32-libexpat-devel mingw32-libexpat mingw32-boost-devel \
97     mingw32-libhyphen-devel mingw32-libhyphen mingw32-hyphen-en \
98     mingw32-liblpsolve mingw32-liblpsolve-devel \
99     mingw32-libxml2-devel mingw32-libxslt-devel mingw32-libicu \
100     mingw32-libicu-devel mingw32-libgraphite2 mingw32-libgraphite2-devel \
101     mingw32-cairo mingw32-cairo-devel mingw32-librsvg mingw32-librsvg-devel \
102     mingw32-hunspell mingw32-hunspell-devel mingw32-libcurl \
103     mingw32-libcurl-devel mingw32-libneon mingw32-libneon-devel \
104     mingw32-libopenssl mingw32-libopenssl-devel mingw32-libtextcat \
105     mingw32-libtextcat-devel mingw32-libdb mingw32-libdb-devel \
106     mingw32-cross-pkg-config mingw32-pkg-config mingw32-libcppunit \
107     mingw32-libcppunit-devel mingw32-libredland mingw32-libredland-devel \
108     mingw32-libmythes mingw32-libmythes-devel
110 There might be more that are missing, please read carefully what autogen.sh
111 tells you, and either remove one of the --with-system-*, or install the
112 missing dependency.
114 It also looks like graphite2.pc needs tweaking in order to work right; but
115 that's likely to be fixed in the openSUSE project.]
117 It is somewhat unclear how well thought-out the conditionals and code
118 for MinGW inside the OOo-originated code in LibreOffice actually
119 is. The little I have seen of it seems a bit randomish, with
120 copy-pasting having been preferred to factoring out differences.
122 The autogen.lastrun I use for my MinGW cross-compilation experimentation is:
124 CC=ccache i686-w64-mingw32-gcc
125 CXX=ccache i686-w64-mingw32-g++
126 CC_FOR_BUILD=ccache gcc
127 CXX_FOR_BUILD=ccache g++
128 --build=x86_64-unknown-linux-gnu
129 --host=i686-w64-mingw32
130 --with-distro=LibreOfficeWin32
131 --disable-activex
132 --disable-binfilter
133 --disable-build-mozilla
134 --disable-directx
135 --disable-ext-nlpsolver
136 --disable-ext-pdfimport
137 --disable-ext-presenter-console
138 --disable-ext-presenter-minimizer
139 --disable-ext-report-builder
140 --disable-ext-scripting-beanshell
141 --disable-ext-scripting-javascript
142 --disable-ext-wiki-publisher
143 --disable-ext-wiki-publisher
144 --disable-mozilla
145 --disable-zenity
146 --enable-python=system
147 --with-external-tar=/mnt/hemulen/ooo/git/master/src
148 --with-num-cpus=1
149 --with-max-jobs=1
150 --with-system-altlinuxhyph
151 --with-system-boost
152 --with-system-cairo
153 --with-system-cppunit
154 --with-system-curl
155 --with-system-db
156 --with-system-expat
157 --with-system-gettext
158 --with-system-hunspell
159 --with-system-icu
160 --with-system-libpng
161 --with-system-libwpd
162 --with-system-libwpg
163 --with-system-libwps
164 --with-system-libxml
165 --with-system-libxslt
166 --with-system-lpsolve
167 --with-system-mythes
168 --with-system-neon
169 --with-system-openssl
170 --with-system-redland
171 --with-vendor=no
172 --without-help
173 --without-helppack-integration
174 --without-myspell-dicts
176 TODO:
178 - installation
179   - so far the make_installer.pl calls makecab.exe, uuidgen.exe, and
180     others; would be best to avoid that if at all possible (using a free
181     cab implementation, part of Wine or something)
182   - MSI generation
183   - if at all possible, the make dev-install installation (with links
184     back to the build) should be done so that it would be directly
185     executable via wine after doing make dev-install :-)
187 - runtime
188   - no idea if the entire thing works after the installation at all; I
189     suppose there will be runtime problems to look at too
191 - cleanup
192   - enable & fix pieces that are currently disabled
193     - --without-myspell-dicts
194     - --disable-directx
195     - --disable-activex
196     - --disable-mozilla
197   - much of the stuff currently relies on --with-system-*, and
198     consequently on the mingw32-* openSUSE packages; might be good to be
199     able to build with as few dependencies as possible - but that is low
200     prio I think
202 - profiling
203   - when all the above is sorted out, we should look at the speed of
204     this vs. the speed of the MSVC version
210 iOS is the operating system of Apple's mobile devices. Clearly for a
211 device like the iPad it would be totally unacceptable to run a normal
212 LibreOffice application with a overlapping windows and mouse-oriented
213 GUI widgets. No work has been done (at least publicly) to design a
214 touch GUI for LibreOffice, so the work on cross-compiling LibreOffice
215 for iOS is extremely experimental, and of course partly pointless;)
216 But it is interesting and fun nonetheless.
218 Obviously it will make sense to build only a part of LibreOffice's
219 code for iOS. Most likely all GUI-oriented code should be left out,
220 and some iOS app that eventually wants to use the remaining bits will
221 handle all its GUI in a platform-dependent manner. How well it will be
222 possible to do such a split remains to be seen. As I said, this is
223 highly experimental and just in its baby steps phase.
225 Technically, one important special aspect of iOS is that apps are not
226 allowed to load own dynamic libraries. (System libraries are used in
227 the form of dynamic libraries, just like on MacOSX, of which iOS is a
228 variant.) So all the libraries in LibreOffice that normally are shared
229 libraries (DLLs on Windows, shared objects (.so) on Linux, dynamic
230 libraries on MacOSX (.dylib)) need to be built as static archives
231 instead. Obviously this will have some interesting consequences for
232 how UNO is implemented and used. None of that has been spared much
233 thought yet.
235 The Apple tool-chain for iOS cross-building is available only for
236 MacOSX, so that is where I have been doing it.
238 Here is my autogen.lastrun for iOS (device):
239 CXX=ccache /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk
240 CC=ccache /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk
241 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0
242 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0
243 --with-distro=LibreOfficeiOS
244 --with-external-tar=/Volumes/ooo/git/master/src
245 --with-num-cpus=1
246 --with-max-jobs=1
248 And here for the iOS simulator:
249 CXX=ccache /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk
250 CC=ccache /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk
251 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0
252 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0
253 --with-distro=LibreOfficeiOS
254 --with-external-tar=/Volumes/ooo/git/master/src
255 --with-num-cpus=1
256 --with-max-jobs=1
257 --disable-librsvg
258 --enable-debug
261 Android
262 -------
264 I don't know much about Android, but from a technical point of view it
265 is a kind of Linux, of course. As far as I know it is allowed for an
266 Android app to use shared objects, but if it isn't, then just the same
267 approach as used on iOS will need to be used.
269 As for the GUI, the same holds as said above for iOS.
271 I have done my Android cross-compilation work on Linux (openSUSE in
272 particular), but it could as well be done on MacOSX. The Android
273 cross-buld tool-chain (the "Native Development Kit", or NDK) is
274 available for Linux, MacOSX and Windows. (Trying to cross-compile from
275 Windows will probably drive you insane.)
277 Here is my autogen.lastrun for Android:
278 SYSBASE=/home/tml/android-ndk-r5c/platforms/android-9/arch-arm
279 CC=ccache /home/tml/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot /home/tml/android-ndk-r5c/platforms/android-9/arch-arm
280 CXX=ccache /home/tml/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ --sysroot /home/tml/android-ndk-r5c/platforms/android-9/arch-arm -I /home/tml/android-ndk-r5c/sources/cxx-stl/gnu-libstdc++/include -I/home/tml/android-ndk-r5c/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include -L/home/tml/android-ndk-r5c/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a -fexceptions -frtti
281 AR=/home/tml/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar
282 NM=/home/tml/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-nm
283 OBJDUMP=/home/tml/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-objdump
284 RANLIB=/home/tml/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ranlib
285 STRIP=/home/tml/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip
286 CC_FOR_BUILD=ccache gcc
287 CXX_FOR_BUILD=ccache g++
288 --build=x86_64-unknown-linux-gnu
289 --disable-zenity
290 --with-distro=LibreOfficeAndroid
291 --with-external-tar=/mnt/hemulen/ooo/git/master/src
292 --disable-python
293 --with-num-cpus=1
294 --with-max-jobs=1
297 PowerPC Mac OS X
298 ----------------
300 Cross-compiling for PowerPC Mac OS X from Intel Mac OS X will probably
301 be easy. The APIs available should after all be closely identical to
302 those on Intel Mac OS X, and LibreOffice builds fine natively on
303 PowerPC Mac already. I have just started experimenting with it. My
304 autogen.lastrun looks like this:
306 CC=ccache /Xcode3/usr/bin/gcc-4.0 -arch ppc
307 CXX=ccache /Xcode3/usr/bin/g++-4.0 -arch ppc
308 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0
309 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0
310 --build=i386-apple-darwin10.7.0
311 --host=powerpc-apple-darwin10
312 --disable-mozilla
313 --disable-build-mozilla
314 --with-external-tar=/Volumes/ooo/git/master/src
318 That's all, thank you, and have a nice day. People with commit access,
319 feel free to edit this document, and add yourself below. Sorry for
320 writing now initially from such a personal point of view.
322 --Tor Lillqvist <tlillqvist@novell.com>, <tml@iki.fi>