[Unattended-Dev] Steps to build linuxboot

Slava Pechenin <[email protected]> Mon, 21 May 2012 15:34:16 +0300
Newsgroups gmane.comp.windows.unattended.devel
Message-ID <CAKtgTK6mgAAV2w-zp4x=Yby8zbL6RZJiGxmiATnwsXX=u7gzrw@mail.gmail.com>
Hi developers

I finally managed to build linuxboot in Ubuntu 12.04, gcc 4.6.3
I faced some troubles so here they are to maybe help somebody

To build linuxboot apply Makefile.patch, move glibc-i686.patch and
slang.patch to linuxboot/misc.

1) make download, some links are broken

2) sf.net/.../parted-1.6.22.tar.gz file is broken, but builds without errors
$ ls -l /var/tmp/parted-1.6.22.tar.gz
-rw------- 1 slava slava 1497993 мая   21 13:52 /var/tmp/parted-1.6.22.tar.gz
$ gzip -t /var/tmp/parted-1.6.22.tar.gz
gzip: /var/tmp/parted-1.6.22.tar.gz: unexpected end of file

3) glibc does not compile, needs a patch
../sysdeps/i386/fpu/s_frexp.S: Assembler messages:
../sysdeps/i386/fpu/s_frexp.S:66: Error: invalid identifier for ".ifdef"
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first
unrecognized character is `1'
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first
unrecognized character is `1'
../sysdeps/i386/fpu/s_frexp.S:66: Error: Missing symbol name in directive

4) busybox, does not use CFLAGS_EXTRA
networking/udhcp/lib.a(dhcpc.o): In function `udhcpc_main':
dhcpc.c:(.text.udhcpc_main+0x5e3): undefined reference to `__fdelt_chk'

5) dosemu fails to link without additional library search path
"build-glibc-2.13/math"
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libm.so:
undefined reference to `__get_cpu_features@GLIBC_PRIVATE'

6) slang needs a patch to compile
/usr/bin/ld: slang-2.0.7/src/objs/libslang.a(slcommon.o): undefined
reference to symbol '__libc_enable_secure@@GLIBC_PRIVATE'

7) usbutils doesn't build because libusb must know about fakelib_cflags
stage1/lib/libusb.so: undefined reference to `__fdelt_chk@GLIBC_2.15'

8) parted must be linked with libdl
../../libparted/.libs/libparted.so: undefined reference to `dlopen'
../../libparted/.libs/libparted.so: undefined reference to `dlclose'
../../libparted/.libs/libparted.so: undefined reference to `dlerror'
../../libparted/.libs/libparted.so: undefined reference to `dlsym'

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________
unattended-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unattended-devel
slang.patch (application/octet-stream, 407 B)
--- slang-2.0.7/src/slcommon.c.orig	2006-11-04 17:57:31.000000000 +0200
+++ slang-2.0.7/src/slcommon.c	2012-05-18 17:44:26.957975637 +0300
@@ -191,7 +191,7 @@
    return p;
 }
 
-#if !defined(HAVE_ISSETUGID) && defined(__GLIBC__) && (__GLIBC__ >= 2)
+#if !defined(HAVE_ISSETUGID) && defined(__GLIBC__) && (__GLIBC__ >= 2) && 0
 extern int __libc_enable_secure;
 # define HAVE___LIBC_ENABLE_SECURE 1
 #endif
glibc-i686.patch (application/octet-stream, 2.5 KB)
Submitted By:            Matt Burgess <matthew_at_linuxfromscratch_dot_org>
Date:                    2010-04-18
Initial Package Version: 2.11.1
Upstream Status:         Not Submitted
Origin:                  http://www.eglibc.org/archives/patches/msg00073.html
Description:             Fixes the following build problem with GCC-4.5.0:

