Proceedings of the Xfree86 Technical Conference
Total Page:16
File Type:pdf, Size:1020Kb
USENIX Association Proceedings of the XFree86 Technical Conference Oakland, California, USA November 8–9, 2001 THE ADVANCED COMPUTING SYSTEMS ASSOCIATION © 2001 by The USENIX Association All Rights Reserved For more information about the USENIX Association: Phone: 1 510 528 8649 FAX: 1 510 548 5738 Email: [email protected] WWW: http://www.usenix.org Rights to individual papers remain with the author or the author's employer. Permission is granted for noncommercial reproduction of the work for educational or research purposes. This copyright notice must be included in the reproduced paper. USENIX acknowledges all trademarks herein. A Cross Compile Environment for X Egbert Eich, XFree86 Core Team, SuSE GmbH Mergenthaleralle 45-47, D-65760 Eschborn, Germany, [email protected] Abstract Inc.3 The purpose of this port was to “stress test” both the compiler and the operating system with its Cross compiling the X Window System has been system libraries. However, at the time this port was a complicated task. imake macros that differed done, the new CPU was not yet available in hard- between target and build system had to be identi- ware. £ fied and redefined. It was not possible to use an The SimICS software emulator[MDHG 98] which existing configuration for the target platform. This emulates an entire system consisting of the CPU, document describes the design and implementation buses, IO and network interfaces, disks and graph- of a comfortable cross compile scheme for XFree86 ics hardware was available for testing purposes. which makes use of an existing target configuration. However, it was clear from the beginning that this emulator was not suitable for building the entire X source tree consisting of the X Window System 1 Introduction server as well as several applications. While a comfortable cross compile environment ex- 1 Advanced Micro Devices, Inc. (AMD) has de- isted to build the GNU compiler gcc the GNU bi- signed a new microprocessor architecture which ex- nary utilities, the Linux kernel and the GNU C Li- tends the instruction set of the ia32 processors to brary, the cross compile environment that existed 64-bit[AMD00] . This new architecture also known ¢¡ for the X Window System was largely unsuitable under the name x86-64 will provide the advan- for our purposes. tages of a 64-bit platform while maintaining full backwards compatibility for existing 32-bit ia32 ap- The XFree86 source code is configured using plications without the sacrifice of performance. imake[DuB93], a tool written during develop- 2 ment of X version 11. While not as automated as Early on, SuSE GmbH (a major Linux distributor) autoconf[VETT00], imake has the advantage of envisioned the new AMD architecture as an inter- providing significantly more control to the devel- esting target platform for the Linux operating sys- oper over the build process. tem. At this very early stage, SuSE began to port the Linux kernel, the system libraries as well as ma- The existing cross compilation mechanism requires jor applications to the x86-64 architecture. hand editing of the imake configuration of the build system to meet the needs of the target system. One of the first major applications to be ported to It is mainly suitable for compiling X for target sys- the new platform after the kernel and a primitive tems that will never host an X build themselves. At shell environment were operational was the X Win- the same time it was heavily dependent not only on dow System [SG92]. This port was to be based on the target system but also on the system that served the source tree maintained by the XFree86 Project, as the build platform. 1http://www.amd.com 2http://www.suse.de 3http://xfree86.org The design goals of the cross compile environment macros from the Imakefile. This Imakefile to be presented here were different: itself contains information about the targets to be built and macros for the rules for the corresponding 1. It had to be independent of the system the Makefile. build was going to take place on. When imake is built, preprocessor macros prede- 2. It had to be able to make use of an existing fined by the C compiler determine the values of imakemdep.h configuration of the target system “in place” macros defined in the header file . imake.c i.e. it should not require additional configura- This header file is itself included in –the imake tion files. source file. The macros defined in imakemdep.h control: (2) was of special importance as the cross com- pile environment for the x86-64 environment was ¤ which flags are needed to build the final ver- supposed to serve as a test base for the port of the sion of imake. X Window System and should provide roughly the ¤ which preprocessor imake should call to gen- same environment as if the build took place on the erate a Makefile. Depending on the plat- target system itself. form this may either be the C preprocessor This article is divided into 3 parts: First, the build itself or the C compiler invoked with the ap- environment of the X Window System and the cur- propriate flag run only the preprocessing stage rent cross compile environment will be reviewed. (usually -E). The next section will describe the internals of the ¤ whether output files generated by the system’s new cross compile environment. Finally, the re- preprocessor need to reprocessed. Certain sults we obtained by testing the x86-64 port with preprocessors may collapse tabs to a single the cross compile environment will be presented whitespace or replaces escaped newline char- acters with a single space. 2 The build environment of the X Window ¤ flags that should be passed to the preproces- System sor when a Makefile is generated. These flags may be macro definitions which uniquely 2.1 How the build environment obtains infor- characterize the target platform. This is espe- mations about the system cially important if imake is to use the C pre- processor instead of the preprocessing stage of The X Window System obtains its informations the C compiler to generate the Makefile, as about the underlying system almost exclusively the predefined compiler macros are not known from the predefined preprocessor macros of the sys- to the preprocessor. Switches which control tem’s C compiler. This information is gathered the operation of imake may also be specified when compiling the program imake which will here. It should be noted that imake may ex- later control the generation of the Makefiles. tend this list by arguments passed to it on the The creation of Makefiles itself is for the most command line or by values which need to be part done by the C preprocessor which selects rule obtained by imake at run time. and variable definitions from rule and definition files. Which rules and definitions are to be selected ¤ how the default name, version numbers of the is governed by a set of macros listed in an imake- operating system can be obtained from the generated file the preprocessor gets passed on invo- utsname structure or by some other system cation. dependent way. The preprocessor performs variable substitutions ¤ any system specific symbols the compiler in Makefile templates and expands build rule may define. These symbols are required for makedepend which will parse the source files DEFAULT_OS_NAME they may depend on. DEFAULT_OS_MAJOR_REV DEFAULT_OS_MINOR_REV DEFAULT_OS_TEENY_REV The predefined preprocessor macros also enable DEFAULT_MACHINE_ARCITECTURE platform specific functionalities in imake. imake is build in a two step process. When the to extract values from the operating sys- build is bootstrapped by “make World” a simple tem utsname structure. For each such imake version is build. This will be used to gener- definition found, the related line from ate a Makefile from a simple Imakefile. This this list: Makefile contains the rules to build the final ver- #define DefaultOSName \\ sion of imake which will be used to build X. <defaultOsName> #define DefaultOSMajorVersion \\ 2.2 How imake works <defaultOSMajorVersion> #define DefaultOSMinorVersion \\ <defaultOSMinorVersion> When imake is run it will: #define DefaultOSTeeneyVersion \\ <defaultOSTeenyVersion> 1. Determine the name of the Imakefile to #define <machineArchitecture> use from the -f command line option. If this option doesn’t exist it will look for a will be added. file named ‘Imakefile’ or ‘imakefile’ (c) Imake will include the definition files in the current directory. The name of localdefines and admindefines this file will be assigned to the macro if either one exists in the current direc- INCLUDE_IMAKEFILE when invoking the tory: preprocessor later on. #define IMAKE_LOCAL_DEFINES \\ 2. Determine the name of the template file to "localdefines" use from the -T command line option. If #include IMAKE_LOCAL_DEFINES this doesn’t exists it will pick the default file or ‘Imake.tmpl’. When the preprocessor is invoked this name will be assigned to the #define IMAKE_ADMIN_DEFINES \\ IMAKE_TEMPLATE macro. "admindefines" #include IMAKE_ADMIN_DEFINES 3. Determine the name of the temporary file which contains all information to be passed (d) At this point, imake adds the include to the preprocessor from the command line by statement for the template file by adding looking for the -C command line option. If the lines: none exists it will default to Imakefile.c. #define INCLUDE_IMAKEFILE \\ 4. imake will store the following information in < <imakefile> > this file: #define IMAKE_TEMPLATE \\ " <template> " (a) A C-style commented header to recog- #include IMAKE_TEMPLATE nize this file as a temporary file gener- <imakefile> is replaced by the imake ated by . name of the Imakefile to be used, (b) Imake will use any definitions found in <template> is filled in with the name imakemdep.h for: of the template file. (e) Finally, imake will include the ¤ the version of the linker macros files adminmacros and ¤ localmacros if either one is present the name of the distribution used.