summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md33
-rw-r--r--interface/Makefile2
-rw-r--r--interface/crt0.s20
-rw-r--r--kernel/kernel.h20
-rw-r--r--packages/ncurses-6.1/README1
-rw-r--r--packages/ncurses-6.1/termios.h275
-rw-r--r--ref/Cross-Porting_Software.html446
-rw-r--r--ref/GCC_Cross-Compiler.html860
-rw-r--r--ref/Hosted_GCC_Cross-Compiler.html408
-rw-r--r--ref/Porting_Newlib.html694
-rw-r--r--ref/README1
-rw-r--r--userspace/Makefile10
-rw-r--r--userspace/myclear.c (renamed from userspace/clear.c)0
-rw-r--r--userspace/ncurses/Makefile10
-rw-r--r--userspace/ncurses/ncurs.c13
-rw-r--r--xxx/packages/ncurses-5.9/termios.h14
16 files changed, 2778 insertions, 29 deletions
diff --git a/README.md b/README.md
index 07f47b9..7b3e289 100644
--- a/README.md
+++ b/README.md
@@ -119,8 +119,39 @@ Todos
* EXTRA: port to arm and berryboot / minicom?
* EXTRA: port doom/quake/mesa 3d
+
+1.GCC & Binutils
+================
+
+ * ref: GCC Cross Compiler
+ * ref: OS Specific Toolchain
+ * ref: Hosted GCC Cross Compiler
+
+2.Porting Newlib
+================
+
+ * ref: Porting_Newlib
+ * Add fool-os specifics under ../newlib-foolos/newlib/libc/sys/foolos
+ * TODO: os specifics diff
+ * cd newlib-build
+ * ../newlib-foolos/configure --prefix=/usr --target=i686-foolos
+ * make all
+ * make DESTDIR=${SYSROOT} install (e.g. make DESTDIR=/home/miguel/temp/foolos/ install)
+
+3.Porting Software
+===================
+
+ * ref: Cross Porting Software
+
+ * ncurses: ../ncurses-6.1/configure --host=i686-foolos --without-tests
+ --with-fallbacks="fool-term" --with-debug --prefix=/usr --with-termlib --without-progs
+
+ * ncurses-examples: ../ncurses-examples-20180127/configure --host=i686-foolos --prefix=/usr --with-ncurses
+ make DESTDIR=/home/miguel/temp/foolos/ install
+
+
Disclaimer
-----------
+==========
THIS IS A WORK IN PROGRESS.
diff --git a/interface/Makefile b/interface/Makefile
index 1cefd39..d70fc30 100644
--- a/interface/Makefile
+++ b/interface/Makefile
@@ -1,4 +1,6 @@
AS=i686-foolos-as
+crt0.o:
+
clean:
rm -f *.o
diff --git a/interface/crt0.s b/interface/crt0.s
index 0b833c0..c24d2d9 100644
--- a/interface/crt0.s
+++ b/interface/crt0.s
@@ -5,19 +5,19 @@ _start:
push %ebx
push %ecx
-cmp $0,_impure_ptr
-jne skipzero
+//cmp $0,_impure_ptr
+//jne skipzero
-movl $0xf5000000, _impure_ptr
-mov $0xf5000000,%ebx
+//movl $0xf5000000, _impure_ptr
+//mov $0xf5000000,%ebx
-allzero:
-movl $0, (%ebx)
-add $4, %ebx
-cmp $0xf5001000,%ebx
-jne allzero
+//allzero:
+//movl $0, (%ebx)
+//add $4, %ebx
+//cmp $0xf5001000,%ebx
+//jne allzero
-skipzero:
+//skipzero:
mov _impure_ptr,%eax
mov $0xf5000000,%ebx
diff --git a/kernel/kernel.h b/kernel/kernel.h
index acd3451..46302ba 100644
--- a/kernel/kernel.h
+++ b/kernel/kernel.h
@@ -62,18 +62,18 @@ REFERENCES
// 8192 pages = 0x2000000 bytes
// minimal space between user and kernel pages 1024 pages!
-#define VMEM_KERNEL 0x00000000 // 8192 pages (32megs) / identity mapped
-#define VMEM_KERNEL_PAGES (1024*16)
+#define VMEM_KERNEL 0x00000000 /// identity mapped
+#define VMEM_KERNEL_PAGES (1024*16) // 64mb
// VMEM_KERNEL END 0x02000000
#define VMEM_USER_ENV 0x07000000 // 1 page / per user process
//#define VMEM_USER_PROG_PAGES (256*16)
-#define VMEM_USER_PROG_PAGES (1024*16)
-#define VMEM_USER_PROG 0x08048000 // ? pages / per user process (usual entry: 0x8048080)
+#define VMEM_USER_PROG_PAGES (1024*16) // 64 megs
+#define VMEM_USER_PROG 0x08048000 // / per user process (usual entry: 0x8048080)
-#define VMEM_USER_STACK_PAGES (1024*16) // 4 pages / per thread
-#define VMEM_USER_STACK_TOP 0xF0000000 // 4 pages / per thread
+#define VMEM_USER_STACK_PAGES (1024*16) // 64 megs / per thread
+#define VMEM_USER_STACK_TOP 0xF0000000 // s / per thread
#define VMEM_LAPIC 0xF0005000 // 1 pages / identity mapped
#define VMEM_IOAPIC 0xF0006000 // 1 pages / identity mapped
@@ -87,11 +87,11 @@ REFERENCES
//TODO: do not hardcode in crt0.s!!!!
#define VMEM_USER_NEWLIB 0xF5000000 // 1 page / newlib reentrancy struct. 1 per thread
-#define VMEM_FRAMEBUFFER 0xF6000000 // 8192 pages (32megs) / identity mapped
-#define VMEM_FRAMEBUFFER_PAGES (1024*8)
+#define VMEM_FRAMEBUFFER 0xF6000000 // identity mapped
+#define VMEM_FRAMEBUFFER_PAGES (1024*8) // 32mb
-#define VMEM_EXT2_RAMIMAGE 0xF8000000 // 8192 pages (32megs) / identity mapped
-#define VMEM_EXT2_PAGES (1024*16)
+#define VMEM_EXT2_RAMIMAGE 0xF8000000 // identity mapped
+#define VMEM_EXT2_PAGES (1024*16) // 64mb
#define VMEM_USER_FRAMEBUFFER 0xFC000000
#define VMEM_USER_FRAMEBUFFER_PAGES 300// 4*320*480 bytes per app (one extra?)
diff --git a/packages/ncurses-6.1/README b/packages/ncurses-6.1/README
new file mode 100644
index 0000000..31432fa
--- /dev/null
+++ b/packages/ncurses-6.1/README
@@ -0,0 +1 @@
+../ncurses-6.1/configure --host=i686-foolos --without-tests --with-fallbacks="fool-term" --with-debug --prefix=/usr --with-termlib --without-progs
diff --git a/packages/ncurses-6.1/termios.h b/packages/ncurses-6.1/termios.h
new file mode 100644
index 0000000..57011cd
--- /dev/null
+++ b/packages/ncurses-6.1/termios.h
@@ -0,0 +1,275 @@
+/* termios type and macro definitions. Linux version.
+ Copyright (C) 1993-1999, 2003, 2005, 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <stdint.h>
+
+struct __dirstream
+{
+ int fd;
+ //..
+ //https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/dirstream.h;h=8303f07fab6f6efaa39e51411ef924e712d995e0;hb=fa39685d5c7df2502213418bead44e9543a9b9ec
+};
+
+//typedef uint32_t __ino_t;
+
+struct dirent
+{
+ __ino_t d_ino;
+ __off_t d_off;
+ unsigned short int d_reclen;
+ unsigned char d_type;
+ char d_name[256]; /* We must not include limits.h! */
+ int d_namlen;
+};
+#define direct dirent
+
+
+typedef struct __dirstream DIR;
+
+#include <sys/time.h>
+
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+#define NCCS 32
+struct termios
+ {
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_line; /* line discipline */
+ cc_t c_cc[NCCS]; /* control characters */
+ speed_t c_ispeed; /* input speed */
+ speed_t c_ospeed; /* output speed */
+#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
+#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
+ };
+
+/* c_cc characters */
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VTIME 5
+#define VMIN 6
+#define VSWTC 7
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VEOL 11
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOL2 16
+
+/* c_iflag bits */
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IUCLC 0001000
+#define IXON 0002000
+#define IXANY 0004000
+#define IXOFF 0010000
+#define IMAXBEL 0020000
+#define IUTF8 0040000
+
+/* c_oflag bits */
+#define OPOST 0000001
+#define OLCUC 0000002
+#define ONLCR 0000004
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+#define OFILL 0000100
+#define OFDEL 0000200
+#if defined __USE_MISC || defined __USE_XOPEN
+# define NLDLY 0000400
+# define NL0 0000000
+# define NL1 0000400
+# define CRDLY 0003000
+# define CR0 0000000
+# define CR1 0001000
+# define CR2 0002000
+# define CR3 0003000
+# define TABDLY 0014000
+# define TAB0 0000000
+# define TAB1 0004000
+# define TAB2 0010000
+# define TAB3 0014000
+# define BSDLY 0020000
+# define BS0 0000000
+# define BS1 0020000
+# define FFDLY 0100000
+# define FF0 0000000
+# define FF1 0100000
+#endif
+
+#define VTDLY 0040000
+#define VT0 0000000
+#define VT1 0040000
+
+#ifdef __USE_MISC
+# define XTABS 0014000
+#endif
+
+/* c_cflag bit meaning */
+#ifdef __USE_MISC
+# define CBAUD 0010017
+#endif
+#define B0 0000000 /* hang up */
+#define B50 0000001
+#define B75 0000002
+#define B110 0000003
+#define B134 0000004
+#define B150 0000005
+#define B200 0000006
+#define B300 0000007
+#define B600 0000010
+#define B1200 0000011
+#define B1800 0000012
+#define B2400 0000013
+#define B4800 0000014
+#define B9600 0000015
+#define B19200 0000016
+#define B38400 0000017
+#ifdef __USE_MISC
+# define EXTA B19200
+# define EXTB B38400
+#endif
+#define CSIZE 0000060
+#define CS5 0000000
+#define CS6 0000020
+#define CS7 0000040
+#define CS8 0000060
+#define CSTOPB 0000100
+#define CREAD 0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL 0002000
+#define CLOCAL 0004000
+#ifdef __USE_MISC
+# define CBAUDEX 0010000
+#endif
+#define B57600 0010001
+#define B115200 0010002
+#define B230400 0010003
+#define B460800 0010004
+#define B500000 0010005
+#define B576000 0010006
+#define B921600 0010007
+#define B1000000 0010010
+#define B1152000 0010011
+#define B1500000 0010012
+#define B2000000 0010013
+#define B2500000 0010014
+#define B3000000 0010015
+#define B3500000 0010016
+#define B4000000 0010017
+#define __MAX_BAUD B4000000
+#ifdef __USE_MISC
+# define CIBAUD 002003600000 /* input baud rate (not used) */
+# define CMSPAR 010000000000 /* mark or space (stick) parity */
+# define CRTSCTS 020000000000 /* flow control */
+#endif
+
+/* c_lflag bits */
+#define ISIG 0000001
+#define ICANON 0000002
+#if defined __USE_MISC || defined __USE_XOPEN
+# define XCASE 0000004
+#endif
+#define ECHO 0000010
+#define ECHOE 0000020
+#define ECHOK 0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define TOSTOP 0000400
+#ifdef __USE_MISC
+# define ECHOCTL 0001000
+# define ECHOPRT 0002000
+# define ECHOKE 0004000
+# define FLUSHO 0010000
+# define PENDIN 0040000
+#endif
+#define IEXTEN 0100000
+#ifdef __USE_BSD
+# define EXTPROC 0200000
+#endif
+
+/* tcflow() and TCXONC use these */
+#define TCOOFF 0
+#define TCOON 1
+#define TCIOFF 2
+#define TCION 3
+
+/* tcflush() and TCFLSH use these */
+#define TCIFLUSH 0
+#define TCOFLUSH 1
+#define TCIOFLUSH 2
+
+/* tcsetattr uses these */
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+
+
+#define _IOT_termios /* Hurd ioctl type field. */ \
+ _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
+
+ static inline int tcgetattr(int fd, struct termios *termios_p)
+ {
+ }
+
+ int tcsetattr(int fd, int optional_actions, const struct termios *termios_p);
+/**
+
+ int tcsendbreak(int fd, int duration);
+
+ int tcdrain(int fd);
+
+ int tcflush(int fd, int queue_selector);
+
+ int tcflow(int fd, int action);
+*/
+ void cfmakeraw(struct termios *termios_p);
+
+ /*
+ speed_t cfgetispeed(const struct termios *termios_p);
+
+ */
+ speed_t cfgetospeed(const struct termios *termios_p);
+
+ /*
+ int cfsetispeed(struct termios *termios_p, speed_t speed);
+
+ int cfsetospeed(struct termios *termios_p, speed_t speed);
+
+ int cfsetspeed(struct termios *termios_p, speed_t speed);
+ */
+
diff --git a/ref/Cross-Porting_Software.html b/ref/Cross-Porting_Software.html
new file mode 100644
index 0000000..7aa63e5
--- /dev/null
+++ b/ref/Cross-Porting_Software.html
@@ -0,0 +1,446 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr" class="client-nojs">
+<head>
+<title>Cross-Porting Software - OSDev Wiki</title>
+<meta charset="UTF-8" />
+<meta name="generator" content="MediaWiki 1.18.0" />
+<link rel="shortcut icon" href="/favicon.ico" />
+<link rel="search" type="application/opensearchdescription+xml" href="/opensearch_desc.php" title="OSDev Wiki (en)" />
+<link rel="EditURI" type="application/rsd+xml" href="https://wiki.osdev.org/api.php?action=rsd" />
+<link rel="alternate" type="application/atom+xml" title="OSDev Wiki Atom feed" href="/index.php?title=Special:RecentChanges&amp;feed=atom" />
+<link rel="stylesheet" href="/load.php?debug=false&amp;lang=en&amp;modules=mediawiki.legacy.commonPrint%2Cshared%7Cskins.vector&amp;only=styles&amp;skin=vector&amp;*" />
+<meta name="ResourceLoaderDynamicStyles" content="" />
+<link rel="stylesheet" href="/load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=styles&amp;skin=vector&amp;*" />
+<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}a.new,#quickbar a.new{color:#ba0000}
+
+/* cache key: wikidb:resourceloader:filter:minify-css:4:c88e2bcd56513749bec09a7e29cb3ffa */
+</style>
+<script src="/load.php?debug=false&amp;lang=en&amp;modules=startup&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.config.set({"wgCanonicalNamespace": "", "wgCanonicalSpecialPageName": false, "wgNamespaceNumber": 0, "wgPageName": "Cross-Porting_Software", "wgTitle": "Cross-Porting Software", "wgCurRevisionId": 19481, "wgArticleId": 3628, "wgIsArticle": true, "wgAction": "view", "wgUserName": null, "wgUserGroups": ["*"], "wgCategories": ["Level 3 Tutorials"], "wgBreakFrames": false, "wgRestrictionEdit": [], "wgRestrictionMove": []});
+}
+</script><script>if(window.mw){
+ mw.loader.load(["mediawiki.page.startup"]);
+}
+</script>
+<style type="text/css">/*<![CDATA[*/
+.source-bash {line-height: normal;}
+.source-bash li, .source-bash pre {
+ line-height: normal; border: 0px none white;
+}
+/**
+ * GeSHi Dynamically Generated Stylesheet
+ * --------------------------------------
+ * Dynamically generated stylesheet for bash
+ * CSS class: source-bash, CSS id:
+ * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
+ * (http://qbnz.com/highlighter/ and http://geshi.org/)
+ * --------------------------------------
+ */
+.bash.source-bash .de1, .bash.source-bash .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
+.bash.source-bash {font-family:monospace;}
+.bash.source-bash .imp {font-weight: bold; color: red;}
+.bash.source-bash li, .bash.source-bash .li1 {font-weight: normal; vertical-align:top;}
+.bash.source-bash .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
+.bash.source-bash .li2 {font-weight: bold; vertical-align:top;}
+.bash.source-bash .kw1 {color: #000000; font-weight: bold;}
+.bash.source-bash .kw2 {color: #c20cb9; font-weight: bold;}
+.bash.source-bash .kw3 {color: #7a0874; font-weight: bold;}
+.bash.source-bash .co0 {color: #666666; font-style: italic;}
+.bash.source-bash .co1 {color: #800000;}
+.bash.source-bash .co2 {color: #cc0000; font-style: italic;}
+.bash.source-bash .co3 {color: #000000; font-weight: bold;}
+.bash.source-bash .co4 {color: #666666;}
+.bash.source-bash .es1 {color: #000099; font-weight: bold;}
+.bash.source-bash .es2 {color: #007800;}
+.bash.source-bash .es3 {color: #007800;}
+.bash.source-bash .es4 {color: #007800;}
+.bash.source-bash .es5 {color: #780078;}
+.bash.source-bash .es_h {color: #000099; font-weight: bold;}
+.bash.source-bash .br0 {color: #7a0874; font-weight: bold;}
+.bash.source-bash .sy0 {color: #000000; font-weight: bold;}
+.bash.source-bash .st0 {color: #ff0000;}
+.bash.source-bash .st_h {color: #ff0000;}
+.bash.source-bash .nu0 {color: #000000;}
+.bash.source-bash .re0 {color: #007800;}
+.bash.source-bash .re1 {color: #007800;}
+.bash.source-bash .re2 {color: #007800;}
+.bash.source-bash .re4 {color: #007800;}
+.bash.source-bash .re5 {color: #660033;}
+.bash.source-bash .ln-xtra, .bash.source-bash li.ln-xtra, .bash.source-bash div.ln-xtra {background-color: #ffc;}
+.bash.source-bash span.xtra { display:block; }
+
+/*]]>*/
+</style>
+<style type="text/css">/*<![CDATA[*/
+@import "/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
+/*]]>*/
+</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/skins/vector/csshover.min.htc")}</style><![endif]--></head>
+<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-Cross-Porting_Software action-view skin-vector">
+ <div id="mw-page-base" class="noprint"></div>
+ <div id="mw-head-base" class="noprint"></div>
+ <!-- content -->
+ <div id="content">
+ <a id="top"></a>
+ <div id="mw-js-message" style="display:none;"></div>
+ <!-- firstHeading -->
+ <h1 id="firstHeading" class="firstHeading">Cross-Porting Software</h1>
+ <!-- /firstHeading -->
+ <!-- bodyContent -->
+ <div id="bodyContent">
+ <!-- tagline -->
+ <div id="siteSub">From OSDev Wiki</div>
+ <!-- /tagline -->
+ <!-- subtitle -->
+ <div id="contentSub"></div>
+ <!-- /subtitle -->
+ <!-- jumpto -->
+ <div id="jump-to-nav">
+ Jump to: <a href="#mw-head">navigation</a>,
+ <a href="#p-search">search</a>
+ </div>
+ <!-- /jumpto -->
+ <!-- bodycontent -->
+ <div lang="en" dir="ltr" class="mw-content-ltr"><table style="font-size:95%; line-height:1.5em; padding:0.25em; float:right; margin: 0 0 8px 15px; clear:right; border:1px solid #aaaaaa; background:#eee; text-align:center;;"><tr><th>Difficulty level</th></tr><tr><td><a href="/File:Difficulty_3.png" class="image"><img alt="Difficulty 3.png" src="/images/c/c1/Difficulty_3.png" width="46" height="14" /></a><br />Advanced</td></tr></table>
+<p>This page is notes on how to port software to your operating system by cross-compiling it. Many core packages use autoconf-generated ./configure script that provide a convenient interface for our purposes. This assumes your operating is somewhat Unix-like. There is a lot of subtle semantics that first-time porters often get wrong and particular packages occasionally misbehave. This tutorial assumes you are porting a package using a conventional configure script (generated with autoconf), but the principles can be adapted to other build systems.
+</p>
+<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
+<ul>
+<li class="toclevel-1 tocsection-1"><a href="#Prerequisites"><span class="tocnumber">1</span> <span class="toctext">Prerequisites</span></a></li>
+<li class="toclevel-1 tocsection-2"><a href="#System_Root"><span class="tocnumber">2</span> <span class="toctext">System Root</span></a></li>
+<li class="toclevel-1 tocsection-3"><a href="#Prefixes"><span class="tocnumber">3</span> <span class="toctext">Prefixes</span></a></li>
+<li class="toclevel-1 tocsection-4"><a href="#Dependencies"><span class="tocnumber">4</span> <span class="toctext">Dependencies</span></a></li>
+<li class="toclevel-1 tocsection-5"><a href="#Patches"><span class="tocnumber">5</span> <span class="toctext">Patches</span></a></li>
+<li class="toclevel-1 tocsection-6"><a href="#Source_Code"><span class="tocnumber">6</span> <span class="toctext">Source Code</span></a></li>
+<li class="toclevel-1 tocsection-7"><a href="#pkg-config"><span class="tocnumber">7</span> <span class="toctext">pkg-config</span></a></li>
+<li class="toclevel-1 tocsection-8"><a href="#Build"><span class="tocnumber">8</span> <span class="toctext">Build</span></a></li>
+<li class="toclevel-1 tocsection-9"><a href="#Porting"><span class="tocnumber">9</span> <span class="toctext">Porting</span></a></li>
+<li class="toclevel-1 tocsection-10"><a href="#Runtime"><span class="tocnumber">10</span> <span class="toctext">Runtime</span></a></li>
+<li class="toclevel-1 tocsection-11"><a href="#Problems"><span class="tocnumber">11</span> <span class="toctext">Problems</span></a>
+<ul>
+<li class="toclevel-2 tocsection-12"><a href="#libtool_.la_files"><span class="tocnumber">11.1</span> <span class="toctext">libtool .la files</span></a></li>
+<li class="toclevel-2 tocsection-13"><a href="#Dumb_pkg-config_use"><span class="tocnumber">11.2</span> <span class="toctext">Dumb pkg-config use</span></a></li>
+<li class="toclevel-2 tocsection-14"><a href="#foo-config"><span class="tocnumber">11.3</span> <span class="toctext">foo-config</span></a></li>
+<li class="toclevel-2 tocsection-15"><a href="#Running_Cross-Compiled_Programs"><span class="tocnumber">11.4</span> <span class="toctext">Running Cross-Compiled Programs</span></a></li>
+<li class="toclevel-2 tocsection-16"><a href="#Assuming_the_Worst"><span class="tocnumber">11.5</span> <span class="toctext">Assuming the Worst</span></a></li>
+<li class="toclevel-2 tocsection-17"><a href="#Gnulib"><span class="tocnumber">11.6</span> <span class="toctext">Gnulib</span></a></li>
+<li class="toclevel-2 tocsection-18"><a href="#Custom_Configure_Script"><span class="tocnumber">11.7</span> <span class="toctext">Custom Configure Script</span></a></li>
+<li class="toclevel-2 tocsection-19"><a href="#No_DESTDIR"><span class="tocnumber">11.8</span> <span class="toctext">No DESTDIR</span></a></li>
+<li class="toclevel-2 tocsection-20"><a href="#Packages_Containing_Dependencies"><span class="tocnumber">11.9</span> <span class="toctext">Packages Containing Dependencies</span></a></li>
+<li class="toclevel-2 tocsection-21"><a href="#Exotic_problems"><span class="tocnumber">11.10</span> <span class="toctext">Exotic problems</span></a></li>
+</ul>
+</li>
+<li class="toclevel-1 tocsection-22"><a href="#Upstreaming_Local_Patches"><span class="tocnumber">12</span> <span class="toctext">Upstreaming Local Patches</span></a></li>
+<li class="toclevel-1 tocsection-23"><a href="#Patch_Collections"><span class="tocnumber">13</span> <span class="toctext">Patch Collections</span></a></li>
+</ul>
+</td></tr></table>
+<h2> <span class="mw-headline" id="Prerequisites"> Prerequisites </span></h2>
+<p>This is an advanced matter and your operating system needs to have an established user-space and a dedicated toolchain:
+</p>
+<ul><li> You need a <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a> like <tt>x86_64-myos</tt>.
+</li><li> You need a <a href="/C_Library" title="C Library">standard library</a> implementation that provides what the third party software needs.
+</li></ul>
+<h2> <span class="mw-headline" id="System_Root"> System Root </span></h2>
+<dl><dd>Please read this <a href="/Meaty_Skeleton#System_Root" title="Meaty Skeleton">article's section on sysroots</a>.
+</dd></dl>
+<p>Your build process needs to involve a system root, a fake root directory for your operating system. Your cross-compiler must be set up to search this directory tree for libraries and headers. I recommend for your build system to look through each of your subprojects and <i>make install</i> them into this system root, then do the same for ports, and finally your build system extracts the desired files from the system root and makes a boot-able image. We will be installing ports into this directory tree. Futher ports may depend on previous ones and it's crucial the system root is searched.
+</p>
+<h2> <span class="mw-headline" id="Prefixes"> Prefixes </span></h2>
+<p>The build systems of the software installs the software somewhere. This is normally in <tt>${PREFIX}/bin</tt>, <tt>${PREFIX}/lib</tt> and so on. The packages often defaults to <tt>/usr/local</tt>, but this is generally used for site-specific files rather than vendor-provided files (you are a vendor now). Note how if you want to install packages into <tt>/bin</tt> and <tt>/lib</tt>, you set the prefix to the empty string, not a single slash. A prefix is not a directory path in its own right, but something that is added in front of a real directory path.
+</p>
+<h2> <span class="mw-headline" id="Dependencies"> Dependencies </span></h2>
+<p>Before porting a package, you need to port its dependencies first (and transitively their dependencies as well). You can often find a list of dependencies in the documentation (perhaps look for README or INSTALL files). Try also to run <tt>./configure --help</tt>, this will often list <tt>--with-foo</tt> options if the package depends on libfoo, it will also list which dependencies are optional. See also guides like <a rel="nofollow" class="external text" href="http://www.linuxfromscratch.org/blfs/">Beyond Linux from Scratch</a> as it contains useful dependency information.
+</p><p>You should be able to construct a nice directed acylic graph of packages and their dependencies (some edges being optional) and use it to decide the order packages are built. If you are not interested in optional dependencies, you can skip them, but beware: Later package may hard-depend on the package you skipped, and may assume a library was built with support for the packager you skipped.
+</p>
+<h2> <span class="mw-headline" id="Patches"> Patches </span></h2>
+<p>It is very likely that you will need to patch the packages you port. You need to set yourself up such that you can easily patch the packages with no to low cost in effort. You can help other people by hosting your patch collection somewhere public. It is often nicer to actually fix misbehaving packages than working around the problem in your build system in complex manners.
+</p>
+<h2> <span class="mw-headline" id="Source_Code"> Source Code </span></h2>
+<p>You need to find the source code for the package you wish to port. This is rather obvious. Generally, it's best to find the latest stable tarball of the package use that. This is preferable to using a git checkout of the package. It's a good idea to save a copy of the original tarball.
+</p><p>It's advisable to check whether this is a real release or whether it has been maliciously modified. Many projects provide hash values of their releases or otherwise sign their releases. Configure scripts are highly convenient places to hide malware (if you have the autoconf skills, you can regenerate the configure script and other files and see if they match). Man-in-the-middle attacking in insecure http/ftp download of a tarball is trivial, you can mitigate this danger by downloading from multiple networks and verifying what other people have.
+</p><p>You also definitely wish to to read the license for the software and whether it even permits the efforts we are taking here.
+</p><p>You extract the source code somewhere appropriate:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="co0"># Use --extract --file if you have a hard time surviving xkcd 1168.</span>
+<span class="kw2">tar</span> <span class="re5">-xf</span> libfoo-<span class="nu0">4.2</span>.tar.xz</pre></div></div>
+<h2> <span class="mw-headline" id="pkg-config"> pkg-config </span></h2>
+<p>Libraries increasingly provide pkg-config files that describe where the headers are installed and how to link against the library (and private library dependencies if statically linked). Working with pkg-config is preferable to fighting it (see below on packages rolling their own foo-config program) and it nicely supports system roots and is cross-compile aware. It's possible to compile a custom cross-pkg-config, or you can simply wrap your system one. Make a <tt>x86_64-myos-pkg-config</tt> executable shell script and put it somewhere in your path for the duration of the cross-compilation:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="co0">#!/bin/sh</span>
+<span class="co0"># Fill these in appropriately:</span>
+<span class="kw3">export</span> <span class="re2">PKG_CONFIG_SYSROOT_DIR</span>=<span class="re1">$MYOS_SYSROOT</span>
+<span class="kw3">export</span> <span class="re2">PKG_CONFIG_LIBDIR</span>=<span class="re1">$MYOS_SYSROOT</span><span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>pkgconfig
+<span class="co0"># TODO: If it works this should probably just be set to the empty string.</span>
+<span class="kw3">export</span> <span class="re2">PKG_CONFIG_PATH</span>=<span class="re1">$PKG_CONFIG_LIBDIR</span>
+<span class="co0"># Use --static here if your OS only has static linking.</span>
+<span class="co0"># TODO: Perhaps it's a bug in the libraries if their pkg-config files doesn't</span>
+<span class="co0"># record that only static libraries were built.</span>
+<span class="kw3">exec</span> pkg-config <span class="re5">--static</span> <span class="st0">&quot;$@&quot;</span></pre></div></div>
+<p>You then set <tt>PKG_CONFIG=x86_64-myos-pkg-config</tt> to packages use your custom pkg-config instead, and <tt>PKG_CONFIG_FOR_BUILD=pkg-config</tt> so packages that wish to compile local programs use the system pkg-config.
+</p>
+<h2> <span class="mw-headline" id="Build"> Build </span></h2>
+<p>This section lists the steps that are sufficient for an ideal port, but see below.
+</p><p>First you wish to find the <tt>config.sub</tt> file. The GNU coding conventions usually place it at <tt>build-aux/config.sub</tt> to avoid clutter in the main directory. You wish to add your operating system's target name to it, as you did in the <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a> article. This change is required, or otherwise the <tt>--host</tt> value will be rejected. This simple fact means that you likely have to have a small patch for every single port.
+</p><p>Secondly, you cross-build the package in this manner:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="co0"># Potentially unset CC and such here (see configure --help) to prevent local</span>
+<span class="co0"># tools from being mistakenly used as cross-tools. Alternatively, set them to</span>
+<span class="co0"># your cross-tools unconditionally. Note also the existence of CC_FOR_BUILD in</span>
+<span class="co0"># the case of packages that needs to build local tools to build themselves.</span>
+&#160;
+.<span class="sy0">/</span>configure <span class="re5">--host</span>=x86_64-myos <span class="re5">--prefix</span>=<span class="sy0">/</span>usr
+<span class="kw2">make</span>
+<span class="kw2">make</span> <span class="re2">DESTDIR</span>=<span class="re1">$SYSROOT</span> <span class="kw2">install</span></pre></div></div>
+<p>This will cross-compile the software and install it under <tt>/usr</tt> on your system, inside your system root as the temporary installation location. Note how many packages remember <tt>--prefix</tt> and use it at runtime to locate their data files. You must not do <tt>--prefix=$SYSROOT/usr</tt> as that means libfoo would look files in <tt>/home/myuser/myos/sysroot/usr/share/libfoo</tt> while running on your operating system instead of <tt>/usr/share/libfoo</tt>. The <tt>DESTDIR</tt> acts as a second prefix for the purpose of installation, it's not revealed to the package before the install step, so it won't mistakenly remember it.
+</p><p>Alternatively, instead of setting <tt>DESTDIR</tt> to the system root, you can set it to a temporary location and create an installable binary package from it, and then install the binary package into the system root.
+</p>
+<h2> <span class="mw-headline" id="Porting"> Porting </span></h2>
+<p>The <tt>make</tt> command likely didn't succeed. You'll need to investigate the build errors and improve your standard library, or improve the package if it is unreasonable.
+</p>
+<h2> <span class="mw-headline" id="Runtime"> Runtime </span></h2>
+<p>After you cross-compiled the package and installed it onto your operating system, it's time to try it out. If you implemented your operating system and standard library well, it should now work. Likely, especially if you made your own custom standard library, your first real ports won't. You now need to learn to debug programs you know nothing about on your new operating system. Have fun! Suddenly it'll work and you have something to talk about in the 'Aww, Yeah!' forum thread.
+</p>
+<h2> <span class="mw-headline" id="Problems"> Problems </span></h2>
+<p>Unfortunately, this is the real world and some packages misbehave in manners that breaks our naive cross-compilation. This is a bug in such packages; the practice described so far should be sufficient for well-made packages. Fortunately, community members likely know of such issues and generally work to upstream fixes, see the patch collections below. This section lists common problems and solutions.
+</p><p>In case it's a bug in these packages, it's advisable to patch the packages to fix the bug and upstream the bugfix (or report the issue), rather than poorly working around the issues in your build system (in ways that tend to get more and more complex). Generally, the best approach is to make the packages implement the interface we rely on above.
+</p>
+<h3> <span class="mw-headline" id="libtool_.la_files"> libtool .la files </span></h3>
+<p>Many libraries use libtool and install .la files into the system library directory. These work somewhat like pkg-config files, except often semantically wrong as they are not sysroot aware (but research the <tt>--with-sysroot</tt> option that libtool-aware configure scripts provide, it might save the system root path in the .la files which is wrong). The files can cause the build system to add library directories to the link command that weren't prefixed with the system root, causing the command link with the <tt>/usr/lib</tt> files from your local operating system.
+</p><p>It's entirely safe to delete these files, so set up your post-install build steps to delete any .la files on sight. The libraries generally install pkg-config files as well and the programs generally use pkg-config to locate libraries anyways (if not, it's perhaps a bug).
+</p>
+<h3> <span class="mw-headline" id="Dumb_pkg-config_use"> Dumb pkg-config use </span></h3>
+<p>Some packages simply invoke pkg-config with the raw <tt>pkg-config</tt> command, rather than using the <tt>PKG_CONFIG</tt> and <tt>PKG_CONFIG_FOR_BUILD</tt> variables. That is a bug. The correct logic is to use the variables if they exist and fall back on the raw command otherwise. The shell expression <tt>${PKG_CONFIG:=pkg-config}</tt> is useful as if it is set and non-empty, then it is used, otherwise pkg-config us used.
+</p>
+<h3> <span class="mw-headline" id="foo-config"> foo-config </span></h3>
+<p>Some packages (like libfreetype, libpng, libsdl, libxml2, and more) install a custom program like <tt>freetype-config</tt> into the bin directory. The idea is packages depending on libfreetype can run <tt>freetype-config --cflags --libs</tt> and it gets the compiler options needed to use the library. This scheme fails horribly in practice, as the bin directory of your operating system is not in your PATH (neither should it be!) and instead the <tt>freetype-config</tt> program of your distribution is used instead. The programs are not even sysroot-aware so it's not added in front of the compiler options. Suddenly your otherwise-nicely cross-compiled programs got linked with a Linux libfreetype with the Linux version of the headers.
+</p><p>The solution is to nuke these programs on sight. They're broken and should never be used or installed on your operating system. Tell the upstream developers to stop providing them and provide pkg-config files, and projects using them to use pkg-config instead. This is supposedly why pkg-config was created, to do this once and for all in a proper way. If you see programs using the foo-config programs, patch the configure script so they use pkg-config instead.
+</p>
+<h3> <span class="mw-headline" id="Running_Cross-Compiled_Programs"> Running Cross-Compiled Programs </span></h3>
+<p>Some packages are not cross-compile aware and use the standard compiler (your cross-compiler) to build a local program that generates parts of the program and then runs the program. This doesn't work, it runs a cross-compiled executable and it won't run on your local operating system. The results vary from execve returning an error, infinite loops, or mysterious crashes. The bug is that the package should have used a variable like <tt>CC_FOR_BUILD</tt> to compile programs for the local system.
+</p><p>This occasionally also takes the form of configure tests that are mistakenly run (not just compiled and linked) when cross-compiling. A while ago, a lot of packages checked for Japanese locales by unconditionally running such tests when cross-compiling leading to fun results. The correct behavior is to attempt running this test, and if we are cross-compiling, then assume something reasonable (or delaying the test until the program is actually run).
+</p>
+<h3> <span class="mw-headline" id="Assuming_the_Worst"> Assuming the Worst </span></h3>
+<p>Some packages take portability to the levels where they want to support broken operating systems and do compatibility magic in these cases. This is often to work around a bug in a particular release of a particular operating system. This compatibility occasionally takes the form of a configure test that needs to be executed. In the event of cross-compilation, these tests needs to assume something. The developers made the error of assuming unknown systems are terribly broken, instead of just using a heuristic that FooBSD (before release 5) is broken and assuming the best about all other systems.
+</p><p>The correct solution is for packages to assume the best about unknown operating systems. This shifts the punishment from the good systems to the bad systems (so they break and they have the opportunity to fix bugs). This is not a problem for existing systems, because if the developers care about FooBSD, that's not an unknown system.
+</p>
+<h3> <span class="mw-headline" id="Gnulib"> Gnulib </span></h3>
+<p>The GNU portability layer takes the form of a collection of files that everyone copies into their packages and then neglect to update often. These files are often deeply integrated into the package (i.e. hard to disable properly). The principle of replacing standard library functions if broken or missing is not too terribly bad - but Gnulib mixes it with a huge paranoia that the host system is terribly broken and assumes the very worst when cross-compiling. The result is that when you cross-compile these ports, huge amounts of compatibility code gets compiled in, and much of this compatibility code does not even work on unknown platforms. Of particular fun is code that needs to integrate deeply into stdio internals or when it replaces your printf. The result is that as you port packages, you often find yourself fixing the same gnulib code over and over (each time subtly different depending on when it was forked). When you improve your stdio implementation to be more standards-compliant, you find yourself needing to fix all those gnulib stdio-internals-aware files all over again, because some silly internal changed.
+</p><p>The solution is to scream in horror at how troublesome and unnecessary this scheme is as obviously you are capable of implementing a correct operating system. This racketeering scheme has <tt>#error</tt> statements that tell you to upstream preprocessor conditionals for your operating system, so they can relish in even more complexity that didn't need to exist in the first place.
+</p><p><a href="/User:Sortie" title="User:Sortie">Sortie</a> has developed a <a rel="nofollow" class="external text" href="https://gitlab.com/sortix/sortix/wikis/Gnulib">gnulib policy for his OS</a> that describes how to handle gnulib and it has a long list of secret autoconf variables that makes gnulib assume everything is perfect.
+</p>
+<h3> <span class="mw-headline" id="Custom_Configure_Script"> Custom Configure Script </span></h3>
+<p>Some packages considers autoconf to be hellish and refuses to use it. They occasionally replace an autoconf-generated configure script with a hand-written one. This is well, but they unfortunately often fail to completely implement the same interface and don't support cross-compilation. You can attempt to patch the configure script to it implements the same interface, or do whatever else gets the job done. You probably want to yell at the developers.
+</p>
+<h3> <span class="mw-headline" id="No_DESTDIR"> No DESTDIR </span></h3>
+<p>The package might not support the <tt>DESTDIR</tt> variable. You should patch the <tt>Makefile</tt> (perhaps <tt>Makefile.in</tt>) to support it and tell the upstream developers. Perhaps it's called something else like <tt>INSTALLROOT</tt>, you can rename it in the Makefile or add <tt>INSTALLROOT&#160;?= $(DESTDIR)</tt>.
+</p>
+<h3> <span class="mw-headline" id="Packages_Containing_Dependencies"> Packages Containing Dependencies </span></h3>
+<p>Sometimes packages contain copies of their dependencies as subdirectories. If you are really unlucky, they get used instead of the real deal. That means you have to port a two year old version all over again. If you are more unlucky, you get something that actually compiles on your operating system, but contains unfixed bugs and has security issues and this gets silently used. Extra fun is if they fixed bugs or enhanced the library and this is not in the upstream version. Tell upstream projects to get their act together if you see it, it's your responsibility to provide dependencies for a good reason.
+</p>
+<h3> <span class="mw-headline" id="Exotic_problems"> Exotic problems </span></h3>
+<p>As you start porting packages that rarely get ported or cross-compiled, you'll likely start finding some seriously messed up packages. For instance, I once found a library that stores the path to the compiler and the compiler options in a header, so other libraries/programs depending on it could locate the compiler that way (and they did) - despite the fact they also had a full and generated configure script. At some point, you should reconsider whether this is actually software you want to port.
+</p>
+<h2> <span class="mw-headline" id="Upstreaming_Local_Patches"> Upstreaming Local Patches </span></h2>
+<p>As you port more packages, you gradually get a patch collection. Many of these patches likely works around issues in your system, but other patches solves general issues in the packages. Ideally, you should not need to patch packages at all. Though, your operating system is not terribly important to support in the upstream version and any patches will likely go stale soon as your operating system improves. However, the patches not related to your operating system is likely of value upstream (or to the other osdever's that also port stuff). You should send such patches upstream or file bug reports. In the long run, it decreases the size of your patch collection and makes it more maintainable.
+</p>
+<h2> <span class="mw-headline" id="Patch_Collections"> Patch Collections </span></h2>
+<p>It is probable that other community members have already ported a particular package. Their patches likely contain insight into how troublesome it is to do a port and what needs to be done. You can often find a collection of all their local patches in a central location.
+</p>
+<ul><li> <a href="/User:Sortie" title="User:Sortie">Sortie</a> has a <a rel="nofollow" class="external text" href="https://users-cs.au.dk/sortie/sortix/release/nightly/patches/">large collection of patches</a> and <a rel="nofollow" class="external text" href="https://gitlab.com/sortix/sortix/wikis/Ports">notes on each port</a>.
+</li></ul>
+
+<!--
+NewPP limit report
+Preprocessor node count: 267/1000000
+Post-expand include size: 372/2097152 bytes
+Template argument size: 84/2097152 bytes
+Expensive parser function count: 0/100
+-->
+
+<!-- Saved in parser cache with key wikidb:pcache:idhash:3628-0!*!0!!en!2!* and timestamp 20181010183746 -->
+</div> <!-- /bodycontent -->
+ <!-- printfooter -->
+ <div class="printfooter">
+ Retrieved from "<a href="https://wiki.osdev.org/index.php?title=Cross-Porting_Software&amp;oldid=19481">https://wiki.osdev.org/index.php?title=Cross-Porting_Software&amp;oldid=19481</a>" </div>
+ <!-- /printfooter -->
+ <!-- catlinks -->
+ <div id='catlinks' class='catlinks'><div id="mw-normal-catlinks"><a href="/Special:Categories" title="Special:Categories">Category</a>: <ul><li><a href="/Category:Level_3_Tutorials" title="Category:Level 3 Tutorials">Level 3 Tutorials</a></li></ul></div></div> <!-- /catlinks -->
+ <div class="visualClear"></div>
+ <!-- debughtml -->
+ <!-- /debughtml -->
+ </div>
+ <!-- /bodyContent -->
+ </div>
+ <!-- /content -->
+ <!-- header -->
+ <div id="mw-head" class="noprint">
+
+<!-- 0 -->
+<div id="p-personal" class="">
+ <h5>Personal tools</h5>
+ <ul>
+ <li id="pt-login"><a href="/index.php?title=Special:UserLogin&amp;returnto=Cross-Porting_Software" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o">Log in</a></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+ <div id="left-navigation">
+
+<!-- 0 -->
+<div id="p-namespaces" class="vectorTabs">
+ <h5>Namespaces</h5>
+ <ul>
+ <li id="ca-nstab-main" class="selected"><span><a href="/Cross-Porting_Software" title="View the content page [c]" accesskey="c">Page</a></span></li>
+ <li id="ca-talk" class="new"><span><a href="/index.php?title=Talk:Cross-Porting_Software&amp;action=edit&amp;redlink=1" title="Discussion about the content page [t]" accesskey="t">Discussion</a></span></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+
+<!-- 1 -->
+<div id="p-variants" class="vectorMenu emptyPortlet">
+ <h5><span>Variants</span><a href="#"></a></h5>
+ <div class="menu">
+ <ul>
+ </ul>
+ </div>
+</div>
+
+<!-- /1 -->
+ </div>
+ <div id="right-navigation">
+
+<!-- 0 -->
+<div id="p-views" class="vectorTabs">
+ <h5>Views</h5>
+ <ul>
+ <li id="ca-view" class="selected"><span><a href="/Cross-Porting_Software" >Read</a></span></li>
+ <li id="ca-viewsource"><span><a href="/index.php?title=Cross-Porting_Software&amp;action=edit" title="This page is protected.&#10;You can view its source [e]" accesskey="e">View source</a></span></li>
+ <li id="ca-history" class="collapsible"><span><a href="/index.php?title=Cross-Porting_Software&amp;action=history" title="Past revisions of this page [h]" accesskey="h">View history</a></span></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+
+<!-- 1 -->
+<div id="p-cactions" class="vectorMenu emptyPortlet">
+ <h5><span>Actions</span><a href="#"></a></h5>
+ <div class="menu">
+ <ul>
+ </ul>
+ </div>
+</div>
+
+<!-- /1 -->
+
+<!-- 2 -->
+<div id="p-search">
+ <h5><label for="searchInput">Search</label></h5>
+ <form action="/index.php" id="searchform">
+ <input type='hidden' name="title" value="Special:Search"/>
+ <input type="search" name="search" title="Search OSDev Wiki [f]" accesskey="f" id="searchInput" /> <input type="submit" name="go" value="Go" title="Go to a page with this exact name if exists" id="searchGoButton" class="searchButton" /> <input type="submit" name="fulltext" value="Search" title="Search the pages for this text" id="mw-searchButton" class="searchButton" /> </form>
+</div>
+
+<!-- /2 -->
+ </div>
+ </div>
+ <!-- /header -->
+ <!-- panel -->
+ <div id="mw-panel" class="noprint">
+ <!-- logo -->
+ <div id="p-logo"><a style="background-image: url(/skins/common/images/osdev.png);" href="/Main_Page" title="Visit the main page"></a></div>
+ <!-- /logo -->
+
+<!-- navigation -->
+<div class="portal" id='p-navigation'>
+ <h5>Navigation</h5>
+ <div class="body">
+ <ul>
+ <li id="n-mainpage"><a href="/Main_Page" title="Visit the main page [z]" accesskey="z">Main Page</a></li>
+ <li id="n-portal"><a href="http://forum.osdev.org/" rel="nofollow" title="About the project, what you can do, where to find things">Forums</a></li>
+ <li id="n-FAQ"><a href="/Category:FAQ">FAQ</a></li>
+ <li id="n-OS-Projects"><a href="/Projects">OS Projects</a></li>
+ <li id="n-randompage"><a href="/Special:Random" title="Load a random page [x]" accesskey="x">Random page</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /navigation -->
+
+<!-- about -->
+<div class="portal" id='p-about'>
+ <h5>About</h5>
+ <div class="body">
+ <ul>
+ <li id="n-This-site"><a href="/OSDevWiki:About">This site</a></li>
+ <li id="n-Joining"><a href="/OSDevWiki:Joining">Joining</a></li>
+ <li id="n-Editing-help"><a href="/OSDevWiki:Editing">Editing help</a></li>
+ <li id="n-recentchanges"><a href="/Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /about -->
+
+<!-- SEARCH -->
+
+<!-- /SEARCH -->
+
+<!-- TOOLBOX -->
+<div class="portal" id='p-tb'>
+ <h5>Toolbox</h5>
+ <div class="body">
+ <ul>
+ <li id="t-whatlinkshere"><a href="/Special:WhatLinksHere/Cross-Porting_Software" title="A list of all wiki pages that link here [j]" accesskey="j">What links here</a></li>
+ <li id="t-recentchangeslinked"><a href="/Special:RecentChangesLinked/Cross-Porting_Software" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li>
+ <li id="t-specialpages"><a href="/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q">Special pages</a></li>
+ <li><a href="/index.php?title=Cross-Porting_Software&amp;printable=yes" rel="alternate">Printable version</a></li>
+ <li id="t-permalink"><a href="/index.php?title=Cross-Porting_Software&amp;oldid=19481" title="Permanent link to this revision of the page">Permanent link</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /TOOLBOX -->
+
+<!-- LANGUAGES -->
+
+<!-- /LANGUAGES -->
+ </div>
+ <!-- /panel -->
+ <!-- footer -->
+ <div id="footer">
+ <ul id="footer-info">
+ <li id="footer-info-lastmod"> This page was last modified on 15 July 2016, at 17:16.</li>
+ <li id="footer-info-viewcount">This page has been accessed 10,259 times.</li>
+ </ul>
+ <ul id="footer-places">
+ <li id="footer-places-privacy"><a href="/OSDev_Wiki:Privacy_policy" title="OSDev Wiki:Privacy policy">Privacy policy</a></li>
+ <li id="footer-places-about"><a href="/OSDev_Wiki:About" title="OSDev Wiki:About">About OSDev Wiki</a></li>
+ <li id="footer-places-disclaimer"><a href="/OSDev_Wiki:General_disclaimer" title="OSDev Wiki:General disclaimer">Disclaimers</a></li>
+ </ul>
+ <ul id="footer-icons" class="noprint">
+ <li id="footer-poweredbyico">
+ <a href="http://www.mediawiki.org/"><img src="/skins/common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" width="88" height="31" /></a>
+ </li>
+ </ul>
+ <div style="clear:both"></div>
+ </div>
+ <!-- /footer -->
+ <!-- fixalpha -->
+ <script type="text/javascript"> if ( window.isMSIE55 ) fixalpha(); </script>
+ <!-- /fixalpha -->
+ <script src="/load.php?debug=false&amp;lang=en&amp;modules=skins.vector&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.loader.load(["mediawiki.user", "mediawiki.util", "mediawiki.page.ready", "mediawiki.legacy.wikibits", "mediawiki.legacy.ajax"]);
+}
+</script>
+<script src="/load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":1,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"highlightbroken":1,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":1,"showtoolbar":1,"skin":"vector","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,"watchlistdays":3,"watchlisthideanons":0,
+ "watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false});;mw.user.tokens.set({"editToken":"+\\","watchToken":false});;mw.loader.state({"user.options":"ready","user.tokens":"ready"});
+
+ /* cache key: wikidb:resourceloader:filter:minify-js:4:19a4b18a9ac79a6b8c60b24af4668814 */
+}
+</script><!-- Served in 0.038 secs. -->
+ </body>
+</html>
diff --git a/ref/GCC_Cross-Compiler.html b/ref/GCC_Cross-Compiler.html
new file mode 100644
index 0000000..6752ffc
--- /dev/null
+++ b/ref/GCC_Cross-Compiler.html
@@ -0,0 +1,860 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr" class="client-nojs">
+<head>
+<title>GCC Cross-Compiler - OSDev Wiki</title>
+<meta charset="UTF-8" />
+<meta name="generator" content="MediaWiki 1.18.0" />
+<link rel="shortcut icon" href="/favicon.ico" />
+<link rel="search" type="application/opensearchdescription+xml" href="/opensearch_desc.php" title="OSDev Wiki (en)" />
+<link rel="EditURI" type="application/rsd+xml" href="https://wiki.osdev.org/api.php?action=rsd" />
+<link rel="alternate" type="application/atom+xml" title="OSDev Wiki Atom feed" href="/index.php?title=Special:RecentChanges&amp;feed=atom" />
+<link rel="stylesheet" href="/load.php?debug=false&amp;lang=en&amp;modules=mediawiki.legacy.commonPrint%2Cshared%7Cskins.vector&amp;only=styles&amp;skin=vector&amp;*" />
+<meta name="ResourceLoaderDynamicStyles" content="" />
+<link rel="stylesheet" href="/load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=styles&amp;skin=vector&amp;*" />
+<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}a.new,#quickbar a.new{color:#ba0000}
+
+/* cache key: wikidb:resourceloader:filter:minify-css:4:c88e2bcd56513749bec09a7e29cb3ffa */
+</style>
+<script src="/load.php?debug=false&amp;lang=en&amp;modules=startup&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.config.set({"wgCanonicalNamespace": "", "wgCanonicalSpecialPageName": false, "wgNamespaceNumber": 0, "wgPageName": "GCC_Cross-Compiler", "wgTitle": "GCC Cross-Compiler", "wgCurRevisionId": 22847, "wgArticleId": 1448, "wgIsArticle": true, "wgAction": "view", "wgUserName": null, "wgUserGroups": ["*"], "wgCategories": ["Articles Written in First Person", "Level 1 Tutorials", "Compilers", "Tutorials"], "wgBreakFrames": false, "wgRestrictionEdit": [], "wgRestrictionMove": []});
+}
+</script><script>if(window.mw){
+ mw.loader.load(["mediawiki.page.startup"]);
+}
+</script>
+<style type="text/css">/*<![CDATA[*/
+.source-bash {line-height: normal;}
+.source-bash li, .source-bash pre {
+ line-height: normal; border: 0px none white;
+}
+/**
+ * GeSHi Dynamically Generated Stylesheet
+ * --------------------------------------
+ * Dynamically generated stylesheet for bash
+ * CSS class: source-bash, CSS id:
+ * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
+ * (http://qbnz.com/highlighter/ and http://geshi.org/)
+ * --------------------------------------
+ */
+.bash.source-bash .de1, .bash.source-bash .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
+.bash.source-bash {font-family:monospace;}
+.bash.source-bash .imp {font-weight: bold; color: red;}
+.bash.source-bash li, .bash.source-bash .li1 {font-weight: normal; vertical-align:top;}
+.bash.source-bash .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
+.bash.source-bash .li2 {font-weight: bold; vertical-align:top;}
+.bash.source-bash .kw1 {color: #000000; font-weight: bold;}
+.bash.source-bash .kw2 {color: #c20cb9; font-weight: bold;}
+.bash.source-bash .kw3 {color: #7a0874; font-weight: bold;}
+.bash.source-bash .co0 {color: #666666; font-style: italic;}
+.bash.source-bash .co1 {color: #800000;}
+.bash.source-bash .co2 {color: #cc0000; font-style: italic;}
+.bash.source-bash .co3 {color: #000000; font-weight: bold;}
+.bash.source-bash .co4 {color: #666666;}
+.bash.source-bash .es1 {color: #000099; font-weight: bold;}
+.bash.source-bash .es2 {color: #007800;}
+.bash.source-bash .es3 {color: #007800;}
+.bash.source-bash .es4 {color: #007800;}
+.bash.source-bash .es5 {color: #780078;}
+.bash.source-bash .es_h {color: #000099; font-weight: bold;}
+.bash.source-bash .br0 {color: #7a0874; font-weight: bold;}
+.bash.source-bash .sy0 {color: #000000; font-weight: bold;}
+.bash.source-bash .st0 {color: #ff0000;}
+.bash.source-bash .st_h {color: #ff0000;}
+.bash.source-bash .nu0 {color: #000000;}
+.bash.source-bash .re0 {color: #007800;}
+.bash.source-bash .re1 {color: #007800;}
+.bash.source-bash .re2 {color: #007800;}
+.bash.source-bash .re4 {color: #007800;}
+.bash.source-bash .re5 {color: #660033;}
+.bash.source-bash .ln-xtra, .bash.source-bash li.ln-xtra, .bash.source-bash div.ln-xtra {background-color: #ffc;}
+.bash.source-bash span.xtra { display:block; }
+
+/*]]>*/
+</style>
+<style type="text/css">/*<![CDATA[*/
+@import "/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
+/*]]>*/
+</style><style type="text/css">/*<![CDATA[*/
+.source-make {line-height: normal;}
+.source-make li, .source-make pre {
+ line-height: normal; border: 0px none white;
+}
+/**
+ * GeSHi Dynamically Generated Stylesheet
+ * --------------------------------------
+ * Dynamically generated stylesheet for make
+ * CSS class: source-make, CSS id:
+ * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
+ * (http://qbnz.com/highlighter/ and http://geshi.org/)
+ * --------------------------------------
+ */
+.make.source-make .de1, .make.source-make .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
+.make.source-make {font-family:monospace;}
+.make.source-make .imp {font-weight: bold; color: red;}
+.make.source-make li, .make.source-make .li1 {font-weight: normal; vertical-align:top;}
+.make.source-make .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
+.make.source-make .li2 {font-weight: bold; vertical-align:top;}
+.make.source-make .kw1 {color: #666622; font-weight: bold;}
+.make.source-make .kw2 {color: #990000;}
+.make.source-make .co1 {color: #339900; font-style: italic;}
+.make.source-make .co2 {color: #000099; font-weight: bold;}
+.make.source-make .es0 {color: #000099; font-weight: bold;}
+.make.source-make .br0 {color: #004400;}
+.make.source-make .sy0 {color: #004400;}
+.make.source-make .st0 {color: #CC2200;}
+.make.source-make .nu0 {color: #CC2200;}
+.make.source-make .re0 {color: #000088; font-weight: bold;}
+.make.source-make .re1 {color: #0000CC; font-weight: bold;}
+.make.source-make .re2 {color: #000088;}
+.make.source-make .ln-xtra, .make.source-make li.ln-xtra, .make.source-make div.ln-xtra {background-color: #ffc;}
+.make.source-make span.xtra { display:block; }
+
+/*]]>*/
+</style>
+<style type="text/css">/*<![CDATA[*/
+@import "/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
+/*]]>*/
+</style><style type="text/css">/*<![CDATA[*/
+.source-text {line-height: normal;}
+.source-text li, .source-text pre {
+ line-height: normal; border: 0px none white;
+}
+/**
+ * GeSHi Dynamically Generated Stylesheet
+ * --------------------------------------
+ * Dynamically generated stylesheet for text
+ * CSS class: source-text, CSS id:
+ * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
+ * (http://qbnz.com/highlighter/ and http://geshi.org/)
+ * --------------------------------------
+ */
+.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
+.text.source-text {font-family:monospace;}
+.text.source-text .imp {font-weight: bold; color: red;}
+.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
+.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
+.text.source-text .li2 {font-weight: bold; vertical-align:top;}
+.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
+.text.source-text span.xtra { display:block; }
+
+/*]]>*/
+</style>
+<style type="text/css">/*<![CDATA[*/
+@import "/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
+/*]]>*/
+</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/skins/vector/csshover.min.htc")}</style><![endif]--></head>
+<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-GCC_Cross-Compiler action-view skin-vector">
+ <div id="mw-page-base" class="noprint"></div>
+ <div id="mw-head-base" class="noprint"></div>
+ <!-- content -->
+ <div id="content">
+ <a id="top"></a>
+ <div id="mw-js-message" style="display:none;"></div>
+ <!-- firstHeading -->
+ <h1 id="firstHeading" class="firstHeading">GCC Cross-Compiler</h1>
+ <!-- /firstHeading -->
+ <!-- bodyContent -->
+ <div id="bodyContent">
+ <!-- tagline -->
+ <div id="siteSub">From OSDev Wiki</div>
+ <!-- /tagline -->
+ <!-- subtitle -->
+ <div id="contentSub"></div>
+ <!-- /subtitle -->
+ <!-- jumpto -->
+ <div id="jump-to-nav">
+ Jump to: <a href="#mw-head">navigation</a>,
+ <a href="#p-search">search</a>
+ </div>
+ <!-- /jumpto -->
+ <!-- bodycontent -->
+ <div lang="en" dir="ltr" class="mw-content-ltr"><center>
+<table style="border: 1px solid #cfcfbf; margin-top: 25px; margin-bottom: 25px; background-color: #f0f0ff; text-align: center;">
+<tr>
+<td>
+<p>This page or section refers to its readers or editors using <i>I</i>, <i>my</i>, <i>we</i> or <i>us</i>. It should be <a rel="nofollow" class="external text" href="https://wiki.osdev.org/index.php?title=GCC_Cross-Compiler&amp;action=edit">edited</a> to be in an encyclopedic tone.
+</p>
+</td></tr></table>
+</center><table style="font-size:95%; line-height:1.5em; padding:0.25em; float:right; margin: 0 0 8px 15px; clear:right; border:1px solid #aaaaaa; background:#eee; text-align:center;;"><tr><th>Difficulty level</th></tr><tr><td><a href="/File:Difficulty_1.png" class="image"><img alt="Difficulty 1.png" src="/images/d/d3/Difficulty_1.png" width="46" height="14" /></a><br />Beginner</td></tr></table>
+<p>In this tutorial we will create a GCC cross-compiler for your own operating system. This compiler is specially made to target exactly your operating system and is what allows you to leave the current operating system behind. You <i>need</i> a cross-compiler for operating systems development, unless you are developing on your own operating system.
+</p>
+<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
+<ul>
+<li class="toclevel-1 tocsection-1"><a href="#Introduction"><span class="tocnumber">1</span> <span class="toctext">Introduction</span></a>
+<ul>
+<li class="toclevel-2 tocsection-2"><a href="#Why_do_I_need_a_Cross_Compiler.3F"><span class="tocnumber">1.1</span> <span class="toctext">Why do I need a Cross Compiler?</span></a></li>
+<li class="toclevel-2 tocsection-3"><a href="#Which_compiler_version_do_I_want.3F"><span class="tocnumber">1.2</span> <span class="toctext">Which compiler version do I want?</span></a></li>
+<li class="toclevel-2 tocsection-4"><a href="#Which_Binutils_version_do_I_want.3F"><span class="tocnumber">1.3</span> <span class="toctext">Which Binutils version do I want?</span></a></li>
+<li class="toclevel-2 tocsection-5"><a href="#Deciding_on_the_target_platform"><span class="tocnumber">1.4</span> <span class="toctext">Deciding on the target platform</span></a></li>
+</ul>
+</li>
+<li class="toclevel-1 tocsection-6"><a href="#Preparing_for_the_build"><span class="tocnumber">2</span> <span class="toctext">Preparing for the build</span></a>
+<ul>
+<li class="toclevel-2"><a href="#Installing_Dependencies"><span class="tocnumber">2.1</span> <span class="toctext">Installing Dependencies</span></a></li>
+<li class="toclevel-2"><a href="#Downloading_the_Source_Code"><span class="tocnumber">2.2</span> <span class="toctext">Downloading the Source Code</span></a></li>
+<li class="toclevel-2"><a href="#Linux_Users_building_a_System_Compiler"><span class="tocnumber">2.3</span> <span class="toctext">Linux Users building a System Compiler</span></a></li>
+<li class="toclevel-2"><a href="#Gentoo_Users"><span class="tocnumber">2.4</span> <span class="toctext">Gentoo Users</span></a></li>
+<li class="toclevel-2"><a href="#macOS_Users"><span class="tocnumber">2.5</span> <span class="toctext">macOS Users</span></a></li>
+<li class="toclevel-2"><a href="#Windows_Users"><span class="tocnumber">2.6</span> <span class="toctext">Windows Users</span></a></li>
+</ul>
+</li>
+<li class="toclevel-1 tocsection-7"><a href="#The_Build"><span class="tocnumber">3</span> <span class="toctext">The Build</span></a>
+<ul>
+<li class="toclevel-2 tocsection-8"><a href="#Preparation"><span class="tocnumber">3.1</span> <span class="toctext">Preparation</span></a></li>
+<li class="toclevel-2 tocsection-9"><a href="#Binutils"><span class="tocnumber">3.2</span> <span class="toctext">Binutils</span></a></li>
+<li class="toclevel-2 tocsection-10"><a href="#GCC"><span class="tocnumber">3.3</span> <span class="toctext">GCC</span></a></li>
+</ul>
+</li>
+<li class="toclevel-1 tocsection-11"><a href="#Using_the_new_Compiler"><span class="tocnumber">4</span> <span class="toctext">Using the new Compiler</span></a></li>
+<li class="toclevel-1 tocsection-12"><a href="#Troubleshooting"><span class="tocnumber">5</span> <span class="toctext">Troubleshooting</span></a>
+<ul>
+<li class="toclevel-2 tocsection-13"><a href="#ld:_cannot_find_-lgcc"><span class="tocnumber">5.1</span> <span class="toctext">ld: cannot find -lgcc</span></a></li>
+<li class="toclevel-2 tocsection-14"><a href="#Binutils_2.9"><span class="tocnumber">5.2</span> <span class="toctext">Binutils 2.9</span></a></li>
+</ul>
+</li>
+<li class="toclevel-1 tocsection-15"><a href="#See_Also"><span class="tocnumber">6</span> <span class="toctext">See Also</span></a>
+<ul>
+<li class="toclevel-2 tocsection-16"><a href="#Articles"><span class="tocnumber">6.1</span> <span class="toctext">Articles</span></a></li>
+<li class="toclevel-2 tocsection-17"><a href="#External_Links"><span class="tocnumber">6.2</span> <span class="toctext">External Links</span></a></li>
+<li class="toclevel-2 tocsection-18"><a href="#Prebuilt_Toolchains"><span class="tocnumber">6.3</span> <span class="toctext">Prebuilt Toolchains</span></a></li>
+</ul>
+</li>
+</ul>
+</td></tr></table>
+<h2> <span class="mw-headline" id="Introduction"> Introduction </span></h2>
+<p>Generally speaking, a cross-compiler is a compiler that runs on platform A (the <b>host</b>), but generates executables for platform B (the <b>target</b>). These two platforms may (but do not need to) differ in CPU, operating system, and/or <a href="/Category:Executable_Formats" title="Category:Executable Formats">executable format</a>. In our case, the host platform is your current operating system, and the target platform is the operating system you are about to make. It is important to realize that these two platforms are not the same; your operating system is always going to be different from your current operating system. This is why we need to build a cross-compiler first, you will most certainly run into trouble otherwise.
+</p>
+<h3> <span class="mw-headline" id="Why_do_I_need_a_Cross_Compiler.3F"> Why do I need a Cross Compiler? </span></h3>
+<dl><dd><i>Main article:</i> <a href="/Why_do_I_need_a_Cross_Compiler%3F" title="Why do I need a Cross Compiler?">Why do I need a Cross Compiler?</a>
+</dd></dl>
+<p>You need to use a cross-compiler <i>unless</i> you are developing on your own operating system. The compiler must know the correct target platform (CPU, operating system), otherwise you will run into trouble. If you use the compiler that comes with your system, then the compiler won't know it is compiling something else entirely. Some tutorials suggest using your system compiler and passing a lot of problematic options to the compiler. This will certainly give you a lot of problems in the future and the solution is build a cross-compiler. If you have already attempted to make an operating system without using a cross-compiler, please read the article <a href="/Why_do_I_need_a_Cross_Compiler%3F" title="Why do I need a Cross Compiler?">Why do I need a Cross Compiler?</a>.
+</p>
+<h3> <span class="mw-headline" id="Which_compiler_version_do_I_want.3F"> Which compiler version do I want? </span></h3>
+<dl><dd><i>Main article:</i> <a href="/Building_GCC" title="Building GCC">Building GCC</a>
+</dd></dl>
+<p>The newest <a href="/GCC" title="GCC">GCC</a> is recommended as it is the latest and greatest release. For instance, you may run into trouble if you use GCC 4.6.3 to build a GCC 4.8.0 cross-compiler. If you are not using the latest major GCC release for your system compiler, we recommend that you <a href="/Building_GCC" title="Building GCC">build the newest GCC as your system compiler</a>.
+</p><p>You can also use older releases as they are usually reasonably good. If your local system compiler isn't too terribly old (at least GCC 4.6.0), you may wish to save yourself the trouble and just pick the latest minor release (such as 4.6.3 if your system compiler is 4.6.1) for your cross-compiler.
+</p><p>You can view your current compiler version by invoking:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw2">gcc</span> <span class="re5">--version</span></pre></div></div>
+<p>You may be able to use an older major GCC release to build a cross-compiler of a newer major GCC release. For instance, GCC 4.7.3 may be able to build a GCC 4.8.0 cross-compiler. However, if you want to use the latest and greatest GCC version for your cross-compiler, we recommend that you <a href="/Building_GCC" title="Building GCC">bootstrap the newest GCC</a> as your system compiler first. Individuals using OS X 10.7 or earlier might want to invest in either building a system GCC (that outputs native Mach-O), or upgrading the local LLVM/Clang installation. Users with 10.8 and above should install the Command Line Tools from Apple's developer website and use Clang to cross-compile GCC.
+</p>
+<h3> <span class="mw-headline" id="Which_Binutils_version_do_I_want.3F"> Which Binutils version do I want? </span></h3>
+<dl><dd><i>Main article:</i> <a href="/Cross-Compiler_Successful_Builds" title="Cross-Compiler Successful Builds">Cross-Compiler Successful Builds</a>
+</dd></dl>
+<p>We recommend that you use the latest and greatest <a href="/Binutils" title="Binutils">Binutils</a> release. Note, however, that not all combinations of GCC and Binutils work. If you run into trouble, use a Binutils that was released at roughly the same time as your desired compiler version. You probably need at least Binutils 2.22, or preferably the latest 2.23.2 release. It doesn't matter what Binutils version you have installed on your current operating system.
+</p>
+<h3> <span class="mw-headline" id="Deciding_on_the_target_platform"> Deciding on the target platform </span></h3>
+<dl><dd><i>Main article:</i> <a href="/Target_Triplet" title="Target Triplet">Target Triplet</a>
+</dd></dl>
+<p>You should already know this. If you are following the <a href="/Bare_Bones" title="Bare Bones">Bare Bones</a> tutorial, you wish to build a cross-compiler for <tt>i686-elf</tt>.
+</p>
+<h2> <span class="mw-headline" id="Preparing_for_the_build"> Preparing for the build </span></h2><table style="font-size:95%; line-height:1.5em; padding:0.25em; float:right; margin: 0 0 8px 15px; clear:right; border:1px solid #aaaaaa; background:#eee; text-align:center;;"><tr><th>Difficulty level</th></tr><tr><td><a href="/File:Difficulty_1.png" class="image"><img alt="Difficulty 1.png" src="/images/d/d3/Difficulty_1.png" width="46" height="14" /></a><br />Beginner</td></tr></table>
+<p><br />
+</p><p>The GNU Compiler Collection is an advanced piece of software with dependencies. You need the following the following in order to build GCC:
+</p>
+<ul><li> A Unix-like environment (Windows users can use the Windows Subsystem for Linux or Cygwin)
+</li><li> Enough memory and hard disk space (it depends, 256 MiB will not be enough).
+</li><li> GCC (existing release you wish to replace), or another system C compiler
+</li><li> G++ (if building a version of GCC &gt;= 4.8.0), or another system C++ compiler
+</li><li> Make
+</li><li> Bison
+</li><li> Flex
+</li><li> GMP
+</li><li> MPFR
+</li><li> MPC
+</li><li> Texinfo
+</li><li> ISL (optional)
+</li><li> CLooG (optional)
+</li></ul>
+<h3> <span class="mw-headline" id="Installing_Dependencies"> Installing Dependencies </span></h3>
+<table border="2" cellpadding="4" cellspacing="0" style="margin-top:1em; margin-bottom:1em; background:#f9f9f9; border:1px #aaa solid; border-collapse:collapse; &#123;&#123;&#123;1}}}">
+
+<tr>
+<th> &#8595; Dependency / OS &#8594;
+</th>
+<td> Source Code
+</td>
+<td> Debian (Ubuntu, Mint, WSL, ...)
+</td>
+<td> Gentoo
+</td>
+<td> Fedora
+</td>
+<td> Cygwin
+</td>
+<td> OpenBSD
+</td></tr>
+<tr>
+<td>How to install
+</td>
+<td>Normally
+</td>
+<td><b><tt>sudo apt install</tt> <i>foo</i></b>
+</td>
+<td>?
+</td>
+<td><b><tt>sudo dnf install</tt> <i>foo</i></b>
+</td>
+<td>Cygwin GUI setup
+</td>
+<td><b><tt>doas pkg_add</tt> <i>foo</i></b>
+</td></tr>
+<tr>
+<td>Compiler
+</td>
+<td>N/A
+</td>
+<td><b><tt>build-essential</tt></b>
+</td>
+<td>?
+</td>
+<td><b><tt>gcc gcc-c++</tt></b>
+</td>
+<td><b><tt>mingw64-x86_64-gcc-g++</tt></b> / <b><tt>mingw64-i686-gcc-g++</tt></b>
+</td>
+<td>Preinstalled
+</td></tr>
+<tr>
+<td>Make
+</td>
+<td>N/A
+</td>
+<td><b><tt>build-essential</tt></b>
+</td>
+<td>?
+</td>
+<td><b><tt>make</tt></b>
+</td>
+<td><b><tt>make</tt></b>
+</td>
+<td>Preinstalled
+</td></tr>
+<tr>
+<td><a rel="nofollow" class="external text" href="https://www.gnu.org/software/bison/">Bison</a>
+</td>
+<td><a rel="nofollow" class="external autonumber" href="https://ftp.gnu.org/gnu/bison/">[1]</a>
+</td>
+<td><b><tt>bison</tt></b>
+</td>
+<td>?
+</td>
+<td><b><tt>bison</tt></b>
+</td>
+<td><b><tt>bison</tt></b>
+</td>
+<td>?
+</td></tr>
+<tr>
+<td><a rel="nofollow" class="external text" href="https://github.com/westes/flex">Flex</a>
+</td>
+<td><a rel="nofollow" class="external autonumber" href="https://github.com/westes/flex/releases">[2]</a>
+</td>
+<td><b><tt>flex</tt></b>
+</td>
+<td>?
+</td>
+<td><b><tt>flex</tt></b>
+</td>
+<td><b><tt>flex</tt></b>
+</td>
+<td>?
+</td></tr>
+<tr>
+<td><a rel="nofollow" class="external text" href="https://gmplib.org/">GMP</a>
+</td>
+<td><a rel="nofollow" class="external autonumber" href="https://ftp.gnu.org/gnu/gmp/">[3]</a>
+</td>
+<td><b><tt>libgmp3-dev</tt></b>
+</td>
+<td><b><tt>dev-libs/gmp</tt></b>
+</td>
+<td><b><tt>gmp-devel</tt></b>
+</td>
+<td><b><tt>libgmp-devel</tt></b>
+</td>
+<td><b><tt>gmp</tt></b>
+</td></tr>
+<tr>
+<td>MPC
+</td>
+<td><a rel="nofollow" class="external autonumber" href="https://ftp.gnu.org/gnu/mpc/">[4]</a>
+</td>
+<td><b><tt>libmpc-dev</tt></b>
+</td>
+<td><b><tt>dev-libs/mpc</tt></b>
+</td>
+<td><b><tt>libmpc-devel</tt></b>
+</td>
+<td><b><tt>libmpc-devel</tt></b>
+</td>
+<td><b><tt>libmpc</tt></b>
+</td></tr>
+<tr>
+<td><a rel="nofollow" class="external text" href="https://www.mpfr.org/">MPFR</a>
+</td>
+<td><a rel="nofollow" class="external autonumber" href="https://ftp.gnu.org/gnu/mpfr/">[5]</a>
+</td>
+<td><b><tt>libmpfr-dev</tt></b>
+</td>
+<td><b><tt>dev-libs/mpfr</tt></b>
+</td>
+<td><b><tt>mpfr-devel</tt></b>
+</td>
+<td><b><tt>libmpfr-devel</tt></b>
+</td>
+<td><b><tt>mpfr</tt></b>
+</td></tr>
+<tr>
+<td><a rel="nofollow" class="external text" href="https://www.gnu.org/software/texinfo/">Texinfo</a>
+</td>
+<td><a rel="nofollow" class="external autonumber" href="https://ftp.gnu.org/gnu/texinfo/">[6]</a>
+</td>
+<td><b><tt>texinfo</tt></b>
+</td>
+<td>?
+</td>
+<td><b><tt>texinfo</tt></b>
+</td>
+<td><b><tt>texinfo</tt></b>
+</td>
+<td><b><tt>texinfo</tt></b>
+</td></tr>
+<tr>
+<td><a rel="nofollow" class="external text" href="https://www.cloog.org/">CLooG</a> (Optional)
+</td>
+<td><a rel="nofollow" class="external text" href="https://www.cloog.org/">CLooG</a>
+</td>
+<td><b><tt>libcloog-isl-dev</tt></b>
+</td>
+<td>?
+</td>
+<td>?
+</td>
+<td><b><tt>libcloog-isl-devel</tt></b>
+</td>
+<td>N/A
+</td></tr>
+<tr>
+<td><a rel="nofollow" class="external text" href="http://isl.gforge.inria.fr/">ISL</a> (Optional)
+</td>
+<td><a rel="nofollow" class="external autonumber" href="http://isl.gforge.inria.fr/">[7]</a>
+</td>
+<td><b><tt>libisl-dev</tt></b>
+</td>
+<td>?
+</td>
+<td>?
+</td>
+<td><b><tt>libisl-devel</tt></b>
+</td>
+<td>N/A
+</td></tr></table>
+<p>You need to have Texinfo installed to build Binutils. You need to have GMP, MPC, and MPFR installed to build GCC. GCC optionally can make use of the CLooG and ISL libraries.
+</p><p>For instance, you can install <b><tt>libgmp3-dev</tt></b> on Debian by running the shell command: <b><tt>sudo apt install libgmp3-dev</tt></b>
+</p><p><b>Note:</b> Version 5.x (or later) of Texinfo is known to be incompatible with the current Binutils 2.23.2 release (and older). You can check your current version using <tt>makeinfo --version</tt>. If your version is too new and you encounter problems during the build, you will need to either use Binutils 2.24 release (or newer) or install an older version of Texinfo - perhaps through building from source - and add it to your <tt>PATH</tt> prior and during the Binutils build.
+</p><p><b>Note:</b> Version 0.13 (or later) of ISL is incompatible with the current CLooG 0.18.1 release (and older). Use version 0.12.2 of ISL or the build <b>will</b> fail.
+</p>
+<h3> <span class="mw-headline" id="Downloading_the_Source_Code"> Downloading the Source Code </span></h3>
+<p>Download the needed source code into a suitable directory such as <tt>$HOME/src</tt>:
+</p>
+<ul><li> You can download the desired Binutils release by visiting the <a rel="nofollow" class="external text" href="https://gnu.org/software/binutils/">Binutils website</a> or directly accessing the <a rel="nofollow" class="external text" href="https://ftp.gnu.org/gnu/binutils/">GNU main mirror</a>.
+</li></ul>
+<ul><li> You can download the desired GCC release by visiting the <a rel="nofollow" class="external text" href="https://gnu.org/software/gcc/">GCC website</a> or directly accessing the <a rel="nofollow" class="external text" href="https://ftp.gnu.org/gnu/gcc/">GNU main mirror</a>.
+</li></ul>
+<p><b>Note:</b> The versioning scheme used is that each fullstop separates a full number, i.e. Binutils 2.20.0 is newer than 2.9.0. This may be confusing, if you have not encountered this (quite common) versioning scheme yet, when looking at an alphanumerically sorted list of tarballs: The file at the bottom of the list is not the latest version! An easy way of getting the latest version is to sort by the last modified date and scrolling to the bottom.
+</p>
+<h3> <span class="mw-headline" id="Linux_Users_building_a_System_Compiler"> Linux Users building a System Compiler </span></h3>
+<p>Your distribution may ship its own patched GCC and Binutils that is customized to work on your particular Linux distribution. You should be able to build a working cross-compiler using the above source code, but you might not be able to build a new system compiler for your current Linux distribution. In that case, try a newer GCC release or get the patched source code.
+</p>
+<h3> <span class="mw-headline" id="Gentoo_Users"> Gentoo Users </span></h3>
+<p>Gentoo lets you set up a cross-development toolchain:
+</p>
+<pre> emerge -av crossdev
+ crossdev --help
+ PORTDIR_OVERLAY="/usr/local/crossdev" crossdev --stage1 --binutils &lt;binutils-version&gt; --gcc &lt;gcc-version&gt; --target &lt;target&gt;
+</pre>
+<p>This will install a GCC cross-compiler into a "slot", i.e. alongside already-existing compiler versions. You can install several cross-compilers that way, simply by changing target designations. An unfortunate downside is that it will also pull in gentoo patches and pass additional configure options that differ from the official <strong class="selflink">GCC Cross-Compiler</strong> setup, and they might behave differently.
+</p><p>After the compilation ran, you can now use your cross-compiler by calling &lt;target&gt;-gcc. You can also use gcc-config to toggle between compiler versions should you need to do so. Don't replace your system compiler with a cross-compiler. The package manager will also suggest updates as soon as they become available.
+</p><p>You can uninstall the cross-compiler by calling <i>crossdev --clean &lt;target&gt;</i>. Read the <a rel="nofollow" class="external text" href="http://www.gentoo.org/proj/en/base/embedded/cross-development.xml">cross-development</a> document for additional information.
+</p><p>Note that the version numbers to binutils and gcc are <i>Gentoo package versions</i>, i.e. there might be a suffix to the "official" (GNU) version that addresses additional patchsets supplied by the Gentoo maintainers. (For example, <i>--binutils 2.24-r3 --gcc 4.8.3</i> is the latest stable package pair at the time of this writing.) You can omit the version numbers to use the latest package available.
+</p><p>Portage uses overlays to store packages that are not part of the original package management. Crossdev needs one overlay where it can store its binutils and gcc packages before building them. You can configure one properly, or you can use PORTDIR_OVERLAY to point at where it should keep its package manager files. Using PORTDIR_OVERLAY is not a good idea with existing overlays, but by then you should know how you have personally set them up earlier anyway and how to do it properly.
+</p>
+<h3> <span class="mw-headline" id="macOS_Users"> macOS Users </span></h3>
+<p>macOS users need a replacement libiconv because the system libiconv is seriously out of date. macOS users can download the latest libiconv release by visiting the <a rel="nofollow" class="external text" href="https://gnu.org/software/libiconv/">libiconv website</a> or directly accessing the <a rel="nofollow" class="external text" href="https://ftp.gnu.org/gnu/libiconv/">GNU main FTP mirror</a>. Otherwise you may get unresolved symbol errors related to libiconv when compiling GCC 4.3 or higher on OS X 10.4 and 10.5.
+</p><p>Install a new version (compile it yourself or use MacPorts) and add <tt>--with-libiconv-prefix=/opt/local</tt> (or <tt>/usr/local</tt> if you compiled it yourself) to GCC's <tt>./configure</tt> line. Alternatively you may place the libiconv source as gcc-x.y.z/libiconv and it will be compiled as part of the GCC compilation process. (This trick also works for MPFR, GMP, and MPC).
+</p><p>The makefiles of Binutils and GCC use the <span class="mw-geshi make source-make"><span class="sy0">$</span><span class="br0">&#40;</span><span class="re2">CC</span><span class="br0">&#41;</span></span> variable to invoke the compiler. On OS X, this resolves to <span class="mw-geshi text source-text">gcc</span> by default, which is actually <span class="mw-geshi bash source-bash">clang</span>. Prior to OS X 10.8, the Clang that came with Xcode's Command Line Tools package was not able to build a working GCC. Users running OS X 10.7 or below may need to find and install GCC, either from <a rel="nofollow" class="external text" href="http://brew.sh">Homebrew</a>, or from somewhere on Apple's website. You can try with the old GCC that comes preinstalled on some macOS versions.
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="co0"># This is only necessary for OS X users running 10.7 or below.</span>
+<span class="kw3">export</span> <span class="re2">CC</span>=<span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span>gcc-<span class="nu0">4.2</span>
+<span class="kw3">export</span> <span class="re2">CXX</span>=<span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span>g++-<span class="nu0">4.2</span>
+<span class="kw3">export</span> <span class="re2">CPP</span>=<span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span>cpp-<span class="nu0">4.2</span>
+<span class="kw3">export</span> <span class="re2">LD</span>=<span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span>gcc-<span class="nu0">4.2</span></pre></div></div>
+<p>You will want to unset these exports once you compiled and installed the cross compiler.
+</p><p><b>Note for Lion users:</b> If you're on Lion (or above) chances are that you don't have the "real" GCC since Apple removed it from the Xcode package, but you can still install it. You can do it via Homebrew or by compiling from source, both are perfectly described on <a rel="nofollow" class="external text" href="http://apple.stackexchange.com/a/38247">a StackExchange answer</a>.
+</p><p><b>Note for Maverick users:</b> You can build binutils-2.24 and gcc-4.8.3 (possible other version) with Xcode 5.1.1. Note that building GCC with LLVM is not officially supported and may cause interesting bugs, if you are willing to take this risk and save time building host-gcc just to compile a cross-gcc, follow this.
+Install GMP, MPFR, Mpc with <a rel="nofollow" class="external text" href="http://http://www.macports.org/">MacPorts</a>.
+</p>
+<pre>sudo port install gmp mpfr libmpc
+</pre>
+<pre>../binutils-2.24/configure --prefix=$PREFIX \
+--target=$TARGET \
+--enable-interwork --enable-multilib \
+--disable-nls --disable-werror
+</pre>
+<pre>../gcc-4.8.3/configure --prefix=$PREFIX \
+--target=$TARGET \
+--disable-nls \
+--enable-languages=c,c++ --without-headers \
+--enable-interwork --enable-multilib \
+--with-gmp=/usr --with-mpc=/opt/local --with-mpfr=/opt/local
+</pre>
+<p><b>Note:</b> There is an issue with port's GMP, so the version from OS X from /usr is used instead.
+</p>
+<h3> <span class="mw-headline" id="Windows_Users"> Windows Users </span></h3>
+<p>Windows users need to set up a Unix-like enviroment such as <a href="/MinGW" title="MinGW">MinGW</a> or <a href="/Cygwin" title="Cygwin">Cygwin</a>. It may well be worth looking into systems such as Linux and see if they fit your needs, as you commonly use a lot of Unix-like tools in operating systems development and this is much easier from a Unix-like operating system. <b>If you have just installed the basic <a href="/Cygwin" title="Cygwin">Cygwin</a> package, you have to run the setup.exe again and install the following packages:</b> GCC, G++, Make, Flex, Bison, Diffutils, libintl-devel, libgmp-devel, libmpfr-devel, libmpc-devel, Texinfo
+</p><p>MinGW + MSYS is an option, and as it addresses the native Windows API instead of a POSIX emulation layer, results in a slightly faster toolchain. Some software packages will not build properly under MSYS as they were not designed for use with Windows. As far as this tutorial is concerned, everything that applies to Cygwin also applies to MSYS unless otherwise specified. Make sure you install the C and C++ compilers, and the MSYS Basic System.
+</p><p>The "Windows Subsystem for Linux (Beta)", released with the Windows 10 Anniversary update is also an option for using a cross compiler. (Tested 08/08/2016 with GCC 6.1.0 and Binutils 2.27) This cross-compiler works reasonably fast, although being in beta state, it may not be ideal permanent development platform.
+</p><p><b>Cygwin note:</b> Cygwin includes your Windows <tt>%PATH%</tt> in its bash <tt>$PATH.</tt> If you were using DJGPP before, this could result in confusion as e.g. calling <tt>GCC</tt> on the Cygwin bash command line would still call the DJGPP compiler. After uninstalling DJGPP, you should delete the DJGPP environment variable and clear the <tt>C:\djgpp</tt> entry (or wherever you installed it) from your <tt>%PATH%</tt>. Likewise, it might be a bad idea to mix build environments in your system PATH variable.
+</p><p><b>MinGW note:</b> Some MinGW-specific information on building a cross-toolchain can be found on the <a rel="nofollow" class="external text" href="http://www.mingw.org/wiki/HostedCrossCompilerHOWTO">hosted cross-compiler how-to page</a> on the MinGW homepage.
+</p><p><b>Windows Subsystem for Linux (Beta) Note:</b> You cannot have your cross compiler in the /mnt/c/ (or /mnt/"x") areas, as trying to compile your cross-compiler there will generate errors, whereas building to $HOME/opt/cross works perfectly. This is fixed with Windows Update KB3176929
+</p>
+<h2> <span class="mw-headline" id="The_Build"> The Build </span></h2>
+<p>We build a toolset running on your host that can turn source code into object files for your target system.
+</p><p>You need to decide where to install your new compiler. It is dangerous and a very bad idea to install it into system directories. You also need to decide whether the new compiler should be installed globally or just for you. If you want to install it just for you (recommended), installing into <tt>$HOME/opt/cross</tt> is normally a good idea. If you want to install it globally, installing it into <tt>/usr/local/cross</tt> is normally a good idea.
+</p><p>Please note that we build everything out of the source directory tree, as is considered good practice. Some packages only support building outside, some only inside and some both (but may not offer extensive checking with make). Building GCC inside the source directory tree fails miserably, at least for older versions.
+</p>
+<h3> <span class="mw-headline" id="Preparation"> Preparation </span></h3>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw3">export</span> <span class="re2">PREFIX</span>=<span class="st0">&quot;<span class="es2">$HOME</span>/opt/cross&quot;</span>
+<span class="kw3">export</span> <span class="re2">TARGET</span>=i686-elf
+<span class="kw3">export</span> <span class="re2">PATH</span>=<span class="st0">&quot;<span class="es2">$PREFIX</span>/bin:<span class="es2">$PATH</span>&quot;</span></pre></div></div>
+<p>We add the installation prefix to the <tt>PATH</tt> of the current shell session. This ensures that the compiler build is able to detect our new binutils once we have built them.
+</p><p>The prefix will configure the build process so that all the files of your cross-compiler environment end up in $HOME/opt/cross. You can change that prefix to whatever you like (e.g., /opt/cross or $HOME/cross would be options). If you have administrator access and wish to make the cross-compiler toolchain available to all users, you can install it into the /usr/local prefix - or perhaps a /usr/local/cross prefix if you are willing to change the system configuration such that this directory is in the search paths for all users. Technically, you could even install directly to /usr, so that your cross-compiler would reside alongside your system compiler, but that is not recommended for several reasons (like risking to overwrite your system compiler if you get TARGET wrong, or getting into conflict with your system's package management).
+</p>
+<h3> <span class="mw-headline" id="Binutils"> Binutils </span></h3>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw3">cd</span> <span class="re1">$HOME</span><span class="sy0">/</span>src
+&#160;
+<span class="kw2">mkdir</span> build-binutils
+<span class="kw3">cd</span> build-binutils
+..<span class="sy0">/</span>binutils-x.y.z<span class="sy0">/</span>configure <span class="re5">--target</span>=<span class="re1">$TARGET</span> <span class="re5">--prefix</span>=<span class="st0">&quot;<span class="es2">$PREFIX</span>&quot;</span> <span class="re5">--with-sysroot</span> <span class="re5">--disable-nls</span> <span class="re5">--disable-werror</span>
+<span class="kw2">make</span>
+<span class="kw2">make</span> <span class="kw2">install</span></pre></div></div>
+<p>This compiles the binutils (assembler, disassembler, and various other useful stuff), runnable on your system but handling code in the format specified by $TARGET.
+</p><p><b>--disable-nls</b> tells binutils not to include native language support. This is basically optional, but reduces dependencies and compile time. It will also result in English-language diagnostics, which the people on the <a rel="nofollow" class="external text" href="http://forum.osdev.org/">Forum</a> understand when you ask your questions.&#160;;-)
+</p><p><b>--with-sysroot</b> tells binutils to enable sysroot support in the cross-compiler by pointing it to a default empty directory. By default, the linker refuses to use sysroots for no good technical reason, while gcc is able to handle both cases at runtime. This will be useful later on.
+</p>
+<h3> <span class="mw-headline" id="GCC"> GCC </span></h3>
+<dl><dd><i>See also the <a rel="nofollow" class="external text" href="http://gcc.gnu.org/install/configure.html">offical instructions for configuring gcc</a>.</i>
+</dd></dl>
+<p>Now, you can build <a href="/GCC" title="GCC">GCC</a>.
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw3">cd</span> <span class="re1">$HOME</span><span class="sy0">/</span>src
+&#160;
+<span class="co0"># The $PREFIX/bin dir _must_ be in the PATH. We did that above.</span>
+<span class="kw2">which</span> <span class="re5">--</span> <span class="re1">$TARGET</span>-as <span class="sy0">||</span> <span class="kw3">echo</span> <span class="re1">$TARGET</span>-as is not <span class="kw1">in</span> the PATH
+&#160;
+<span class="kw2">mkdir</span> build-gcc
+<span class="kw3">cd</span> build-gcc
+..<span class="sy0">/</span>gcc-x.y.z<span class="sy0">/</span>configure <span class="re5">--target</span>=<span class="re1">$TARGET</span> <span class="re5">--prefix</span>=<span class="st0">&quot;<span class="es2">$PREFIX</span>&quot;</span> <span class="re5">--disable-nls</span> <span class="re5">--enable-languages</span>=c,<span class="kw2">c++</span> <span class="re5">--without-headers</span>
+<span class="kw2">make</span> all-gcc
+<span class="kw2">make</span> all-target-libgcc
+<span class="kw2">make</span> install-gcc
+<span class="kw2">make</span> install-target-libgcc</pre></div></div>
+<p>We build <a href="/Libgcc" title="Libgcc">libgcc</a>, a low-level support library that the compiler expects available at compile time. Linking against <a href="/Libgcc" title="Libgcc">libgcc</a> provides integer, floating point, decimal, stack unwinding (useful for exception handling) and other support functions. Note how we are <i>not</i> simply running <tt>make &amp;&amp; make install</tt> as that would build way too much, not all components of gcc are ready to target your unfinished operating system.
+</p><p><b>--disable-nls</b> is the same as for binutils above.
+</p><p><b>--without-headers</b> tells <a href="/GCC" title="GCC">GCC</a> not to rely on any C library (standard or runtime) being present for the target.
+</p><p><b>--enable-languages</b> tells <a href="/GCC" title="GCC">GCC</a> not to compile all the other language frontends it supports, but only C (and optionally C++).
+</p><p>It will take a while to build your cross-compiler.
+</p><p>If you are building a cross compiler for x86-64, you may want to consider building Libgcc without the "red zone": <a href="/Libgcc_without_red_zone" title="Libgcc without red zone">Libgcc_without_red_zone</a>
+</p>
+<h2> <span class="mw-headline" id="Using_the_new_Compiler"> Using the new Compiler </span></h2>
+<p>Now you have a "naked" cross-compiler. It does not have access to a C library or C runtime yet, so you cannot use any of the standard includes or create runnable binaries. But it is quite sufficient to compile the kernel you will be making shortly. Your toolset resides in $HOME/opt/cross (or what you set <tt>$PREFIX</tt> to). For example, you have a GCC executable installed as <tt>$HOME/opt/cross/bin/$TARGET-gcc</tt>, which creates programs for your TARGET.
+</p><p>You can now run your new compiler by invoking something like:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="co4">$</span>HOME<span class="sy0">/</span>opt<span class="sy0">/</span>cross<span class="sy0">/</span>bin<span class="sy0">/</span><span class="re1">$TARGET</span>-gcc <span class="re5">--version</span></pre></div></div>
+<p>Note how this compiler is <i>not</i> able to compile normal C programs. The cross-compiler will spit errors whenever you want to #include any of the standard headers (except for a select few that actually are platform-independent, and generated by the compiler itself). This is quite correct - you don't have a standard library for the target system yet!
+</p><p>The C standard defines two different kinds of executing environments - "freestanding" and "hosted". While the definition might be rather fuzzy for the average application programmer, it is pretty clear-cut when you're doing OS development: A kernel is "freestanding", everything you do in user space is "hosted". A "freestanding" environment needs to provide only a subset of the C library: float.h, iso646.h, limits.h, stdalign.h, stdarg.h, stdbool.h, stddef.h, stdint.h and stdnoreturn.h (as of C11). All of these consist of typedef s and #define s "only", so you can implement them without a single .c file in sight.
+</p><p>To use your new compiler simply by invoking <tt>$TARGET-gcc</tt>, add <tt>$HOME/opt/cross/bin</tt> to your <tt>$PATH</tt> by typing:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw3">export</span> <span class="re2">PATH</span>=<span class="st0">&quot;<span class="es2">$HOME</span>/opt/cross/bin:<span class="es2">$PATH</span>&quot;</span></pre></div></div>
+<p>This command will add your new compiler to your PATH for this shell session. If you wish to use it permanently, add the PATH command to your <tt>~/.profile</tt> configuration shell script or similar. Consult your shell documentation for more information.
+</p><p>You can now move on to complete the <a href="/Bare_Bones" title="Bare Bones">Bare Bones</a> tutorial variant that lead you here and complete it using your new cross-compiler. If you built a new GCC version as your system compiler and used it to build the cross-compiler, you can now safely uninstall it unless you wish to continue using it.
+</p>
+<h2> <span class="mw-headline" id="Troubleshooting"> Troubleshooting </span></h2>
+<p>In general, <b>verify</b> that you read the instructions carefully and typed the commands precisely. Don't skip instructions. You will have to set your PATH variable again if you use a new shell instance, if you don't make it permanent by adding it to your shell profile. If a compilation seems to have gotten really messed up, type <tt>make distclean</tt>, and then start the make process over again. Ensure your un-archiever doesn't change newline characters.
+</p>
+<h4> <span class="mw-headline" id="ld:_cannot_find_-lgcc"> ld: cannot find -lgcc </span></h4>
+<p>You specified that you want to link the GCC low-level runtime library into your executable through the <tt>-lgcc</tt>' switch, but forgot to build and properly install the library.
+</p>
+<h4> <span class="mw-headline" id="Binutils_2.9"> Binutils 2.9 </span></h4>
+<p>What's alphabetically on the top or bottom is not necessarily the latest version. After 2.9 comes 2.10, 2.11, 2.12 and then there are fifteen more releases that are all newer and progressively more likely to build or support your choice of GCC version.
+</p>
+<h2> <span class="mw-headline" id="See_Also"> See Also </span></h2>
+<h3> <span class="mw-headline" id="Articles"> Articles </span></h3>
+<ul><li><a href="/Cross-Compiler_Successful_Builds" title="Cross-Compiler Successful Builds">Cross-Compiler Successful Builds</a> - combinations of GCC and Binutils which have been shown to work with this tutorial by OSDev.org members.
+</li><li><a href="/Target_Triplet" title="Target Triplet">Target Triplet</a> - on target triplets and their use
+</li><li><a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a> - going a step further and adding your own target.
+</li><li><a href="/LLVM_Cross-Compiler" title="LLVM Cross-Compiler">LLVM Cross-Compiler</a> - some compilers make things much easier.
+</li><li><a href="/Canadian_Cross" title="Canadian Cross" class="mw-redirect">Canadian Cross</a> - making things yet more complicated.
+</li></ul>
+<h3> <span class="mw-headline" id="External_Links"> External Links </span></h3>
+<ul><li><a rel="nofollow" class="external free" href="http://kegel.com/crosstool">http://kegel.com/crosstool</a> has a popular example of a script that automatically downloads, patches, and builds binutils, gcc, and glibc for known platforms.
+</li><li><a rel="nofollow" class="external free" href="http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html">http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html</a> - Summary of the support functions you get when you link with libgcc.
+</li><li><a rel="nofollow" class="external free" href="http://forums.gentoo.org/viewtopic.php?t=66125">http://forums.gentoo.org/viewtopic.php?t=66125</a> - Compiling Windows applications under Linux
+</li><li><a rel="nofollow" class="external free" href="http://www.libsdl.org/extras/win32/cross/README.txt">http://www.libsdl.org/extras/win32/cross/README.txt</a> - dito
+</li><li><a rel="nofollow" class="external free" href="https://github.com/travisg/toolchains">https://github.com/travisg/toolchains</a> - Another script for building simple cross compilers
+</li><li><a rel="nofollow" class="external free" href="https://www.youtube.com/watch?v=aESwsmnA7Ec">https://www.youtube.com/watch?v=aESwsmnA7Ec</a> - A walkthrough of how to build a cross-compiler using Cygwin on Windows.
+</li><li><a rel="nofollow" class="external free" href="https://github.com/Cheapskate01/Cross-Compiler-Build-Script">https://github.com/Cheapskate01/Cross-Compiler-Build-Script</a> - A dead-simple script that Binutils and Gcc for you.
+</li></ul>
+<h3> <span class="mw-headline" id="Prebuilt_Toolchains"> Prebuilt Toolchains </span></h3>
+<p>These were built by people in the OSdev community for their own building needs and shared at will, without guaranteeing any support or that it will even work on your setup. YMMV.
+</p><p><b>Latests versions for Linux (many arch)</b>
+</p>
+<ul><li> <a rel="nofollow" class="external text" href="https://www.kernel.org/pub/tools/crosstool/">kernel.org various hosts/targets</a>
+</li></ul>
+<p><b>For Linux x86_64 host</b>
+</p>
+<ul><li> <a rel="nofollow" class="external text" href="https://drive.google.com/file/d/0Bw6lG3Ej2746STJaM2dNbC05elE/view?usp=sharing">i386-elf &amp; i686-elf 7.1.0 target uploaded by TheAlmostGenius</a>
+</li></ul>
+<ul><li> <a rel="nofollow" class="external text" href="http://newos.org/toolchains/i386-elf-4.9.1-Linux-x86_64.tar.xz">i386-elf 4.9.1 target</a>
+</li><li> <a rel="nofollow" class="external text" href="http://newos.org/toolchains/i686-elf-4.9.1-Linux-x86_64.tar.xz">i686-elf 4.9.1 target</a>
+</li><li> <a rel="nofollow" class="external text" href="http://newos.org/toolchains/x86_64-elf-4.9.1-Linux-x86_64.tar.xz">x86_64-elf 4.9.1 target</a>
+</li><li> <a rel="nofollow" class="external text" href="http://newos.org/toolchains/aarch64-elf-4.9.1-Linux-x86_64.tar.xz">aarch64-elf 4.9.1 target</a>
+</li><li> <a rel="nofollow" class="external text" href="http://newos.org/toolchains/arm-eabi-4.9.1-Linux-x86_64.tar.xz">arm-eabi 4.9.1 target</a>
+</li><li> <a rel="nofollow" class="external text" href="http://newos.org/toolchains/m68k-elf-4.9.1-Linux-x86_64.tar.xz">m68k-elf 4.9.1 target</a>
+</li><li> <a rel="nofollow" class="external text" href="http://newos.org/toolchains/powerpc-elf-4.9.1-Linux-x86_64.tar.xz">powerpc-elf 4.9.1 target</a>
+</li><li> <a rel="nofollow" class="external text" href="http://newos.org/toolchains/sparc-elf-4.9.1-Linux-x86_64.tar.xz">sparc-elf 4.9.1 target</a>
+</li><li> <a rel="nofollow" class="external text" href="http://newos.org/toolchains/sh-elf-4.9.1-Linux-x86_64.tar.xz">sh-elf 4.9.1 target</a>
+</li></ul>
+<p>The packages from phillid.tk below have been shrunk to about 10 MiB for each pair of packages (GCC &amp; Binutils).
+Please note that this has been achieved by enabling only the C front-end for GCC.
+If you're going to write your OS in any language but C or Assembly, these packages aren't for you.
+These are actually Pacman packages, but untarring them to / and rm-ing /.MTREE and other clutter dotfiles contained in the package will work the same.
+</p><p><b>For Windows host</b>
+</p>
+<ul><li> <a rel="nofollow" class="external text" href="https://drive.google.com/file/d/0B85K_c7mx3QjUnZuaFRPWlBIcXM/edit?usp=sharing">i686-elf 4.8.2 target</a>
+</li><li> <a rel="nofollow" class="external text" href="https://mega.co.nz/#F!bBxA3SKJ!TDL4i1NjaZKd4YMo9p2U7g">x86_64-elf 5.1.0 target</a>
+</li><li> <a rel="nofollow" class="external text" href="https://github.com/lordmilko/i686-elf-tools">i686-elf 7.1.0 target + GDB</a>
+</li></ul>
+<p><b>For Windows Subsystem for Linux (Beta) host</b>
+</p>
+<ul><li> <a rel="nofollow" class="external text" href="http://www.bin-os.com/i686-elf-6.1.0.tar.gz">i686-elf 6.1.0 target</a> (extracts to a directory called "cross", don't forget to install 'make' - I would recommend "apt-get install build-essential" to also add additional useful tools)
+</li></ul>
+<p><b>For OSX host</b>
+</p>
+<ul><li> <a rel="nofollow" class="external text" href="https://docs.google.com/file/d/0BxDNp6DGU6SZcmlHVWpNblRnWWs/edit?usp=sharing">x86_64-pc-elf Cross Compiler setup with GCC and Binutils for x86_64 OSX</a>
+</li></ul>
+<p><b>ARM prebuilt toolchains for multiple host platforms</b>
+</p><p>ARM provides it's own prebuilt toolchain based upon GNU utilities for development targeting ARM systems.
+</p>
+<ul><li> <a rel="nofollow" class="external text" href="https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads">GNU ARM Embedded Toolchain</a>
+</li></ul>
+<p><b>Docker image</b>
+</p>
+<ul><li> <a rel="nofollow" class="external text" href="https://hub.docker.com/r/joshwyant/gcc-cross/">i686-elf 8.1.0 target</a>
+</li></ul>
+
+<!--
+NewPP limit report
+Preprocessor node count: 389/1000000
+Post-expand include size: 14617/2097152 bytes
+Template argument size: 392/2097152 bytes
+Expensive parser function count: 0/100
+-->
+
+<!-- Saved in parser cache with key wikidb:pcache:idhash:1448-0!*!0!!en!2!* and timestamp 20181010183609 -->
+</div> <!-- /bodycontent -->
+ <!-- printfooter -->
+ <div class="printfooter">
+ Retrieved from "<a href="https://wiki.osdev.org/index.php?title=GCC_Cross-Compiler&amp;oldid=22847">https://wiki.osdev.org/index.php?title=GCC_Cross-Compiler&amp;oldid=22847</a>" </div>
+ <!-- /printfooter -->
+ <!-- catlinks -->
+ <div id='catlinks' class='catlinks'><div id="mw-normal-catlinks"><a href="/Special:Categories" title="Special:Categories">Categories</a>: <ul><li><a href="/Category:Articles_Written_in_First_Person" title="Category:Articles Written in First Person">Articles Written in First Person</a></li><li><a href="/Category:Level_1_Tutorials" title="Category:Level 1 Tutorials">Level 1 Tutorials</a></li><li><a href="/Category:Compilers" title="Category:Compilers">Compilers</a></li><li><a href="/Category:Tutorials" title="Category:Tutorials">Tutorials</a></li></ul></div></div> <!-- /catlinks -->
+ <div class="visualClear"></div>
+ <!-- debughtml -->
+ <!-- /debughtml -->
+ </div>
+ <!-- /bodyContent -->
+ </div>
+ <!-- /content -->
+ <!-- header -->
+ <div id="mw-head" class="noprint">
+
+<!-- 0 -->
+<div id="p-personal" class="">
+ <h5>Personal tools</h5>
+ <ul>
+ <li id="pt-login"><a href="/index.php?title=Special:UserLogin&amp;returnto=GCC_Cross-Compiler" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o">Log in</a></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+ <div id="left-navigation">
+
+<!-- 0 -->
+<div id="p-namespaces" class="vectorTabs">
+ <h5>Namespaces</h5>
+ <ul>
+ <li id="ca-nstab-main" class="selected"><span><a href="/GCC_Cross-Compiler" title="View the content page [c]" accesskey="c">Page</a></span></li>
+ <li id="ca-talk"><span><a href="/Talk:GCC_Cross-Compiler" title="Discussion about the content page [t]" accesskey="t">Discussion</a></span></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+
+<!-- 1 -->
+<div id="p-variants" class="vectorMenu emptyPortlet">
+ <h5><span>Variants</span><a href="#"></a></h5>
+ <div class="menu">
+ <ul>
+ </ul>
+ </div>
+</div>
+
+<!-- /1 -->
+ </div>
+ <div id="right-navigation">
+
+<!-- 0 -->
+<div id="p-views" class="vectorTabs">
+ <h5>Views</h5>
+ <ul>
+ <li id="ca-view" class="selected"><span><a href="/GCC_Cross-Compiler" >Read</a></span></li>
+ <li id="ca-viewsource"><span><a href="/index.php?title=GCC_Cross-Compiler&amp;action=edit" title="This page is protected.&#10;You can view its source [e]" accesskey="e">View source</a></span></li>
+ <li id="ca-history" class="collapsible"><span><a href="/index.php?title=GCC_Cross-Compiler&amp;action=history" title="Past revisions of this page [h]" accesskey="h">View history</a></span></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+
+<!-- 1 -->
+<div id="p-cactions" class="vectorMenu emptyPortlet">
+ <h5><span>Actions</span><a href="#"></a></h5>
+ <div class="menu">
+ <ul>
+ </ul>
+ </div>
+</div>
+
+<!-- /1 -->
+
+<!-- 2 -->
+<div id="p-search">
+ <h5><label for="searchInput">Search</label></h5>
+ <form action="/index.php" id="searchform">
+ <input type='hidden' name="title" value="Special:Search"/>
+ <input type="search" name="search" title="Search OSDev Wiki [f]" accesskey="f" id="searchInput" /> <input type="submit" name="go" value="Go" title="Go to a page with this exact name if exists" id="searchGoButton" class="searchButton" /> <input type="submit" name="fulltext" value="Search" title="Search the pages for this text" id="mw-searchButton" class="searchButton" /> </form>
+</div>
+
+<!-- /2 -->
+ </div>
+ </div>
+ <!-- /header -->
+ <!-- panel -->
+ <div id="mw-panel" class="noprint">
+ <!-- logo -->
+ <div id="p-logo"><a style="background-image: url(/skins/common/images/osdev.png);" href="/Main_Page" title="Visit the main page"></a></div>
+ <!-- /logo -->
+
+<!-- navigation -->
+<div class="portal" id='p-navigation'>
+ <h5>Navigation</h5>
+ <div class="body">
+ <ul>
+ <li id="n-mainpage"><a href="/Main_Page" title="Visit the main page [z]" accesskey="z">Main Page</a></li>
+ <li id="n-portal"><a href="http://forum.osdev.org/" rel="nofollow" title="About the project, what you can do, where to find things">Forums</a></li>
+ <li id="n-FAQ"><a href="/Category:FAQ">FAQ</a></li>
+ <li id="n-OS-Projects"><a href="/Projects">OS Projects</a></li>
+ <li id="n-randompage"><a href="/Special:Random" title="Load a random page [x]" accesskey="x">Random page</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /navigation -->
+
+<!-- about -->
+<div class="portal" id='p-about'>
+ <h5>About</h5>
+ <div class="body">
+ <ul>
+ <li id="n-This-site"><a href="/OSDevWiki:About">This site</a></li>
+ <li id="n-Joining"><a href="/OSDevWiki:Joining">Joining</a></li>
+ <li id="n-Editing-help"><a href="/OSDevWiki:Editing">Editing help</a></li>
+ <li id="n-recentchanges"><a href="/Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /about -->
+
+<!-- SEARCH -->
+
+<!-- /SEARCH -->
+
+<!-- TOOLBOX -->
+<div class="portal" id='p-tb'>
+ <h5>Toolbox</h5>
+ <div class="body">
+ <ul>
+ <li id="t-whatlinkshere"><a href="/Special:WhatLinksHere/GCC_Cross-Compiler" title="A list of all wiki pages that link here [j]" accesskey="j">What links here</a></li>
+ <li id="t-recentchangeslinked"><a href="/Special:RecentChangesLinked/GCC_Cross-Compiler" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li>
+ <li id="t-specialpages"><a href="/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q">Special pages</a></li>
+ <li><a href="/index.php?title=GCC_Cross-Compiler&amp;printable=yes" rel="alternate">Printable version</a></li>
+ <li id="t-permalink"><a href="/index.php?title=GCC_Cross-Compiler&amp;oldid=22847" title="Permanent link to this revision of the page">Permanent link</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /TOOLBOX -->
+
+<!-- LANGUAGES -->
+<div class="portal" id='p-lang'>
+ <h5>In other languages</h5>
+ <div class="body">
+ <ul>
+ <li class="interwiki-de"><a href="http://www.lowlevel.eu/wiki/Cross-Compiler" title="Cross-Compiler">Deutsch</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /LANGUAGES -->
+ </div>
+ <!-- /panel -->
+ <!-- footer -->
+ <div id="footer">
+ <ul id="footer-info">
+ <li id="footer-info-lastmod"> This page was last modified on 14 September 2018, at 17:58.</li>
+ <li id="footer-info-viewcount">This page has been accessed 710,811 times.</li>
+ </ul>
+ <ul id="footer-places">
+ <li id="footer-places-privacy"><a href="/OSDev_Wiki:Privacy_policy" title="OSDev Wiki:Privacy policy">Privacy policy</a></li>
+ <li id="footer-places-about"><a href="/OSDev_Wiki:About" title="OSDev Wiki:About">About OSDev Wiki</a></li>
+ <li id="footer-places-disclaimer"><a href="/OSDev_Wiki:General_disclaimer" title="OSDev Wiki:General disclaimer">Disclaimers</a></li>
+ </ul>
+ <ul id="footer-icons" class="noprint">
+ <li id="footer-poweredbyico">
+ <a href="http://www.mediawiki.org/"><img src="/skins/common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" width="88" height="31" /></a>
+ </li>
+ </ul>
+ <div style="clear:both"></div>
+ </div>
+ <!-- /footer -->
+ <!-- fixalpha -->
+ <script type="text/javascript"> if ( window.isMSIE55 ) fixalpha(); </script>
+ <!-- /fixalpha -->
+ <script src="/load.php?debug=false&amp;lang=en&amp;modules=skins.vector&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.loader.load(["mediawiki.user", "mediawiki.util", "mediawiki.page.ready", "mediawiki.legacy.wikibits", "mediawiki.legacy.ajax"]);
+}
+</script>
+<script src="/load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":1,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"highlightbroken":1,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":1,"showtoolbar":1,"skin":"vector","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,"watchlistdays":3,"watchlisthideanons":0,
+ "watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false});;mw.user.tokens.set({"editToken":"+\\","watchToken":false});;mw.loader.state({"user.options":"ready","user.tokens":"ready"});
+
+ /* cache key: wikidb:resourceloader:filter:minify-js:4:19a4b18a9ac79a6b8c60b24af4668814 */
+}
+</script><!-- Served in 0.039 secs. -->
+ </body>
+</html>
diff --git a/ref/Hosted_GCC_Cross-Compiler.html b/ref/Hosted_GCC_Cross-Compiler.html
new file mode 100644
index 0000000..c3a0555
--- /dev/null
+++ b/ref/Hosted_GCC_Cross-Compiler.html
@@ -0,0 +1,408 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr" class="client-nojs">
+<head>
+<title>Hosted GCC Cross-Compiler - OSDev Wiki</title>
+<meta charset="UTF-8" />
+<meta name="generator" content="MediaWiki 1.18.0" />
+<link rel="shortcut icon" href="/favicon.ico" />
+<link rel="search" type="application/opensearchdescription+xml" href="/opensearch_desc.php" title="OSDev Wiki (en)" />
+<link rel="EditURI" type="application/rsd+xml" href="https://wiki.osdev.org/api.php?action=rsd" />
+<link rel="alternate" type="application/atom+xml" title="OSDev Wiki Atom feed" href="/index.php?title=Special:RecentChanges&amp;feed=atom" />
+<link rel="stylesheet" href="/load.php?debug=false&amp;lang=en&amp;modules=mediawiki.legacy.commonPrint%2Cshared%7Cskins.vector&amp;only=styles&amp;skin=vector&amp;*" />
+<meta name="ResourceLoaderDynamicStyles" content="" />
+<link rel="stylesheet" href="/load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=styles&amp;skin=vector&amp;*" />
+<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}a.new,#quickbar a.new{color:#ba0000}
+
+/* cache key: wikidb:resourceloader:filter:minify-css:4:c88e2bcd56513749bec09a7e29cb3ffa */
+</style>
+<script src="/load.php?debug=false&amp;lang=en&amp;modules=startup&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.config.set({"wgCanonicalNamespace": "", "wgCanonicalSpecialPageName": false, "wgNamespaceNumber": 0, "wgPageName": "Hosted_GCC_Cross-Compiler", "wgTitle": "Hosted GCC Cross-Compiler", "wgCurRevisionId": 22405, "wgArticleId": 3637, "wgIsArticle": true, "wgAction": "view", "wgUserName": null, "wgUserGroups": ["*"], "wgCategories": ["Level 3 Tutorials", "Compilers", "Tutorials"], "wgBreakFrames": false, "wgRestrictionEdit": [], "wgRestrictionMove": []});
+}
+</script><script>if(window.mw){
+ mw.loader.load(["mediawiki.page.startup"]);
+}
+</script>
+<style type="text/css">/*<![CDATA[*/
+.source-bash {line-height: normal;}
+.source-bash li, .source-bash pre {
+ line-height: normal; border: 0px none white;
+}
+/**
+ * GeSHi Dynamically Generated Stylesheet
+ * --------------------------------------
+ * Dynamically generated stylesheet for bash
+ * CSS class: source-bash, CSS id:
+ * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
+ * (http://qbnz.com/highlighter/ and http://geshi.org/)
+ * --------------------------------------
+ */
+.bash.source-bash .de1, .bash.source-bash .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
+.bash.source-bash {font-family:monospace;}
+.bash.source-bash .imp {font-weight: bold; color: red;}
+.bash.source-bash li, .bash.source-bash .li1 {font-weight: normal; vertical-align:top;}
+.bash.source-bash .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
+.bash.source-bash .li2 {font-weight: bold; vertical-align:top;}
+.bash.source-bash .kw1 {color: #000000; font-weight: bold;}
+.bash.source-bash .kw2 {color: #c20cb9; font-weight: bold;}
+.bash.source-bash .kw3 {color: #7a0874; font-weight: bold;}
+.bash.source-bash .co0 {color: #666666; font-style: italic;}
+.bash.source-bash .co1 {color: #800000;}
+.bash.source-bash .co2 {color: #cc0000; font-style: italic;}
+.bash.source-bash .co3 {color: #000000; font-weight: bold;}
+.bash.source-bash .co4 {color: #666666;}
+.bash.source-bash .es1 {color: #000099; font-weight: bold;}
+.bash.source-bash .es2 {color: #007800;}
+.bash.source-bash .es3 {color: #007800;}
+.bash.source-bash .es4 {color: #007800;}
+.bash.source-bash .es5 {color: #780078;}
+.bash.source-bash .es_h {color: #000099; font-weight: bold;}
+.bash.source-bash .br0 {color: #7a0874; font-weight: bold;}
+.bash.source-bash .sy0 {color: #000000; font-weight: bold;}
+.bash.source-bash .st0 {color: #ff0000;}
+.bash.source-bash .st_h {color: #ff0000;}
+.bash.source-bash .nu0 {color: #000000;}
+.bash.source-bash .re0 {color: #007800;}
+.bash.source-bash .re1 {color: #007800;}
+.bash.source-bash .re2 {color: #007800;}
+.bash.source-bash .re4 {color: #007800;}
+.bash.source-bash .re5 {color: #660033;}
+.bash.source-bash .ln-xtra, .bash.source-bash li.ln-xtra, .bash.source-bash div.ln-xtra {background-color: #ffc;}
+.bash.source-bash span.xtra { display:block; }
+
+/*]]>*/
+</style>
+<style type="text/css">/*<![CDATA[*/
+@import "/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
+/*]]>*/
+</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/skins/vector/csshover.min.htc")}</style><![endif]--></head>
+<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-Hosted_GCC_Cross-Compiler action-view skin-vector">
+ <div id="mw-page-base" class="noprint"></div>
+ <div id="mw-head-base" class="noprint"></div>
+ <!-- content -->
+ <div id="content">
+ <a id="top"></a>
+ <div id="mw-js-message" style="display:none;"></div>
+ <!-- firstHeading -->
+ <h1 id="firstHeading" class="firstHeading">Hosted GCC Cross-Compiler</h1>
+ <!-- /firstHeading -->
+ <!-- bodyContent -->
+ <div id="bodyContent">
+ <!-- tagline -->
+ <div id="siteSub">From OSDev Wiki</div>
+ <!-- /tagline -->
+ <!-- subtitle -->
+ <div id="contentSub"></div>
+ <!-- /subtitle -->
+ <!-- jumpto -->
+ <div id="jump-to-nav">
+ Jump to: <a href="#mw-head">navigation</a>,
+ <a href="#p-search">search</a>
+ </div>
+ <!-- /jumpto -->
+ <!-- bodycontent -->
+ <div lang="en" dir="ltr" class="mw-content-ltr"><table style="font-size:95%; line-height:1.5em; padding:0.25em; float:right; margin: 0 0 8px 15px; clear:right; border:1px solid #aaaaaa; background:#eee; text-align:center;;"><tr><th>Difficulty level</th></tr><tr><td><a href="/File:Difficulty_3.png" class="image"><img alt="Difficulty 3.png" src="/images/c/c1/Difficulty_3.png" width="46" height="14" /></a><br />Advanced</td></tr></table>
+<p>In this tutorial we create a cross-compiler that provides a hosted environment (user-space, libc, all that good stuff) as opposed to the initial <a href="/GCC_Cross-Compiler" title="GCC Cross-Compiler">GCC Cross-Compiler</a> that only provides a freestanding environment. This is an advanced topic meant for established developers, newcomers should start with a <a href="/GCC_Cross-Compiler" title="GCC Cross-Compiler">freestanding cross-compiler</a>. The <tt>-elf</tt> targets are incapable of having a user-space, so you need to make a <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a> before following this tutorial. You also need a <a href="/C_Library" title="C Library">C Library</a>, perhaps a <a href="/Creating_a_C_Library" title="Creating a C Library">homemade one</a>.
+</p>
+<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
+<ul>
+<li class="toclevel-1 tocsection-1"><a href="#Introduction"><span class="tocnumber">1</span> <span class="toctext">Introduction</span></a></li>
+<li class="toclevel-1 tocsection-2"><a href="#Prerequisites"><span class="tocnumber">2</span> <span class="toctext">Prerequisites</span></a></li>
+<li class="toclevel-1 tocsection-3"><a href="#Sysroot_Headers"><span class="tocnumber">3</span> <span class="toctext">Sysroot Headers</span></a></li>
+<li class="toclevel-1 tocsection-4"><a href="#Binutils"><span class="tocnumber">4</span> <span class="toctext">Binutils</span></a></li>
+<li class="toclevel-1 tocsection-5"><a href="#GCC"><span class="tocnumber">5</span> <span class="toctext">GCC</span></a></li>
+<li class="toclevel-1 tocsection-6"><a href="#libc"><span class="tocnumber">6</span> <span class="toctext">libc</span></a></li>
+<li class="toclevel-1 tocsection-7"><a href="#libstdc.2B.2B"><span class="tocnumber">7</span> <span class="toctext">libstdc++</span></a>
+<ul>
+<li class="toclevel-2 tocsection-8"><a href="#Troubleshooting"><span class="tocnumber">7.1</span> <span class="toctext">Troubleshooting</span></a></li>
+</ul>
+</li>
+<li class="toclevel-1 tocsection-9"><a href="#Conclusion"><span class="tocnumber">8</span> <span class="toctext">Conclusion</span></a></li>
+<li class="toclevel-1 tocsection-10"><a href="#See_Also"><span class="tocnumber">9</span> <span class="toctext">See Also</span></a>
+<ul>
+<li class="toclevel-2 tocsection-11"><a href="#Articles"><span class="tocnumber">9.1</span> <span class="toctext">Articles</span></a></li>
+</ul>
+</li>
+</ul>
+</td></tr></table>
+<h2> <span class="mw-headline" id="Introduction"> Introduction </span></h2>
+<p>This tutorial acts as a patch to the original <a href="/GCC_Cross-Compiler" title="GCC Cross-Compiler">GCC Cross-Compiler</a> article by subtly changing the instructions. The caveats and instructions from it generally apply here, too. You are assumed to be an experienced reader that automatically remembers trivial matters such as adding the cross-compiler prefix bindir to the <tt>PATH</tt> before building the cross-compiler, or installing the dependencies of Binutils and GCC.
+</p><p>This article completes the work begun in <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a> by compiling it, thus implementing the next step in <a href="/Porting_GCC_to_your_OS" title="Porting GCC to your OS">Porting GCC to your OS</a>: Teaching GCC what your operating system is and making a cross-compiler for it.
+</p><p>You will be using a new <a href="/Target_Triplet" title="Target Triplet">target triplet</a>, rather than <tt>i686-elf</tt>, we'll be using your custom <tt>i686-myos</tt> target. You will be supplying the Binutils and GCC source code yourself rather than using pure upstream releases.
+</p>
+<h2> <span class="mw-headline" id="Prerequisites"> Prerequisites </span></h2>
+<p>To correctly complete this tutorial, your libc must need particular minimum requirements. The libgcc will be built with libc support, meaning that your libc needs a few standard headers that define particular types, constants and functions. In particular, you need to supply:
+</p>
+<ul><li> <tt>sys/types.h</tt>: This header is just required to exist and can be empty.
+</li><li> <tt>errno.h</tt>: This header is just required to exist and can be empty.
+</li><li> <tt>stdlib.h</tt>: <tt>abort()</tt>, <tt>free()</tt>, <tt>malloc()</tt>.
+</li><li> <tt>stdio.h</tt>: <tt>FILE</tt>, <tt>stderr</tt>, <tt>fflush()</tt>, <tt>fprintf()</tt>.
+</li><li> <tt>string.h</tt>: <tt>size_t</tt>, <tt>memcpy</tt>, <tt>memset()</tt>, <tt>strlen()</tt>.
+</li><li> <tt>time.h</tt>: This header is just required to exist and can be empty.
+</li><li> <tt>unistd.h</tt>: This header is just required to exist and can be empty.
+</li></ul>
+<p>Additionally, the <tt>all-target-libgcc</tt> target also unconditionally builds the libgcov support library, which has these additional requirements:
+</p>
+<ul><li> <tt>sys/types.h</tt>: <tt>pid_t</tt>.
+</li><li> <tt>stdlib.h</tt>: <tt>atexit()</tt>, <tt>atoi()</tt>, <tt>getenv()</tt>.
+</li><li> <tt>stdio.h</tt>: <tt>size_t</tt>, <tt>SEEK_SET</tt>, <tt>fclose()</tt>, <tt>fopen()</tt>, <tt>fread()</tt>, <tt>fseek()</tt>, <tt>ftell()</tt>, <tt>fwrite()</tt>, <tt>setbuf()</tt>, <tt>vfprintf()</tt>.
+</li><li> <tt>string.h</tt>: <tt>strcpy()</tt>.
+</li><li> <tt>unistd.h</tt>: <tt>pid_t</tt>, <tt>fork()</tt>, <tt>execv()</tt>, <tt>execve()</tt>, <tt>execvp()</tt>.
+</li></ul>
+<p>Note how these are statically linked libraries and are not linked. It will do to simply add function prototypes with no implementation (or better yet, a stub implementation, or a real one) and no linker errors will happen unless the relevant parts of libgcc or libgcov are needed. Note how these are just the minimum requirements to get by without any implicit-function-declaration issues; the code is able to use more standard library features if available.
+</p><p>For the record and convenience, <a rel="nofollow" class="external text" href="https://gist.github.com/sortie/9a64aa532052e2137f05f5324a75b474">here are minimal headers</a> that satisfies the requirements.
+</p>
+<h2> <span class="mw-headline" id="Sysroot_Headers"> Sysroot Headers </span></h2>
+<p>Your previous <tt>i686-elf</tt> toolchain was built using the <tt>--without-headers</tt> configure option. This tells the compiler that there is no standard library and no headers. The libgcc is built with libc support as described above. This requires the standard library headers to be installed into your <a href="/Meaty_Skeleton#System_Root" title="Meaty Skeleton">system root</a> prior to the cross-compiler build.
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw3">cd</span> <span class="re1">$HOME</span><span class="sy0">/</span>myos
+<span class="kw2">mkdir</span> <span class="re5">-p</span> sysroot
+<span class="kw2">mkdir</span> <span class="re5">-p</span> sysroot<span class="sy0">/</span>usr<span class="sy0">/</span>include
+<span class="kw2">cp</span> <span class="re5">-RT</span> libc<span class="sy0">/</span>include sysroot<span class="sy0">/</span>usr<span class="sy0">/</span>include
+<span class="kw2">cp</span> <span class="re5">-RT</span> kernel<span class="sy0">/</span>include sysroot<span class="sy0">/</span>usr<span class="sy0">/</span>include</pre></div></div>
+<p><b>Note</b>: Not all <tt>cp(1)</tt> implementations support the <tt>-RT</tt> combination that conveniently merges the contents of one directory into another.
+</p>
+<h2> <span class="mw-headline" id="Binutils"> Binutils </span></h2>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw3">cd</span> <span class="re1">$HOME</span><span class="sy0">/</span>src
+<span class="kw2">mkdir</span> build-binutils
+<span class="kw3">cd</span> build-binutils
+..<span class="sy0">/</span>myos-binutils<span class="sy0">/</span>configure <span class="re5">--target</span>=i686-myos <span class="re5">--prefix</span>=<span class="st0">&quot;<span class="es2">$PREFIX</span>&quot;</span> <span class="re5">--with-sysroot</span>=<span class="re1">$HOME</span><span class="sy0">/</span>myos<span class="sy0">/</span>sysroot <span class="re5">--disable-werror</span>
+<span class="kw2">make</span>
+<span class="kw2">make</span> <span class="kw2">install</span></pre></div></div>
+<p><b>--with-sysroot=</b> This option tells the compiler where your sysroot is. It is not used during the compilation process, but it is remembered and used when the linker searches for libraries.
+</p>
+<h2> <span class="mw-headline" id="GCC"> GCC </span></h2>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw3">cd</span> <span class="re1">$HOME</span><span class="sy0">/</span>src
+<span class="kw2">mkdir</span> build-gcc
+<span class="kw3">cd</span> build-gcc
+..<span class="sy0">/</span>myos-gcc<span class="sy0">/</span>configure <span class="re5">--target</span>=i686-myos <span class="re5">--prefix</span>=<span class="st0">&quot;<span class="es2">$PREFIX</span>&quot;</span> <span class="re5">--with-sysroot</span>=<span class="re1">$HOME</span><span class="sy0">/</span>myos<span class="sy0">/</span>sysroot <span class="re5">--enable-languages</span>=c,<span class="kw2">c++</span>
+<span class="kw2">make</span> all-gcc all-target-libgcc
+<span class="kw2">make</span> install-gcc install-target-libgcc</pre></div></div>
+<p><b>--with-sysroot=</b> This option tells the compiler where your sysroot is. It is used during the libgcc build and is remembered and used when the compiler searches for headers and libraries.
+</p>
+<h2> <span class="mw-headline" id="libc"> libc </span></h2>
+<p>You can now compile your <a href="/C_Library" title="C Library">C Library</a> normally using your fresh, custom cross-compiler.
+</p>
+<h2> <span class="mw-headline" id="libstdc.2B.2B"> libstdc++ </span></h2>
+<p>The libstdc++ library was still not built above as it depends on libc as it needs to perform link tests to know about it. The GCC developers have poorly designed the libstdc++ package and it is tied to GCC and must be built as part of GCC, it can't be built on its own without tricks. If you saved your build-gcc directory from earlier, you can continue the process now (otherwise, it will build a full new cross-compiler for no good reason):
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw3">cd</span> <span class="re1">$HOME</span><span class="sy0">/</span>src<span class="sy0">/</span>build-gcc
+<span class="kw2">make</span> all-target-libstdc++-v3
+<span class="kw2">make</span> install-target-libstdc++-v3</pre></div></div>
+<h3> <span class="mw-headline" id="Troubleshooting"> Troubleshooting </span></h3>
+<p>In case you get an this error (occurs when using newlib):
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1">.<span class="sy0">/</span>..<span class="sy0">/</span>..<span class="sy0">/</span>..<span class="sy0">/</span>gcc-7.2.0<span class="sy0">/</span>libstdc++-v3<span class="sy0">/</span>libsupc++<span class="sy0">/</span>new_opa.cc:<span class="nu0">62</span>:<span class="nu0">1</span>: error: ‘void<span class="sy0">*</span> aligned_alloc<span class="br0">&#40;</span>std::size_t, std::size_t<span class="br0">&#41;</span>’ was declared ‘extern’ and later ‘static’ <span class="br0">&#91;</span>-fpermissive<span class="br0">&#93;</span>
+ aligned_alloc <span class="br0">&#40;</span>std::size_t al, std::size_t sz<span class="br0">&#41;</span></pre></div></div>
+<p>Open the file <b>libstdc++-v3/libsupc++/new_opa.cc</b> with an editor and remove the "static inline" before in the function prototype.
+</p>
+<h2> <span class="mw-headline" id="Conclusion"> Conclusion </span></h2>
+<p>You now have a full <tt>i686-myos</tt> toolchain that provides a hosted environment producing executables for your user-space. Your program loader will load programs into the current process, set up an initial thread at the program entry point, and the process will perform system calls to cooperate with the kernel.
+</p><p>You can continue to polish your custom toolchain by teaching it more about your operating system and customizing its behavior to your needs. As your standard library and kernel support improves, you will become able to easily <a href="/Cross-Porting_Software" title="Cross-Porting Software">port third party software</a> to your operating system by making third party software use your cross-compiler.
+</p>
+<h2> <span class="mw-headline" id="See_Also"> See Also </span></h2>
+<h3> <span class="mw-headline" id="Articles"> Articles </span></h3>
+<ul><li> <a href="/GCC" title="GCC">GCC</a>
+</li><li> <a href="/GCC_Cross-Compiler" title="GCC Cross-Compiler">GCC Cross-Compiler</a>
+</li><li> <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a>
+</li><li> <a href="/ELF" title="ELF">ELF</a>
+</li><li> <a href="/System_Call" title="System Call" class="mw-redirect">System Call</a>
+</li><li> <a href="/Porting_GCC_to_your_OS" title="Porting GCC to your OS">Porting GCC to your OS</a>
+</li><li> <a href="/Cross-Porting_Software" title="Cross-Porting Software">Cross-Porting Software</a>
+</li></ul>
+
+<!--
+NewPP limit report
+Preprocessor node count: 239/1000000
+Post-expand include size: 372/2097152 bytes
+Template argument size: 84/2097152 bytes
+Expensive parser function count: 0/100
+-->
+
+<!-- Saved in parser cache with key wikidb:pcache:idhash:3637-0!*!0!!en!2!* and timestamp 20181010183647 -->
+</div> <!-- /bodycontent -->
+ <!-- printfooter -->
+ <div class="printfooter">
+ Retrieved from "<a href="https://wiki.osdev.org/index.php?title=Hosted_GCC_Cross-Compiler&amp;oldid=22405">https://wiki.osdev.org/index.php?title=Hosted_GCC_Cross-Compiler&amp;oldid=22405</a>" </div>
+ <!-- /printfooter -->
+ <!-- catlinks -->
+ <div id='catlinks' class='catlinks'><div id="mw-normal-catlinks"><a href="/Special:Categories" title="Special:Categories">Categories</a>: <ul><li><a href="/Category:Level_3_Tutorials" title="Category:Level 3 Tutorials">Level 3 Tutorials</a></li><li><a href="/Category:Compilers" title="Category:Compilers">Compilers</a></li><li><a href="/Category:Tutorials" title="Category:Tutorials">Tutorials</a></li></ul></div></div> <!-- /catlinks -->
+ <div class="visualClear"></div>
+ <!-- debughtml -->
+ <!-- /debughtml -->
+ </div>
+ <!-- /bodyContent -->
+ </div>
+ <!-- /content -->
+ <!-- header -->
+ <div id="mw-head" class="noprint">
+
+<!-- 0 -->
+<div id="p-personal" class="">
+ <h5>Personal tools</h5>
+ <ul>
+ <li id="pt-login"><a href="/index.php?title=Special:UserLogin&amp;returnto=Hosted_GCC_Cross-Compiler" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o">Log in</a></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+ <div id="left-navigation">
+
+<!-- 0 -->
+<div id="p-namespaces" class="vectorTabs">
+ <h5>Namespaces</h5>
+ <ul>
+ <li id="ca-nstab-main" class="selected"><span><a href="/Hosted_GCC_Cross-Compiler" title="View the content page [c]" accesskey="c">Page</a></span></li>
+ <li id="ca-talk" class="new"><span><a href="/index.php?title=Talk:Hosted_GCC_Cross-Compiler&amp;action=edit&amp;redlink=1" title="Discussion about the content page [t]" accesskey="t">Discussion</a></span></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+
+<!-- 1 -->
+<div id="p-variants" class="vectorMenu emptyPortlet">
+ <h5><span>Variants</span><a href="#"></a></h5>
+ <div class="menu">
+ <ul>
+ </ul>
+ </div>
+</div>
+
+<!-- /1 -->
+ </div>
+ <div id="right-navigation">
+
+<!-- 0 -->
+<div id="p-views" class="vectorTabs">
+ <h5>Views</h5>
+ <ul>
+ <li id="ca-view" class="selected"><span><a href="/Hosted_GCC_Cross-Compiler" >Read</a></span></li>
+ <li id="ca-viewsource"><span><a href="/index.php?title=Hosted_GCC_Cross-Compiler&amp;action=edit" title="This page is protected.&#10;You can view its source [e]" accesskey="e">View source</a></span></li>
+ <li id="ca-history" class="collapsible"><span><a href="/index.php?title=Hosted_GCC_Cross-Compiler&amp;action=history" title="Past revisions of this page [h]" accesskey="h">View history</a></span></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+
+<!-- 1 -->
+<div id="p-cactions" class="vectorMenu emptyPortlet">
+ <h5><span>Actions</span><a href="#"></a></h5>
+ <div class="menu">
+ <ul>
+ </ul>
+ </div>
+</div>
+
+<!-- /1 -->
+
+<!-- 2 -->
+<div id="p-search">
+ <h5><label for="searchInput">Search</label></h5>
+ <form action="/index.php" id="searchform">
+ <input type='hidden' name="title" value="Special:Search"/>
+ <input type="search" name="search" title="Search OSDev Wiki [f]" accesskey="f" id="searchInput" /> <input type="submit" name="go" value="Go" title="Go to a page with this exact name if exists" id="searchGoButton" class="searchButton" /> <input type="submit" name="fulltext" value="Search" title="Search the pages for this text" id="mw-searchButton" class="searchButton" /> </form>
+</div>
+
+<!-- /2 -->
+ </div>
+ </div>
+ <!-- /header -->
+ <!-- panel -->
+ <div id="mw-panel" class="noprint">
+ <!-- logo -->
+ <div id="p-logo"><a style="background-image: url(/skins/common/images/osdev.png);" href="/Main_Page" title="Visit the main page"></a></div>
+ <!-- /logo -->
+
+<!-- navigation -->
+<div class="portal" id='p-navigation'>
+ <h5>Navigation</h5>
+ <div class="body">
+ <ul>
+ <li id="n-mainpage"><a href="/Main_Page" title="Visit the main page [z]" accesskey="z">Main Page</a></li>
+ <li id="n-portal"><a href="http://forum.osdev.org/" rel="nofollow" title="About the project, what you can do, where to find things">Forums</a></li>
+ <li id="n-FAQ"><a href="/Category:FAQ">FAQ</a></li>
+ <li id="n-OS-Projects"><a href="/Projects">OS Projects</a></li>
+ <li id="n-randompage"><a href="/Special:Random" title="Load a random page [x]" accesskey="x">Random page</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /navigation -->
+
+<!-- about -->
+<div class="portal" id='p-about'>
+ <h5>About</h5>
+ <div class="body">
+ <ul>
+ <li id="n-This-site"><a href="/OSDevWiki:About">This site</a></li>
+ <li id="n-Joining"><a href="/OSDevWiki:Joining">Joining</a></li>
+ <li id="n-Editing-help"><a href="/OSDevWiki:Editing">Editing help</a></li>
+ <li id="n-recentchanges"><a href="/Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /about -->
+
+<!-- SEARCH -->
+
+<!-- /SEARCH -->
+
+<!-- TOOLBOX -->
+<div class="portal" id='p-tb'>
+ <h5>Toolbox</h5>
+ <div class="body">
+ <ul>
+ <li id="t-whatlinkshere"><a href="/Special:WhatLinksHere/Hosted_GCC_Cross-Compiler" title="A list of all wiki pages that link here [j]" accesskey="j">What links here</a></li>
+ <li id="t-recentchangeslinked"><a href="/Special:RecentChangesLinked/Hosted_GCC_Cross-Compiler" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li>
+ <li id="t-specialpages"><a href="/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q">Special pages</a></li>
+ <li><a href="/index.php?title=Hosted_GCC_Cross-Compiler&amp;printable=yes" rel="alternate">Printable version</a></li>
+ <li id="t-permalink"><a href="/index.php?title=Hosted_GCC_Cross-Compiler&amp;oldid=22405" title="Permanent link to this revision of the page">Permanent link</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /TOOLBOX -->
+
+<!-- LANGUAGES -->
+
+<!-- /LANGUAGES -->
+ </div>
+ <!-- /panel -->
+ <!-- footer -->
+ <div id="footer">
+ <ul id="footer-info">
+ <li id="footer-info-lastmod"> This page was last modified on 21 May 2018, at 12:07.</li>
+ <li id="footer-info-viewcount">This page has been accessed 14,088 times.</li>
+ </ul>
+ <ul id="footer-places">
+ <li id="footer-places-privacy"><a href="/OSDev_Wiki:Privacy_policy" title="OSDev Wiki:Privacy policy">Privacy policy</a></li>
+ <li id="footer-places-about"><a href="/OSDev_Wiki:About" title="OSDev Wiki:About">About OSDev Wiki</a></li>
+ <li id="footer-places-disclaimer"><a href="/OSDev_Wiki:General_disclaimer" title="OSDev Wiki:General disclaimer">Disclaimers</a></li>
+ </ul>
+ <ul id="footer-icons" class="noprint">
+ <li id="footer-poweredbyico">
+ <a href="http://www.mediawiki.org/"><img src="/skins/common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" width="88" height="31" /></a>
+ </li>
+ </ul>
+ <div style="clear:both"></div>
+ </div>
+ <!-- /footer -->
+ <!-- fixalpha -->
+ <script type="text/javascript"> if ( window.isMSIE55 ) fixalpha(); </script>
+ <!-- /fixalpha -->
+ <script src="/load.php?debug=false&amp;lang=en&amp;modules=skins.vector&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.loader.load(["mediawiki.user", "mediawiki.util", "mediawiki.page.ready", "mediawiki.legacy.wikibits", "mediawiki.legacy.ajax"]);
+}
+</script>
+<script src="/load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":1,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"highlightbroken":1,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":1,"showtoolbar":1,"skin":"vector","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,"watchlistdays":3,"watchlisthideanons":0,
+ "watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false});;mw.user.tokens.set({"editToken":"+\\","watchToken":false});;mw.loader.state({"user.options":"ready","user.tokens":"ready"});
+
+ /* cache key: wikidb:resourceloader:filter:minify-js:4:19a4b18a9ac79a6b8c60b24af4668814 */
+}
+</script><!-- Served in 0.195 secs. -->
+ </body>
+</html>
diff --git a/ref/Porting_Newlib.html b/ref/Porting_Newlib.html
new file mode 100644
index 0000000..0f4fe17
--- /dev/null
+++ b/ref/Porting_Newlib.html
@@ -0,0 +1,694 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr" class="client-nojs">
+<head>
+<title>Porting Newlib - OSDev Wiki</title>
+<meta charset="UTF-8" />
+<meta name="generator" content="MediaWiki 1.18.0" />
+<link rel="shortcut icon" href="/favicon.ico" />
+<link rel="search" type="application/opensearchdescription+xml" href="/opensearch_desc.php" title="OSDev Wiki (en)" />
+<link rel="EditURI" type="application/rsd+xml" href="https://wiki.osdev.org/api.php?action=rsd" />
+<link rel="alternate" type="application/atom+xml" title="OSDev Wiki Atom feed" href="/index.php?title=Special:RecentChanges&amp;feed=atom" />
+<link rel="stylesheet" href="/load.php?debug=false&amp;lang=en&amp;modules=mediawiki.legacy.commonPrint%2Cshared%7Cskins.vector&amp;only=styles&amp;skin=vector&amp;*" />
+<meta name="ResourceLoaderDynamicStyles" content="" />
+<link rel="stylesheet" href="/load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=styles&amp;skin=vector&amp;*" />
+<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}a.new,#quickbar a.new{color:#ba0000}
+
+/* cache key: wikidb:resourceloader:filter:minify-css:4:c88e2bcd56513749bec09a7e29cb3ffa */
+</style>
+<script src="/load.php?debug=false&amp;lang=en&amp;modules=startup&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.config.set({"wgCanonicalNamespace": "", "wgCanonicalSpecialPageName": false, "wgNamespaceNumber": 0, "wgPageName": "Porting_Newlib", "wgTitle": "Porting Newlib", "wgCurRevisionId": 22427, "wgArticleId": 2126, "wgIsArticle": true, "wgAction": "view", "wgUserName": null, "wgUserGroups": ["*"], "wgCategories": ["Level 3 Tutorials", "Tutorials"], "wgBreakFrames": false, "wgRestrictionEdit": [], "wgRestrictionMove": []});
+}
+</script><script>if(window.mw){
+ mw.loader.load(["mediawiki.page.startup"]);
+}
+</script>
+<style type="text/css">/*<![CDATA[*/
+.source-bash {line-height: normal;}
+.source-bash li, .source-bash pre {
+ line-height: normal; border: 0px none white;
+}
+/**
+ * GeSHi Dynamically Generated Stylesheet
+ * --------------------------------------
+ * Dynamically generated stylesheet for bash
+ * CSS class: source-bash, CSS id:
+ * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
+ * (http://qbnz.com/highlighter/ and http://geshi.org/)
+ * --------------------------------------
+ */
+.bash.source-bash .de1, .bash.source-bash .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
+.bash.source-bash {font-family:monospace;}
+.bash.source-bash .imp {font-weight: bold; color: red;}
+.bash.source-bash li, .bash.source-bash .li1 {font-weight: normal; vertical-align:top;}
+.bash.source-bash .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
+.bash.source-bash .li2 {font-weight: bold; vertical-align:top;}
+.bash.source-bash .kw1 {color: #000000; font-weight: bold;}
+.bash.source-bash .kw2 {color: #c20cb9; font-weight: bold;}
+.bash.source-bash .kw3 {color: #7a0874; font-weight: bold;}
+.bash.source-bash .co0 {color: #666666; font-style: italic;}
+.bash.source-bash .co1 {color: #800000;}
+.bash.source-bash .co2 {color: #cc0000; font-style: italic;}
+.bash.source-bash .co3 {color: #000000; font-weight: bold;}
+.bash.source-bash .co4 {color: #666666;}
+.bash.source-bash .es1 {color: #000099; font-weight: bold;}
+.bash.source-bash .es2 {color: #007800;}
+.bash.source-bash .es3 {color: #007800;}
+.bash.source-bash .es4 {color: #007800;}
+.bash.source-bash .es5 {color: #780078;}
+.bash.source-bash .es_h {color: #000099; font-weight: bold;}
+.bash.source-bash .br0 {color: #7a0874; font-weight: bold;}
+.bash.source-bash .sy0 {color: #000000; font-weight: bold;}
+.bash.source-bash .st0 {color: #ff0000;}
+.bash.source-bash .st_h {color: #ff0000;}
+.bash.source-bash .nu0 {color: #000000;}
+.bash.source-bash .re0 {color: #007800;}
+.bash.source-bash .re1 {color: #007800;}
+.bash.source-bash .re2 {color: #007800;}
+.bash.source-bash .re4 {color: #007800;}
+.bash.source-bash .re5 {color: #660033;}
+.bash.source-bash .ln-xtra, .bash.source-bash li.ln-xtra, .bash.source-bash div.ln-xtra {background-color: #ffc;}
+.bash.source-bash span.xtra { display:block; }
+
+/*]]>*/
+</style>
+<style type="text/css">/*<![CDATA[*/
+@import "/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
+/*]]>*/
+</style><style type="text/css">/*<![CDATA[*/
+.source-autoconf {line-height: normal;}
+.source-autoconf li, .source-autoconf pre {
+ line-height: normal; border: 0px none white;
+}
+/**
+ * GeSHi Dynamically Generated Stylesheet
+ * --------------------------------------
+ * Dynamically generated stylesheet for autoconf
+ * CSS class: source-autoconf, CSS id:
+ * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
+ * (http://qbnz.com/highlighter/ and http://geshi.org/)
+ * --------------------------------------
+ */
+.autoconf.source-autoconf .de1, .autoconf.source-autoconf .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
+.autoconf.source-autoconf {font-family:monospace;}
+.autoconf.source-autoconf .imp {font-weight: bold; color: red;}
+.autoconf.source-autoconf li, .autoconf.source-autoconf .li1 {font-weight: normal; vertical-align:top;}
+.autoconf.source-autoconf .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
+.autoconf.source-autoconf .li2 {font-weight: bold; vertical-align:top;}
+.autoconf.source-autoconf .kw1 {color: #00ffff;}
+.autoconf.source-autoconf .co1 {color: #666666;}
+.autoconf.source-autoconf .co2 {color: #339900;}
+.autoconf.source-autoconf .co3 {color: #666666;}
+.autoconf.source-autoconf .coMULTI {color: #ff0000; font-style: italic;}
+.autoconf.source-autoconf .es0 {color: #000099;}
+.autoconf.source-autoconf .es1 {color: #000099;}
+.autoconf.source-autoconf .es2 {color: #660099;}
+.autoconf.source-autoconf .es3 {color: #660099;}
+.autoconf.source-autoconf .es4 {color: #660099;}
+.autoconf.source-autoconf .es5 {color: #006699;}
+.autoconf.source-autoconf .br0 {color: #008000;}
+.autoconf.source-autoconf .sy0 {color: #008000;}
+.autoconf.source-autoconf .sy1 {color: #000080;}
+.autoconf.source-autoconf .sy2 {color: #000040;}
+.autoconf.source-autoconf .sy3 {color: #000040;}
+.autoconf.source-autoconf .sy4 {color: #008080;}
+.autoconf.source-autoconf .st0 {color: #996600;}
+.autoconf.source-autoconf .nu0 {color: #0000dd;}
+.autoconf.source-autoconf .nu6 {color: #208080;}
+.autoconf.source-autoconf .nu8 {color: #208080;}
+.autoconf.source-autoconf .nu12 {color: #208080;}
+.autoconf.source-autoconf .nu16 {color:#800080;}
+.autoconf.source-autoconf .nu17 {color:#800080;}
+.autoconf.source-autoconf .nu18 {color:#800080;}
+.autoconf.source-autoconf .nu19 {color:#800080;}
+.autoconf.source-autoconf .me1 {color: #202020;}
+.autoconf.source-autoconf .me2 {color: #202020;}
+.autoconf.source-autoconf .ln-xtra, .autoconf.source-autoconf li.ln-xtra, .autoconf.source-autoconf div.ln-xtra {background-color: #ffc;}
+.autoconf.source-autoconf span.xtra { display:block; }
+
+/*]]>*/
+</style>
+<style type="text/css">/*<![CDATA[*/
+@import "/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
+/*]]>*/
+</style><style type="text/css">/*<![CDATA[*/
+.source-c {line-height: normal;}
+.source-c li, .source-c pre {
+ line-height: normal; border: 0px none white;
+}
+/**
+ * GeSHi Dynamically Generated Stylesheet
+ * --------------------------------------
+ * Dynamically generated stylesheet for c
+ * CSS class: source-c, CSS id:
+ * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
+ * (http://qbnz.com/highlighter/ and http://geshi.org/)
+ * --------------------------------------
+ */
+.c.source-c .de1, .c.source-c .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
+.c.source-c {font-family:monospace;}
+.c.source-c .imp {font-weight: bold; color: red;}
+.c.source-c li, .c.source-c .li1 {font-weight: normal; vertical-align:top;}
+.c.source-c .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
+.c.source-c .li2 {font-weight: bold; vertical-align:top;}
+.c.source-c .kw1 {color: #b1b100;}
+.c.source-c .kw2 {color: #000000; font-weight: bold;}
+.c.source-c .kw3 {color: #000066;}
+.c.source-c .kw4 {color: #993333;}
+.c.source-c .co1 {color: #666666; font-style: italic;}
+.c.source-c .co2 {color: #339933;}
+.c.source-c .coMULTI {color: #808080; font-style: italic;}
+.c.source-c .es0 {color: #000099; font-weight: bold;}
+.c.source-c .es1 {color: #000099; font-weight: bold;}
+.c.source-c .es2 {color: #660099; font-weight: bold;}
+.c.source-c .es3 {color: #660099; font-weight: bold;}
+.c.source-c .es4 {color: #660099; font-weight: bold;}
+.c.source-c .es5 {color: #006699; font-weight: bold;}
+.c.source-c .br0 {color: #009900;}
+.c.source-c .sy0 {color: #339933;}
+.c.source-c .st0 {color: #ff0000;}
+.c.source-c .nu0 {color: #0000dd;}
+.c.source-c .nu6 {color: #208080;}
+.c.source-c .nu8 {color: #208080;}
+.c.source-c .nu12 {color: #208080;}
+.c.source-c .nu16 {color:#800080;}
+.c.source-c .nu17 {color:#800080;}
+.c.source-c .nu18 {color:#800080;}
+.c.source-c .nu19 {color:#800080;}
+.c.source-c .me1 {color: #202020;}
+.c.source-c .me2 {color: #202020;}
+.c.source-c .ln-xtra, .c.source-c li.ln-xtra, .c.source-c div.ln-xtra {background-color: #ffc;}
+.c.source-c span.xtra { display:block; }
+
+/*]]>*/
+</style>
+<style type="text/css">/*<![CDATA[*/
+@import "/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
+/*]]>*/
+</style><style type="text/css">/*<![CDATA[*/
+.source-make {line-height: normal;}
+.source-make li, .source-make pre {
+ line-height: normal; border: 0px none white;
+}
+/**
+ * GeSHi Dynamically Generated Stylesheet
+ * --------------------------------------
+ * Dynamically generated stylesheet for make
+ * CSS class: source-make, CSS id:
+ * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
+ * (http://qbnz.com/highlighter/ and http://geshi.org/)
+ * --------------------------------------
+ */
+.make.source-make .de1, .make.source-make .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
+.make.source-make {font-family:monospace;}
+.make.source-make .imp {font-weight: bold; color: red;}
+.make.source-make li, .make.source-make .li1 {font-weight: normal; vertical-align:top;}
+.make.source-make .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
+.make.source-make .li2 {font-weight: bold; vertical-align:top;}
+.make.source-make .kw1 {color: #666622; font-weight: bold;}
+.make.source-make .kw2 {color: #990000;}
+.make.source-make .co1 {color: #339900; font-style: italic;}
+.make.source-make .co2 {color: #000099; font-weight: bold;}
+.make.source-make .es0 {color: #000099; font-weight: bold;}
+.make.source-make .br0 {color: #004400;}
+.make.source-make .sy0 {color: #004400;}
+.make.source-make .st0 {color: #CC2200;}
+.make.source-make .nu0 {color: #CC2200;}
+.make.source-make .re0 {color: #000088; font-weight: bold;}
+.make.source-make .re1 {color: #0000CC; font-weight: bold;}
+.make.source-make .re2 {color: #000088;}
+.make.source-make .ln-xtra, .make.source-make li.ln-xtra, .make.source-make div.ln-xtra {background-color: #ffc;}
+.make.source-make span.xtra { display:block; }
+
+/*]]>*/
+</style>
+<style type="text/css">/*<![CDATA[*/
+@import "/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
+/*]]>*/
+</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/skins/vector/csshover.min.htc")}</style><![endif]--></head>
+<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-Porting_Newlib action-view skin-vector">
+ <div id="mw-page-base" class="noprint"></div>
+ <div id="mw-head-base" class="noprint"></div>
+ <!-- content -->
+ <div id="content">
+ <a id="top"></a>
+ <div id="mw-js-message" style="display:none;"></div>
+ <!-- firstHeading -->
+ <h1 id="firstHeading" class="firstHeading">Porting Newlib</h1>
+ <!-- /firstHeading -->
+ <!-- bodyContent -->
+ <div id="bodyContent">
+ <!-- tagline -->
+ <div id="siteSub">From OSDev Wiki</div>
+ <!-- /tagline -->
+ <!-- subtitle -->
+ <div id="contentSub"></div>
+ <!-- /subtitle -->
+ <!-- jumpto -->
+ <div id="jump-to-nav">
+ Jump to: <a href="#mw-head">navigation</a>,
+ <a href="#p-search">search</a>
+ </div>
+ <!-- /jumpto -->
+ <!-- bodycontent -->
+ <div lang="en" dir="ltr" class="mw-content-ltr"><table style="font-size:95%; line-height:1.5em; padding:0.25em; float:right; margin: 0 0 8px 15px; clear:right; border:1px solid #aaaaaa; background:#eee; text-align:center;;"><tr><th>Difficulty level</th></tr><tr><td><a href="/File:Difficulty_3.png" class="image"><img alt="Difficulty 3.png" src="/images/c/c1/Difficulty_3.png" width="46" height="14" /></a><br />Advanced</td></tr></table>
+<p>Newlib is a C library intended for use on embedded systems available under a free software license. It is known for being simple to port to new operating systems. Allegedly, it's coding practices are sometimes questionable. This tutorial follows <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a> and completes it using newlib rather than using another <a href="/C_Library" title="C Library">C Library</a> such as <a href="/Creating_a_C_Library" title="Creating a C Library">your own</a>.
+</p><p>Porting newlib is one of the easiest ways to get a simple C library into your operating system without an excessive amount of effort. As an added bonus, once complete you can port the toolchain (GCC/binutils) to your OS - and who wouldn't want to do that?
+</p>
+<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
+<ul>
+<li class="toclevel-1 tocsection-1"><a href="#Introduction"><span class="tocnumber">1</span> <span class="toctext">Introduction</span></a></li>
+<li class="toclevel-1 tocsection-2"><a href="#Preparation"><span class="tocnumber">2</span> <span class="toctext">Preparation</span></a>
+<ul>
+<li class="toclevel-2 tocsection-3"><a href="#Download_source_code_of_Automake_and_Autoconf"><span class="tocnumber">2.1</span> <span class="toctext">Download source code of Automake and Autoconf</span></a></li>
+</ul>
+</li>
+<li class="toclevel-1 tocsection-4"><a href="#System_Calls"><span class="tocnumber">3</span> <span class="toctext">System Calls</span></a></li>
+<li class="toclevel-1 tocsection-5"><a href="#Porting_Newlib"><span class="tocnumber">4</span> <span class="toctext">Porting Newlib</span></a>
+<ul>
+<li class="toclevel-2 tocsection-6"><a href="#config.sub"><span class="tocnumber">4.1</span> <span class="toctext">config.sub</span></a></li>
+<li class="toclevel-2 tocsection-7"><a href="#newlib.2Fconfigure.host"><span class="tocnumber">4.2</span> <span class="toctext">newlib/configure.host</span></a></li>
+<li class="toclevel-2 tocsection-8"><a href="#newlib.2Flibc.2Fsys.2Fconfigure.in"><span class="tocnumber">4.3</span> <span class="toctext">newlib/libc/sys/configure.in</span></a></li>
+<li class="toclevel-2 tocsection-9"><a href="#newlib.2Flibc.2Fsys.2Fmyos"><span class="tocnumber">4.4</span> <span class="toctext">newlib/libc/sys/myos</span></a></li>
+<li class="toclevel-2 tocsection-10"><a href="#newlib.2Flibc.2Fsys.2Fmyos.2Fcrt0.c"><span class="tocnumber">4.5</span> <span class="toctext">newlib/libc/sys/myos/crt0.c</span></a></li>
+<li class="toclevel-2 tocsection-11"><a href="#newlib.2Flibc.2Fsys.2Fmyos.2Fsyscalls.c"><span class="tocnumber">4.6</span> <span class="toctext">newlib/libc/sys/myos/syscalls.c</span></a></li>
+<li class="toclevel-2 tocsection-12"><a href="#newlib.2Flibc.2Fsys.2Fmyos.2Fconfigure.in"><span class="tocnumber">4.7</span> <span class="toctext">newlib/libc/sys/myos/configure.in</span></a></li>
+<li class="toclevel-2 tocsection-13"><a href="#newlib.2Flibc.2Fsys.2Fmyos.2FMakefile.am"><span class="tocnumber">4.8</span> <span class="toctext">newlib/libc/sys/myos/Makefile.am</span></a></li>
+<li class="toclevel-2 tocsection-14"><a href="#Signal_handling"><span class="tocnumber">4.9</span> <span class="toctext">Signal handling</span></a></li>
+</ul>
+</li>
+<li class="toclevel-1 tocsection-15"><a href="#Compiling"><span class="tocnumber">5</span> <span class="toctext">Compiling</span></a></li>
+<li class="toclevel-1 tocsection-16"><a href="#Conclusion"><span class="tocnumber">6</span> <span class="toctext">Conclusion</span></a></li>
+<li class="toclevel-1 tocsection-17"><a href="#See_Also"><span class="tocnumber">7</span> <span class="toctext">See Also</span></a>
+<ul>
+<li class="toclevel-2 tocsection-18"><a href="#Articles"><span class="tocnumber">7.1</span> <span class="toctext">Articles</span></a></li>
+</ul>
+</li>
+</ul>
+</td></tr></table>
+<h2> <span class="mw-headline" id="Introduction"> Introduction </span></h2>
+<p>I decided that after an incredibly difficult week of trying to get newlib ported to my own OS that I would write a tutorial that outlines the requirements for porting newlib and how to actually do it. I'm assuming you can already load binaries from somewhere and that these binaries are compiled C code. I also assume you have a syscall interface setup already. Why wait? Let's get cracking!
+</p>
+<h2> <span class="mw-headline" id="Preparation"> Preparation </span></h2>
+<p>Download newlib source (I'm using 2.5.0) from <a rel="nofollow" class="external text" href="ftp://sources.redhat.com/pub/newlib/index.html">this ftp server</a>.
+</p><p><br />
+</p>
+<h3> <span class="mw-headline" id="Download_source_code_of_Automake_and_Autoconf"> Download source code of Automake and Autoconf </span></h3>
+<p>Acquire Automake (v1.12) and Autoconf (v2.65) from here:
+<a rel="nofollow" class="external autonumber" href="https://ftp.gnu.org/gnu/automake/automake-1.12.tar.gz">[1]</a>
+<a rel="nofollow" class="external autonumber" href="https://ftp.gnu.org/gnu/autoconf/autoconf-2.65.tar.gz">[2]</a>
+</p><p><br />
+Untar both of the archives:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw2">tar</span> xvf automake-<span class="nu0">1.12</span>.tar.gz
+<span class="kw2">tar</span> xvf autoconf-<span class="nu0">2.65</span>.tar.gz</pre></div></div>
+<p>Create a destination folder:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw2">mkdir</span> ~<span class="sy0">/</span>bin</pre></div></div>
+<p>Create a build folder:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw2">mkdir</span> build
+<span class="kw3">cd</span> build</pre></div></div>
+<p>Configure automake first:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1">..<span class="sy0">/</span>automake-<span class="nu0">1.12</span><span class="sy0">/</span>configure <span class="re5">--prefix</span>=<span class="st0">&quot;~/bin&quot;</span></pre></div></div>
+<p>Make and install
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw2">make</span> <span class="sy0">&amp;&amp;</span> <span class="kw2">make</span> <span class="kw2">install</span></pre></div></div>
+<p>Now lets configure autoconf
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1">..<span class="sy0">/</span>autoconf-<span class="nu0">2.65</span><span class="sy0">/</span>configure <span class="re5">--prefix</span>=~<span class="sy0">/</span>bin</pre></div></div>
+<p>Then make and install:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw2">make</span> <span class="sy0">&amp;&amp;</span> <span class="kw2">make</span> <span class="kw2">install</span></pre></div></div>
+<p>You should now have the proper binaries in ~/bin!
+</p><p>To add these binaries to your path temporarily
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw3">export</span> <span class="re2">PATH</span>=~<span class="sy0">/</span>bin:<span class="re1">$PATH</span></pre></div></div>
+<h2> <span class="mw-headline" id="System_Calls"> System Calls </span></h2>
+<p>First of all you need to support a set of 17 system calls that act as 'glue' between newlib and your OS. These calls are the typical "_exit", "open", "read/write", "execve" (et al). See the <a rel="nofollow" class="external text" href="http://sourceware.org/newlib/libc.html#Syscalls">Red Hat newlib C library</a> documentation.
+</p><p>My kernel exposes all the system calls on interrupt 0x80 (128d) so I just had to put a bit of inline assembly into each stub to do what I needed it to do. It's up to you how to implement them in relation to your kernel.
+</p>
+<h2> <span class="mw-headline" id="Porting_Newlib"> Porting Newlib </span></h2>
+<h3> <span class="mw-headline" id="config.sub"> config.sub </span></h3>
+<p>Same as for binutils in <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a>.
+</p>
+<h3> <span class="mw-headline" id="newlib.2Fconfigure.host"> newlib/configure.host </span></h3>
+<p>Tell newlib which system-specific directory to use for our particular target. In the section starting 'Get the source directories to use for the host ... case "${host}" in', add a section:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1">i<span class="br0">&#91;</span><span class="nu0">3</span>-<span class="nu0">7</span><span class="br0">&#93;</span><span class="nu0">86</span>-<span class="sy0">*</span>-myos<span class="sy0">*</span><span class="br0">&#41;</span>
+ <span class="re2">sys_dir</span>=myos
+ <span class="sy0">;;</span></pre></div></div>
+<h3> <span class="mw-headline" id="newlib.2Flibc.2Fsys.2Fconfigure.in"> newlib/libc/sys/configure.in </span></h3>
+<p>Tell the newlib build system that it also needs to configure our myos-specific host directory. In the <tt>case ${sys_dir} in</tt> list, simply add
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="autoconf source-autoconf"><pre class="de1"> myos<span class="br0">&#41;</span> <span class="kw1">AC_CONFIG_SUBDIRS</span><span class="br0">&#40;</span>myos<span class="br0">&#41;</span> <span class="sy0">;;</span></pre></div></div>
+<p><b>Note:</b> After this, you need to run <tt>autoconf (precisely version 2.64)</tt> in the libc/sys directory.
+</p>
+<h3> <span class="mw-headline" id="newlib.2Flibc.2Fsys.2Fmyos"> newlib/libc/sys/myos </span></h3>
+<p>This is a directory that we need to create where we put our OS-specific extensions to newlib. We need to create a minimum of 4 files. You can easily add more files to this directory to define your own os-specific library functions, if you want them to be included in libc.a (and so linked in to every application by default).
+</p>
+<h3> <span class="mw-headline" id="newlib.2Flibc.2Fsys.2Fmyos.2Fcrt0.c"> newlib/libc/sys/myos/crt0.c </span></h3>
+<p>This file creates crt0.o, which is included in every application. It should define the symbol _start, and then call the main() function, possibly after setting up process-space segment selectors and pushing argc and argv onto the stack. A simple implementation is:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="c source-c"><pre class="de1"><span class="co2">#include &lt;fcntl.h&gt;</span>
+&#160;
+<span class="kw2">extern</span> <span class="kw4">void</span> <span class="kw3">exit</span><span class="br0">&#40;</span><span class="kw4">int</span> code<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw2">extern</span> <span class="kw4">int</span> main <span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
+&#160;
+<span class="kw4">void</span> _start<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
+ <span class="kw4">int</span> ex <span class="sy0">=</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
+ <span class="kw3">exit</span><span class="br0">&#40;</span>ex<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="br0">&#125;</span></pre></div></div>
+<p><b>Note:</b> add in argc and argv support based on how you handle them in your OS
+</p>
+<h3> <span class="mw-headline" id="newlib.2Flibc.2Fsys.2Fmyos.2Fsyscalls.c"> newlib/libc/sys/myos/syscalls.c </span></h3>
+<p>This file should contain the implementations for each glue function newlib requires.
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="c source-c"><pre class="de1"><span class="coMULTI">/* note these headers are all provided by newlib - you don't need to provide them */</span>
+<span class="co2">#include &lt;sys/stat.h&gt;</span>
+<span class="co2">#include &lt;sys/types.h&gt;</span>
+<span class="co2">#include &lt;sys/fcntl.h&gt;</span>
+<span class="co2">#include &lt;sys/times.h&gt;</span>
+<span class="co2">#include &lt;sys/errno.h&gt;</span>
+<span class="co2">#include &lt;sys/time.h&gt;</span>
+<span class="co2">#include &lt;stdio.h&gt;</span>
+&#160;
+<span class="kw4">void</span> _exit<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> close<span class="br0">&#40;</span><span class="kw4">int</span> file<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">char</span> <span class="sy0">**</span>environ<span class="sy0">;</span> <span class="coMULTI">/* pointer to array of char * strings that define the current environment variables */</span>
+<span class="kw4">int</span> execve<span class="br0">&#40;</span><span class="kw4">char</span> <span class="sy0">*</span>name<span class="sy0">,</span> <span class="kw4">char</span> <span class="sy0">**</span>argv<span class="sy0">,</span> <span class="kw4">char</span> <span class="sy0">**</span>env<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> fork<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> fstat<span class="br0">&#40;</span><span class="kw4">int</span> file<span class="sy0">,</span> <span class="kw4">struct</span> stat <span class="sy0">*</span>st<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> getpid<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> isatty<span class="br0">&#40;</span><span class="kw4">int</span> file<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> kill<span class="br0">&#40;</span><span class="kw4">int</span> pid<span class="sy0">,</span> <span class="kw4">int</span> sig<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> link<span class="br0">&#40;</span><span class="kw4">char</span> <span class="sy0">*</span>old<span class="sy0">,</span> <span class="kw4">char</span> <span class="sy0">*</span>new<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> lseek<span class="br0">&#40;</span><span class="kw4">int</span> file<span class="sy0">,</span> <span class="kw4">int</span> ptr<span class="sy0">,</span> <span class="kw4">int</span> dir<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> open<span class="br0">&#40;</span><span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span>name<span class="sy0">,</span> <span class="kw4">int</span> flags<span class="sy0">,</span> ...<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> read<span class="br0">&#40;</span><span class="kw4">int</span> file<span class="sy0">,</span> <span class="kw4">char</span> <span class="sy0">*</span>ptr<span class="sy0">,</span> <span class="kw4">int</span> len<span class="br0">&#41;</span><span class="sy0">;</span>
+caddr_t sbrk<span class="br0">&#40;</span><span class="kw4">int</span> incr<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> stat<span class="br0">&#40;</span><span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span>file<span class="sy0">,</span> <span class="kw4">struct</span> stat <span class="sy0">*</span>st<span class="br0">&#41;</span><span class="sy0">;</span>
+clock_t times<span class="br0">&#40;</span><span class="kw4">struct</span> tms <span class="sy0">*</span>buf<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> unlink<span class="br0">&#40;</span><span class="kw4">char</span> <span class="sy0">*</span>name<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> wait<span class="br0">&#40;</span><span class="kw4">int</span> <span class="sy0">*</span>status<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> write<span class="br0">&#40;</span><span class="kw4">int</span> file<span class="sy0">,</span> <span class="kw4">char</span> <span class="sy0">*</span>ptr<span class="sy0">,</span> <span class="kw4">int</span> len<span class="br0">&#41;</span><span class="sy0">;</span>
+<span class="kw4">int</span> gettimeofday<span class="br0">&#40;</span><span class="kw4">struct</span> timeval <span class="sy0">*</span>p<span class="sy0">,</span> <span class="kw4">struct</span> timezone <span class="sy0">*</span>z<span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>
+<p><b>Note</b>: You may split this up into multiple files, just don't forget to link against all of them in Makefile.am.
+</p>
+<h3> <span class="mw-headline" id="newlib.2Flibc.2Fsys.2Fmyos.2Fconfigure.in"> newlib/libc/sys/myos/configure.in </span></h3>
+<p>Configure script for our system directory.
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1">AC_PREREQ<span class="br0">&#40;</span><span class="nu0">2.59</span><span class="br0">&#41;</span>
+AC_INIT<span class="br0">&#40;</span><span class="br0">&#91;</span>newlib<span class="br0">&#93;</span>, <span class="br0">&#91;</span>NEWLIB_VERSION<span class="br0">&#93;</span><span class="br0">&#41;</span>
+AC_CONFIG_SRCDIR<span class="br0">&#40;</span><span class="br0">&#91;</span>crt0.c<span class="br0">&#93;</span><span class="br0">&#41;</span>
+AC_CONFIG_AUX_DIR<span class="br0">&#40;</span>..<span class="sy0">/</span>..<span class="sy0">/</span>..<span class="sy0">/</span>..<span class="br0">&#41;</span>
+NEWLIB_CONFIGURE<span class="br0">&#40;</span>..<span class="sy0">/</span>..<span class="sy0">/</span>..<span class="br0">&#41;</span>
+AC_CONFIG_FILES<span class="br0">&#40;</span><span class="br0">&#91;</span>Makefile<span class="br0">&#93;</span><span class="br0">&#41;</span>
+AC_OUTPUT</pre></div></div>
+<h3> <span class="mw-headline" id="newlib.2Flibc.2Fsys.2Fmyos.2FMakefile.am"> newlib/libc/sys/myos/Makefile.am </span></h3>
+<p>A Makefile template for this directory:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="make source-make"><pre class="de1">AUTOMAKE_OPTIONS <span class="sy0">=</span> cygnus
+INCLUDES <span class="sy0">=</span> <span class="sy0">$</span><span class="br0">&#40;</span><span class="re2">NEWLIB_CFLAGS</span><span class="br0">&#41;</span> <span class="sy0">$</span><span class="br0">&#40;</span><span class="re2">CROSS_CFLAGS</span><span class="br0">&#41;</span> <span class="sy0">$</span><span class="br0">&#40;</span><span class="re2">TARGET_CFLAGS</span><span class="br0">&#41;</span>
+AM_CCASFLAGS <span class="sy0">=</span> <span class="sy0">$</span><span class="br0">&#40;</span><span class="re2">INCLUDES</span><span class="br0">&#41;</span>
+&#160;
+noinst_LIBRARIES <span class="sy0">=</span> lib<span class="sy0">.</span>a
+&#160;
+if MAY_SUPPLY_SYSCALLS
+extra_objs <span class="sy0">=</span> syscalls<span class="sy0">.</span>o <span class="co1"># add more object files here if you split up</span>
+<span class="kw1">else</span> <span class="co1"># syscalls.c into multiple files in the previous step</span>
+extra_objs <span class="sy0">=</span>
+<span class="kw1">endif</span>
+&#160;
+lib_a_SOURCES <span class="sy0">=</span>
+lib_a_LIBADD <span class="sy0">=</span> <span class="sy0">$</span><span class="br0">&#40;</span><span class="re2">extra_objs</span><span class="br0">&#41;</span>
+EXTRA_lib_a_SOURCES <span class="sy0">=</span> syscalls<span class="sy0">.</span>c crt0<span class="sy0">.</span>c <span class="co1"># add more source files here if you split up</span>
+lib_a_DEPENDENCIES <span class="sy0">=</span> <span class="sy0">$</span><span class="br0">&#40;</span><span class="re2">extra_objs</span><span class="br0">&#41;</span> <span class="co1"># syscalls.c into multiple files</span>
+lib_a_CCASFLAGS <span class="sy0">=</span> <span class="sy0">$</span><span class="br0">&#40;</span><span class="re2">AM_CCASFLAGS</span><span class="br0">&#41;</span>
+lib_a_CFLAGS <span class="sy0">=</span> <span class="sy0">$</span><span class="br0">&#40;</span><span class="re2">AM_CFLAGS</span><span class="br0">&#41;</span>
+&#160;
+if MAY_SUPPLY_SYSCALLS
+all<span class="sy0">:</span> crt0<span class="sy0">.</span>o
+<span class="kw1">endif</span>
+&#160;
+ACLOCAL_AMFLAGS <span class="sy0">=</span> <span class="sy0">-</span>I <span class="sy0">../../..</span>
+CONFIG_STATUS_DEPENDENCIES <span class="sy0">=</span> <span class="sy0">$</span><span class="br0">&#40;</span><span class="re2">newlib_basedir</span><span class="br0">&#41;</span><span class="sy0">/</span>configure<span class="sy0">.</span>host</pre></div></div>
+<p><b>Note</b>: After this, you need to run <tt>autoconf</tt> in the newlib/libc/sys/ directory, and <tt>autoreconf</tt> in the newlib/libc/sys/myos directory.
+</p>
+<h3> <span class="mw-headline" id="Signal_handling"> Signal handling </span></h3>
+<p>Newlib has two different mechanisms for dealing with UNIX signals (see the man pages for signal()/raise()). In the first, it provides its own emulation, where it maintains a table of signal handlers in a per-process manner. If you use this method, then you will only be able to respond to signals sent from within the current process. In order to support it, all you need to do is make sure your crt0 calls '_init_signal' before it calls main, which sets up the signal handler table.
+</p><p>Alternatively, you can provide your own implementation. To do this, you need to define your own version of signal() in syscalls.c. A typical implementation would register the handler somewhere in kernel space, so that issuing a signal from another process causes the corresponding function to be called in the receiving process (this will also require some nifty stack-playing in the receiving process, as you are basically interrupting the program flow in the middle). You then need to provide a kill() function in syscalls.c which actually sends signals to another process. Newlib will still define a raise() function for you, but it is just a stub which calls kill() with the current process id. To switch newlib to this mode, you need to #define the SIGNAL_PROVIDED macro when compiling. A simple way to do this is to add the line:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="re2">newlib_cflags</span>=<span class="st0">&quot;<span class="es3">${newlib_cflags}</span> -DSIGNAL_PROVIDED&quot;</span></pre></div></div>
+<p>to your host's entry in <tt>configure.host</tt>. It would probably also make sense to provide sigaction(), and provide signal() as a wrapper for it. Note that <a rel="nofollow" class="external text" href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html">the Open Group's</a> definition of sigaction states that 1) sigaction supersedes signal, and 2) an application designed shouldn't use both to manipulate the same signal.
+</p>
+<h2> <span class="mw-headline" id="Compiling"> Compiling </span></h2>
+<p>You can build newlib in this manner:
+Newlib is very pesky about the compiler, and you probably haven't built your own i686-myos-gcc toolchain yet, meaning that configure will not be happy when you set target to i686-myos. So use this hack to get it to work (it worked fine for me).
+</p><p><b>Note:</b> there must be a better way then this.
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="co0"># newlib setup</span>
+<span class="re2">CURRDIR</span>=$<span class="br0">&#40;</span><span class="kw3">pwd</span><span class="br0">&#41;</span>
+&#160;
+<span class="co0"># make symlinks (a bad hack) to make newlib work</span>
+<span class="kw3">cd</span> ~<span class="sy0">/</span>cross<span class="sy0">/</span>bin<span class="sy0">/</span> <span class="co0"># this is where the bootstrapped generic cross compiler toolchain (i686-elf-xxx) is installed in,</span>
+ <span class="co0"># change this based on your development environment.</span>
+<span class="kw2">ln</span> i686-elf-ar i686-myos-ar
+<span class="kw2">ln</span> i686-elf-as i686-myos-as
+<span class="kw2">ln</span> i686-elf-gcc i686-myos-gcc
+<span class="kw2">ln</span> i686-elf-gcc i686-myos-cc
+<span class="kw2">ln</span> i686-elf-ranlib i686-myos-ranlib
+&#160;
+<span class="co0"># return</span>
+<span class="kw3">cd</span> <span class="re1">$CURRDIR</span></pre></div></div>
+<p>Then run the following commands to build newlib
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw2">mkdir</span> build-newlib
+<span class="kw3">cd</span> build-newlib
+..<span class="sy0">/</span>newlib-x.y.z<span class="sy0">/</span>configure <span class="re5">--prefix</span>=<span class="sy0">/</span>usr <span class="re5">--target</span>=i686-myos
+<span class="kw2">make</span> all
+<span class="kw2">make</span> <span class="re2">DESTDIR</span>=<span class="co1">${SYSROOT}</span> <span class="kw2">install</span></pre></div></div>
+<p><b>Note:</b> SYSROOT is where all your OS-specific toolchains will be installed in. It will look like a miniature version of the Linux filesystem, but have your OS-specific toolchains in; I am using ~/myos as my SYSROOT directory.
+</p><p>For some reason, the newer versions of newlib (at least for me) didn't put the libraries in a location where other utilities like binutils could find.
+So here's another hack to fix this:
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1"><span class="kw2">cp</span> <span class="re5">-ar</span> <span class="re1">$SYSROOT</span><span class="sy0">/</span>usr<span class="sy0">/</span>i386-myos<span class="sy0">/*</span> <span class="re1">$SYSROOT</span><span class="sy0">/</span>usr<span class="sy0">/</span></pre></div></div>
+<p>After building all of this, your freshly built libc will be installed in your SYSROOT directory! Now you can progress to building your own <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a>.
+</p><p><b>Important Note:</b> I found that for newlib to properly work, you have to link against libc, libg, libm, and libnosys - hence when porting gcc, in
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="c source-c"><pre class="de1"><span class="co2">#define LIB_SPEC ...</span></pre></div></div>
+<p>in gcc/config/myos.h,
+</p><p>make sure you put
+</p>
+<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="c source-c"><pre class="de1"><span class="co2">#define LIB_SPEC &quot;-lc -lg -lm -lnosys&quot;</span></pre></div></div>
+<p>at the bare minimum.
+</p><p>I highly recommend rebuilding the library with your <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a> after you are done porting one. (don't forget to remove the symlinks, too.)
+</p>
+<h2> <span class="mw-headline" id="Conclusion"> Conclusion </span></h2>
+<p>Well, you've done it. You've ported newlib to your OS! With this you can start creating user mode programs with ease! You may now also add in new functions to newlib, such as dlopen(), dlclose(), dlsym(), and dlerror() for dynamic linking support. Your operating system has a bright road ahead! You can now port the toolchain and run binutils and GCC on your own OS. Almost self-hosting, how do you feel?
+</p><p>Good luck!
+</p><p>Last Updated by <b>0fb1d8</b> for compatibility with newer versions of newlib and the <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a> tutorial.
+</p><p><b>Note:</b> I used a lot of hacks in this article, if you find a better way to do something, please contribute to the page. Thank you.
+</p>
+<h2> <span class="mw-headline" id="See_Also"> See Also </span></h2>
+<h3> <span class="mw-headline" id="Articles"> Articles </span></h3>
+<ul><li> <a href="/GCC_Cross-Compiler" title="GCC Cross-Compiler">GCC Cross-Compiler</a>
+</li><li> <a href="/OS_Specific_Toolchain" title="OS Specific Toolchain">OS Specific Toolchain</a>
+</li></ul>
+
+<!--
+NewPP limit report
+Preprocessor node count: 399/1000000
+Post-expand include size: 372/2097152 bytes
+Template argument size: 84/2097152 bytes
+Expensive parser function count: 0/100
+-->
+
+<!-- Saved in parser cache with key wikidb:pcache:idhash:2126-0!*!0!!en!2!* and timestamp 20181010182943 -->
+</div> <!-- /bodycontent -->
+ <!-- printfooter -->
+ <div class="printfooter">
+ Retrieved from "<a href="https://wiki.osdev.org/index.php?title=Porting_Newlib&amp;oldid=22427">https://wiki.osdev.org/index.php?title=Porting_Newlib&amp;oldid=22427</a>" </div>
+ <!-- /printfooter -->
+ <!-- catlinks -->
+ <div id='catlinks' class='catlinks'><div id="mw-normal-catlinks"><a href="/Special:Categories" title="Special:Categories">Categories</a>: <ul><li><a href="/Category:Level_3_Tutorials" title="Category:Level 3 Tutorials">Level 3 Tutorials</a></li><li><a href="/Category:Tutorials" title="Category:Tutorials">Tutorials</a></li></ul></div></div> <!-- /catlinks -->
+ <div class="visualClear"></div>
+ <!-- debughtml -->
+ <!-- /debughtml -->
+ </div>
+ <!-- /bodyContent -->
+ </div>
+ <!-- /content -->
+ <!-- header -->
+ <div id="mw-head" class="noprint">
+
+<!-- 0 -->
+<div id="p-personal" class="">
+ <h5>Personal tools</h5>
+ <ul>
+ <li id="pt-login"><a href="/index.php?title=Special:UserLogin&amp;returnto=Porting_Newlib" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o">Log in</a></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+ <div id="left-navigation">
+
+<!-- 0 -->
+<div id="p-namespaces" class="vectorTabs">
+ <h5>Namespaces</h5>
+ <ul>
+ <li id="ca-nstab-main" class="selected"><span><a href="/Porting_Newlib" title="View the content page [c]" accesskey="c">Page</a></span></li>
+ <li id="ca-talk"><span><a href="/Talk:Porting_Newlib" title="Discussion about the content page [t]" accesskey="t">Discussion</a></span></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+
+<!-- 1 -->
+<div id="p-variants" class="vectorMenu emptyPortlet">
+ <h5><span>Variants</span><a href="#"></a></h5>
+ <div class="menu">
+ <ul>
+ </ul>
+ </div>
+</div>
+
+<!-- /1 -->
+ </div>
+ <div id="right-navigation">
+
+<!-- 0 -->
+<div id="p-views" class="vectorTabs">
+ <h5>Views</h5>
+ <ul>
+ <li id="ca-view" class="selected"><span><a href="/Porting_Newlib" >Read</a></span></li>
+ <li id="ca-viewsource"><span><a href="/index.php?title=Porting_Newlib&amp;action=edit" title="This page is protected.&#10;You can view its source [e]" accesskey="e">View source</a></span></li>
+ <li id="ca-history" class="collapsible"><span><a href="/index.php?title=Porting_Newlib&amp;action=history" title="Past revisions of this page [h]" accesskey="h">View history</a></span></li>
+ </ul>
+</div>
+
+<!-- /0 -->
+
+<!-- 1 -->
+<div id="p-cactions" class="vectorMenu emptyPortlet">
+ <h5><span>Actions</span><a href="#"></a></h5>
+ <div class="menu">
+ <ul>
+ </ul>
+ </div>
+</div>
+
+<!-- /1 -->
+
+<!-- 2 -->
+<div id="p-search">
+ <h5><label for="searchInput">Search</label></h5>
+ <form action="/index.php" id="searchform">
+ <input type='hidden' name="title" value="Special:Search"/>
+ <input type="search" name="search" title="Search OSDev Wiki [f]" accesskey="f" id="searchInput" /> <input type="submit" name="go" value="Go" title="Go to a page with this exact name if exists" id="searchGoButton" class="searchButton" /> <input type="submit" name="fulltext" value="Search" title="Search the pages for this text" id="mw-searchButton" class="searchButton" /> </form>
+</div>
+
+<!-- /2 -->
+ </div>
+ </div>
+ <!-- /header -->
+ <!-- panel -->
+ <div id="mw-panel" class="noprint">
+ <!-- logo -->
+ <div id="p-logo"><a style="background-image: url(/skins/common/images/osdev.png);" href="/Main_Page" title="Visit the main page"></a></div>
+ <!-- /logo -->
+
+<!-- navigation -->
+<div class="portal" id='p-navigation'>
+ <h5>Navigation</h5>
+ <div class="body">
+ <ul>
+ <li id="n-mainpage"><a href="/Main_Page" title="Visit the main page [z]" accesskey="z">Main Page</a></li>
+ <li id="n-portal"><a href="http://forum.osdev.org/" rel="nofollow" title="About the project, what you can do, where to find things">Forums</a></li>
+ <li id="n-FAQ"><a href="/Category:FAQ">FAQ</a></li>
+ <li id="n-OS-Projects"><a href="/Projects">OS Projects</a></li>
+ <li id="n-randompage"><a href="/Special:Random" title="Load a random page [x]" accesskey="x">Random page</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /navigation -->
+
+<!-- about -->
+<div class="portal" id='p-about'>
+ <h5>About</h5>
+ <div class="body">
+ <ul>
+ <li id="n-This-site"><a href="/OSDevWiki:About">This site</a></li>
+ <li id="n-Joining"><a href="/OSDevWiki:Joining">Joining</a></li>
+ <li id="n-Editing-help"><a href="/OSDevWiki:Editing">Editing help</a></li>
+ <li id="n-recentchanges"><a href="/Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /about -->
+
+<!-- SEARCH -->
+
+<!-- /SEARCH -->
+
+<!-- TOOLBOX -->
+<div class="portal" id='p-tb'>
+ <h5>Toolbox</h5>
+ <div class="body">
+ <ul>
+ <li id="t-whatlinkshere"><a href="/Special:WhatLinksHere/Porting_Newlib" title="A list of all wiki pages that link here [j]" accesskey="j">What links here</a></li>
+ <li id="t-recentchangeslinked"><a href="/Special:RecentChangesLinked/Porting_Newlib" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li>
+ <li id="t-specialpages"><a href="/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q">Special pages</a></li>
+ <li><a href="/index.php?title=Porting_Newlib&amp;printable=yes" rel="alternate">Printable version</a></li>
+ <li id="t-permalink"><a href="/index.php?title=Porting_Newlib&amp;oldid=22427" title="Permanent link to this revision of the page">Permanent link</a></li>
+ </ul>
+ </div>
+</div>
+
+<!-- /TOOLBOX -->
+
+<!-- LANGUAGES -->
+
+<!-- /LANGUAGES -->
+ </div>
+ <!-- /panel -->
+ <!-- footer -->
+ <div id="footer">
+ <ul id="footer-info">
+ <li id="footer-info-lastmod"> This page was last modified on 5 June 2018, at 08:43.</li>
+ <li id="footer-info-viewcount">This page has been accessed 93,161 times.</li>
+ </ul>
+ <ul id="footer-places">
+ <li id="footer-places-privacy"><a href="/OSDev_Wiki:Privacy_policy" title="OSDev Wiki:Privacy policy">Privacy policy</a></li>
+ <li id="footer-places-about"><a href="/OSDev_Wiki:About" title="OSDev Wiki:About">About OSDev Wiki</a></li>
+ <li id="footer-places-disclaimer"><a href="/OSDev_Wiki:General_disclaimer" title="OSDev Wiki:General disclaimer">Disclaimers</a></li>
+ </ul>
+ <ul id="footer-icons" class="noprint">
+ <li id="footer-poweredbyico">
+ <a href="http://www.mediawiki.org/"><img src="/skins/common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" width="88" height="31" /></a>
+ </li>
+ </ul>
+ <div style="clear:both"></div>
+ </div>
+ <!-- /footer -->
+ <!-- fixalpha -->
+ <script type="text/javascript"> if ( window.isMSIE55 ) fixalpha(); </script>
+ <!-- /fixalpha -->
+ <script src="/load.php?debug=false&amp;lang=en&amp;modules=skins.vector&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.loader.load(["mediawiki.user", "mediawiki.util", "mediawiki.page.ready", "mediawiki.legacy.wikibits", "mediawiki.legacy.ajax"]);
+}
+</script>
+<script src="/load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=scripts&amp;skin=vector&amp;*"></script>
+<script>if(window.mw){
+ mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":1,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"highlightbroken":1,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":1,"showtoolbar":1,"skin":"vector","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,"watchlistdays":3,"watchlisthideanons":0,
+ "watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false});;mw.user.tokens.set({"editToken":"+\\","watchToken":false});;mw.loader.state({"user.options":"ready","user.tokens":"ready"});
+
+ /* cache key: wikidb:resourceloader:filter:minify-js:4:19a4b18a9ac79a6b8c60b24af4668814 */
+}
+</script><!-- Served in 0.040 secs. -->
+ </body>
+</html>
diff --git a/ref/README b/ref/README
new file mode 100644
index 0000000..70d9e39
--- /dev/null
+++ b/ref/README
@@ -0,0 +1 @@
+https://wiki.osdev.org/
diff --git a/userspace/Makefile b/userspace/Makefile
index f7d0ae5..dc5509c 100644
--- a/userspace/Makefile
+++ b/userspace/Makefile
@@ -1,4 +1,4 @@
-IMAGESIZE=40000 #ext2.img size in Kb
+IMAGESIZE=60000 #ext2.img size in Kb
#######################
@@ -36,6 +36,7 @@ ext2.img: $(PROGS)
make -C fonts
make -C xterm
make -C cpp
+ make -C ncurses
@echo "----------------------"
@echo "Creating ext2.img ...."
@dd if=/dev/zero of=ext2.img bs=1024 count=$(IMAGESIZE)
@@ -54,6 +55,8 @@ ext2.img: $(PROGS)
@cp fonts/binfont.bin mnt/doc/fonts
@cp xterm/xterm mnt/bin
@cp cpp/testcpp mnt/bin
+ @cp ncurses/ncurs mnt/bin
+ @cp /home/miguel/temp/foolos/usr/bin/* mnt/bin
# cp ~/temp/fool-os-stuff/binutils-build-host-foolos/binutils/readelf mnt/bin
# cp ../font/binfont.bin mnt/
@@ -77,6 +80,11 @@ clean:
make -C fonts clean
make -C xterm clean
make -C cpp clean
+ make -C ncurses clean
@echo "Cleaning userspace ..."; rm -f *.o $(PROGS) ext2.img *.d
+umount:
+ sudo umount mnt
+ rm mnt -r
+
new: clean all
diff --git a/userspace/clear.c b/userspace/myclear.c
index 1c794b8..1c794b8 100644
--- a/userspace/clear.c
+++ b/userspace/myclear.c
diff --git a/userspace/ncurses/Makefile b/userspace/ncurses/Makefile
new file mode 100644
index 0000000..4a8fc56
--- /dev/null
+++ b/userspace/ncurses/Makefile
@@ -0,0 +1,10 @@
+CC=i686-foolos-gcc
+AS=i686-foolos-as
+
+LDLIBS=-lncurses -lcurses
+CFLAGS=-static
+
+ncurs:
+
+clean:
+ rm -f *.o ncurs
diff --git a/userspace/ncurses/ncurs.c b/userspace/ncurses/ncurs.c
new file mode 100644
index 0000000..6edf8e6
--- /dev/null
+++ b/userspace/ncurses/ncurs.c
@@ -0,0 +1,13 @@
+#include <ncurses.h>
+
+int main()
+{
+
+// initscr(); /* Start curses mode */
+// printw("Hello World !!!"); /* Print Hello World */
+// refresh(); /* Print it on to the real screen */
+// getch(); /* Wait for user input */
+// endwin(); /* End curses mode */
+
+ return 0;
+}
diff --git a/xxx/packages/ncurses-5.9/termios.h b/xxx/packages/ncurses-5.9/termios.h
index 98ae1b7..e38434d 100644
--- a/xxx/packages/ncurses-5.9/termios.h
+++ b/xxx/packages/ncurses-5.9/termios.h
@@ -25,7 +25,7 @@ struct __dirstream
//https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/dirstream.h;h=8303f07fab6f6efaa39e51411ef924e712d995e0;hb=fa39685d5c7df2502213418bead44e9543a9b9ec
};
-typedef uint32_t __ino_t;
+//typedef uint32_t __ino_t;
struct dirent
{
@@ -36,19 +36,19 @@ struct dirent
char d_name[256]; /* We must not include limits.h! */
int d_namlen;
};
-#define direct dirent
+#define direct dirent
typedef struct __dirstream DIR;
#include <sys/time.h>
-
typedef unsigned char cc_t;
typedef unsigned int speed_t;
typedef unsigned int tcflag_t;
#define NCCS 32
+
struct termios
{
tcflag_t c_iflag; /* input mode flags */
@@ -242,8 +242,8 @@ struct termios
#define _IOT_termios /* Hurd ioctl type field. */ \
_IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
- int tcgetattr(int fd, struct termios *termios_p);
- int tcsetattr(int fd, int optional_actions, const struct termios *termios_p);
+ // int tcgetattr(int fd, struct termios *termios_p);
+ // int tcsetattr(int fd, int optional_actions, const struct termios *termios_p);
/**
int tcsendbreak(int fd, int duration);
@@ -254,13 +254,13 @@ struct termios
int tcflow(int fd, int action);
*/
- void cfmakeraw(struct termios *termios_p);
+ // void cfmakeraw(struct termios *termios_p);
/*
speed_t cfgetispeed(const struct termios *termios_p);
*/
- speed_t cfgetospeed(const struct termios *termios_p);
+// speed_t cfgetospeed(const struct termios *termios_p);
/*
int cfsetispeed(struct termios *termios_p, speed_t speed);