/mnt/lfs/sources/libc-build/math/s_frexp.os.dt -MT /mnt/lfs/sources/libc-build/math/s_frexp.os
./sysdeps/i386/fpu/s_frexp.S: Assembler messages:
./sysdeps/i386/fpu/s_frexp.S:66: Error: invalid identifier for ".ifdef"
./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `.'
./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
./sysdeps/i386/fpu/s_frexp.S:66: Error: expected comma after name `' in .size directive
./sysdeps/i386/fpu/s_frexp.S:66: Error: ".endif" without ".if"
./sysdeps/i386/fpu/s_frexp.S:66: Error: junk `.get_pc_thunk.dx' after expression
make[2]: *** [/mnt/lfs/sources/libc-build/math/s_frexp.os] Error 1

diff -Naur glibc-2.11.1.orig/nptl/sysdeps/pthread/pt-initfini.c glibc-2.11.1/nptl/sysdeps/pthread/pt-initfini.c
--- glibc-2.11.1.orig/nptl/sysdeps/pthread/pt-initfini.c	2009-12-08 20:10:20.000000000 +0000
+++ glibc-2.11.1/nptl/sysdeps/pthread/pt-initfini.c	2010-04-17 11:34:06.882681001 +0000
@@ -45,6 +45,11 @@
 /* Embed an #include to pull in the alignment and .end directives. */
 asm ("\n#include \"defs.h\"");
 
+asm ("\n#if defined __i686 && defined __ASSEMBLER__");
+asm ("\n#undef __i686");
+asm ("\n#define __i686 __i686");
+asm ("\n#endif");
+
 /* The initial common code ends here. */
 asm ("\n/*@HEADER_ENDS*/");
 
diff -Naur glibc-2.11.1.orig/sysdeps/unix/sysv/linux/i386/sysdep.h glibc-2.11.1/sysdeps/unix/sysv/linux/i386/sysdep.h
--- glibc-2.11.1.orig/sysdeps/unix/sysv/linux/i386/sysdep.h	2009-12-08 20:10:20.000000000 +0000
+++ glibc-2.11.1/sysdeps/unix/sysv/linux/i386/sysdep.h	2010-04-17 11:34:06.882681001 +0000
@@ -29,6 +29,10 @@
 #include <dl-sysdep.h>
 #include <tls.h>
 
+#if defined __i686 && defined __ASSEMBLER__
+#undef __i686
+#define __i686 __i686
+#endif
 
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
Makefile.patch (application/octet-stream, 3.2 KB)
--- svn-3468/linuxboot/Makefile	2012-05-16 12:27:54.017239188 +0300
+++ work/linuxboot/Makefile	2012-05-21 13:50:59.996148246 +0300
@@ -200,7 +200,11 @@
 	cp $< $@
 	[ -e $@ ] && touch $@
 
-$(slang)/src/objs/libslang.a: stage1/lib/libdl.so $(slang)/configure
+$(slang)/.stamp-slang-patch: misc/slang.patch
+	cd $(slang) && patch -b -p1 < $(cwd)/$<
+	touch $@
+
+$(slang)/src/objs/libslang.a: $(slang)/.stamp-slang-patch stage1/lib/libdl.so $(slang)/configure
 	rm -f $@
 	cd $(slang)						\
 	&& CC="$(CC) $(fakelib_cflags)" ./configure		\
@@ -312,10 +316,15 @@
 	sed -ie "s| gcc -E | $(CC) -E |" $(glibc)/locale/gen-translit.pl
 	touch $@
 
+$(glibc)/.stamp-glibc-i686-patch: misc/glibc-i686.patch
+	cd $(glibc) && patch -b -p1 < $(cwd)/$<
+	touch $@
+
 ## glibc
 # Configure switches cheerfully stolen from LFS project
 # (http://www.linuxfromscratch.org/lfs/view/development/chapter05/glibc.html).
 build-$(glibc)/libc.so: $(linux)/arch/x86/boot/bzImage	\
+			$(glibc)/.stamp-glibc-i686-patch \
 			$(glibc)/.stamp-glibc-gen-translit.pl-patch
 	mkdir -p build-$(glibc)
 	cd build-$(glibc) && CC="$(CC)" CFLAGS="-O2 -U_FORTIFY_SOURCE -fno-stack-protector $(CFLAGS)"	\
@@ -360,6 +369,7 @@
 # FIXME: Should include -nostdinc here
 fakelib_cflags=-isystem $(cwd)/fakeinclude -L$(cwd)/fakelib	\
 	-L$(cwd)/stage1/lib -L$(cwd)/stage1/usr/lib		\
+        -L$(cwd)/build-$(glibc)/math                            \
 	-Wl,-rpath-link,$(cwd)/stage1/lib
 
 # Create empty config file to silence ldconfig warnings
@@ -484,7 +494,7 @@
 				stage1/lib/libdl.so
 	cd $(parted)							\
 	&& CC="$(CC)" CXX="$(CXX)"						\
-		CFLAGS="$(fakelib_cflags) -I$(cwd)/$(e2fsprogs)/lib"	\
+		CFLAGS="$(fakelib_cflags) -I$(cwd)/$(e2fsprogs)/lib -ldl"	\
 		./configure --disable-nls --without-readline		\
 		--build=i586-linux --disable-Werror			\
 	&& $(MAKE)
@@ -800,7 +810,7 @@
 ## libusb
 $(libusb)/.libs/libusb-0.1.so.4.4.4:
 	cd $(libusb)						\
-	&& CC="$(CC)" CXX="$(CXX)" ./configure --disable-static		\
+	&& CC="$(CC)" CXX="$(CXX)" CPPFLAGS="$(fakelib_cflags)" ./configure --disable-static		\
 	                        --build=i586-linux		\
 	                        --disable-dependency-tracking	\
 	&&  $(MAKE)
@@ -1037,7 +1047,7 @@
 #	:pserver:[email protected]:/cvs/glibc)
 $(call download_rule, $(glibc), tar.bz2, http://ftp.gnu.org/gnu/glibc/)
 $(call download_rule, $(kbd), tar.gz,			\
-	http://www.all.kernel.org/pub/linux/utils/kbd/)
+	http://ftp.altlinux.com/pub/people/legion/kbd/)
 $(call download_rule, $(libusb), tar.gz,	\
 	http://downloads.sourceforge.net/libusb/)
 $(call download_rule, $(linux), tar.bz2,		\
@@ -1067,10 +1077,10 @@
 $(call download_rule, $(syslinux), tar.gz, \
         http://ftp.all.kernel.org/pub/linux/utils/boot/syslinux/)
 $(call download_rule, $(usbutils), tar.bz2,	\
-	http://mirror.anl.gov/pub/linux/utils/usb/usbutils/)
+	http://ftp.sunet.se/pub/Linux/kernel.org/linux/utils/usb/usbutils/)
 $(call download_rule, $(wireless_tools), tar.gz,	\
 	http://pcmcia-cs.sourceforge.net/ftp/contrib/)
-$(call download_rule, $(zlib), tar.gz, http://www.zlib.net/)
+$(call download_rule, $(zlib), tar.gz, http://downloads.sourceforge.net/project/libpng/zlib/1.2.5/)
 
 symlink_targets=$(addprefix symlink-,$(packages))		\
 	symlink-build-$(glibc) symlink-build-$(dosemu)		\