From 07a7048420310f30d73b065662bc161b7801a755 Mon Sep 17 00:00:00 2001 From: Mark Seaborn Date: Mon, 18 Jan 2010 13:05:53 +0000 Subject: [PATCH] Find nacl-gcc via PATH rather than hard-coding a relative pathname Allows the glibc source tree to be put in a different location. --- link-libcso.sh | 78 ++++++++++++++++++++++++------------------------- make-example-dynamic.sh | 2 +- make-example.sh | 2 +- myconfig.sh | 7 ++++- 4 files changed, 47 insertions(+), 42 deletions(-) rewrite link-libcso.sh (73%) diff --git a/link-libcso.sh b/link-libcso.sh dissimilarity index 73% index bbcf9467a1..60dfb1b924 100755 --- a/link-libcso.sh +++ b/link-libcso.sh @@ -1,39 +1,39 @@ -#!/bin/bash - -# This script is a shortcut for building libc.so, the dynamic linker, -# and some other libraries. -# It's faster than running make on glibc. - -set -e - -BUILD=build - -echo - ld.so -../tools_bin/linux/sdk/nacl-sdk/bin/nacl-gcc \ - -nostdlib -nostartfiles -shared \ - -o $BUILD/elf/ld.so \ - -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs \ - $BUILD/elf/librtld.os -Wl,--version-script=$BUILD/ld.map \ - -Wl,-Map,$BUILD/elf/ld.so.map \ - -Wl,-soname=ld-linux.so.2 -Lld - -echo - libc_pic.os -../tools_bin/linux/sdk/nacl-sdk/bin/nacl-gcc \ - -nostdlib -nostartfiles -r -o $BUILD/libc_pic.os \ - -Wl,-d -Wl,--whole-archive $BUILD/libc_pic.a \ - -Wl,-Map,$BUILD/libc_pic.os.map - -echo - libc.so -../tools_bin/linux/sdk/nacl-sdk/bin/nacl-gcc -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/lib/ld-linux.so.2 -B$BUILD/csu/ -Wl,--version-script=$BUILD/libc.map -Wl,-soname=libc.so.6 -Wl,-z,relro -Wl,--hash-style=both -nostdlib -nostartfiles -e __libc_main -L$BUILD -L$BUILD/math -L$BUILD/elf -L$BUILD/dlfcn -L$BUILD/nss -L$BUILD/nis -L$BUILD/rt -L$BUILD/resolv -L$BUILD/crypt -L$BUILD/nptl -Wl,-rpath-link=$BUILD:$BUILD/math:$BUILD/elf:$BUILD/dlfcn:$BUILD/nss:$BUILD/nis:$BUILD/rt:$BUILD/resolv:$BUILD/crypt:$BUILD/nptl -o $BUILD/libc.so $BUILD/csu/abi-note.o $BUILD/elf/soinit.os $BUILD/libc_pic.os $BUILD/elf/sofini.os $BUILD/elf/interp.os $BUILD/elf/ld.so -lgcc -Lld \ - -Wl,-Map,$BUILD/libc.so.map - -echo - libdl.so -../tools_bin/linux/sdk/nacl-sdk/bin/nacl-gcc -L$BUILD/../ld -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/work/nacl/2/googleclient/native_client/install/lib/ld-linux.so.2 -B$BUILD/csu/ -Wl,--version-script=$BUILD/libdl.map -Wl,-soname=libdl.so.2 -Wl,-z,relro -Wl,--hash-style=both -L$BUILD -L$BUILD/math -L$BUILD/elf -L$BUILD/dlfcn -L$BUILD/nss -L$BUILD/nis -L$BUILD/rt -L$BUILD/resolv -L$BUILD/crypt -L$BUILD/nptl -Wl,-rpath-link=$BUILD:$BUILD/math:$BUILD/elf:$BUILD/dlfcn:$BUILD/nss:$BUILD/nis:$BUILD/rt:$BUILD/resolv:$BUILD/crypt:$BUILD/nptl -o $BUILD/dlfcn/libdl.so $BUILD/csu/abi-note.o -Wl,--whole-archive $BUILD/dlfcn/libdl_pic.a -Wl,--no-whole-archive $BUILD/elf/interp.os $BUILD/libc.so $BUILD/libc_nonshared.a $BUILD/elf/ld.so \ - -Wl,-Map,$BUILD/dlfcn/libdl.so.map - -echo - libmemusage.so -../tools_bin/linux/sdk/nacl-sdk/bin/nacl-gcc -L$BUILD/../ld -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/work/nacl/2/googleclient/native_client/install/lib/ld-linux.so.2 -B$BUILD/csu/ -Wl,-soname=libmemusage.so -Wl,-z,relro -Wl,--hash-style=both -L$BUILD -L$BUILD/math -L$BUILD/elf -L$BUILD/dlfcn -L$BUILD/nss -L$BUILD/nis -L$BUILD/rt -L$BUILD/resolv -L$BUILD/crypt -L$BUILD/nptl -Wl,-rpath-link=$BUILD:$BUILD/math:$BUILD/elf:$BUILD/dlfcn:$BUILD/nss:$BUILD/nis:$BUILD/rt:$BUILD/resolv:$BUILD/crypt:$BUILD/nptl -o $BUILD/malloc/libmemusage.so $BUILD/csu/abi-note.o -Wl,--whole-archive $BUILD/malloc/libmemusage_pic.a -Wl,--no-whole-archive $BUILD/elf/interp.os $BUILD/dlfcn/libdl.so $BUILD/elf/ld.so \ - -Wl,-Map,$BUILD/malloc/libmemusage.so.map - -echo - libpthread.so -../tools_bin/linux/sdk/nacl-sdk/bin/nacl-gcc -L$BUILD/../ld -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/work/nacl/3/googleclient/native_client/install/lib/ld-linux.so.2 -B$BUILD/nptl/ -B$BUILD/csu/ -B$BUILD/nptl/ -Wl,--version-script=$BUILD/libpthread.map -Wl,-soname=libpthread.so.0 -Wl,-z,relro -Wl,--hash-style=both -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst -e __nptl_main -L$BUILD -L$BUILD/math -L$BUILD/elf -L$BUILD/dlfcn -L$BUILD/nss -L$BUILD/nis -L$BUILD/rt -L$BUILD/resolv -L$BUILD/crypt -L$BUILD/nptl -Wl,-rpath-link=$BUILD:$BUILD/math:$BUILD/elf:$BUILD/dlfcn:$BUILD/nss:$BUILD/nis:$BUILD/rt:$BUILD/resolv:$BUILD/crypt:$BUILD/nptl -o $BUILD/nptl/libpthread.so $BUILD/csu/abi-note.o -Wl,--whole-archive $BUILD/nptl/libpthread_pic.a -Wl,--no-whole-archive $BUILD/elf/interp.os $BUILD/libc.so $BUILD/libc_nonshared.a $BUILD/elf/ld.so +#!/bin/bash + +# This script is a shortcut for building libc.so, the dynamic linker, +# and some other libraries. +# It's faster than running make on glibc. + +set -e + +BUILD=build + +echo - ld.so +nacl-gcc \ + -nostdlib -nostartfiles -shared \ + -o $BUILD/elf/ld.so \ + -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs \ + $BUILD/elf/librtld.os -Wl,--version-script=$BUILD/ld.map \ + -Wl,-Map,$BUILD/elf/ld.so.map \ + -Wl,-soname=ld-linux.so.2 -Lld + +echo - libc_pic.os +nacl-gcc \ + -nostdlib -nostartfiles -r -o $BUILD/libc_pic.os \ + -Wl,-d -Wl,--whole-archive $BUILD/libc_pic.a \ + -Wl,-Map,$BUILD/libc_pic.os.map + +echo - libc.so +nacl-gcc -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/lib/ld-linux.so.2 -B$BUILD/csu/ -Wl,--version-script=$BUILD/libc.map -Wl,-soname=libc.so.6 -Wl,-z,relro -Wl,--hash-style=both -nostdlib -nostartfiles -e __libc_main -L$BUILD -L$BUILD/math -L$BUILD/elf -L$BUILD/dlfcn -L$BUILD/nss -L$BUILD/nis -L$BUILD/rt -L$BUILD/resolv -L$BUILD/crypt -L$BUILD/nptl -Wl,-rpath-link=$BUILD:$BUILD/math:$BUILD/elf:$BUILD/dlfcn:$BUILD/nss:$BUILD/nis:$BUILD/rt:$BUILD/resolv:$BUILD/crypt:$BUILD/nptl -o $BUILD/libc.so $BUILD/csu/abi-note.o $BUILD/elf/soinit.os $BUILD/libc_pic.os $BUILD/elf/sofini.os $BUILD/elf/interp.os $BUILD/elf/ld.so -lgcc -Lld \ + -Wl,-Map,$BUILD/libc.so.map + +echo - libdl.so +nacl-gcc -L$BUILD/../ld -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/work/nacl/2/googleclient/native_client/install/lib/ld-linux.so.2 -B$BUILD/csu/ -Wl,--version-script=$BUILD/libdl.map -Wl,-soname=libdl.so.2 -Wl,-z,relro -Wl,--hash-style=both -L$BUILD -L$BUILD/math -L$BUILD/elf -L$BUILD/dlfcn -L$BUILD/nss -L$BUILD/nis -L$BUILD/rt -L$BUILD/resolv -L$BUILD/crypt -L$BUILD/nptl -Wl,-rpath-link=$BUILD:$BUILD/math:$BUILD/elf:$BUILD/dlfcn:$BUILD/nss:$BUILD/nis:$BUILD/rt:$BUILD/resolv:$BUILD/crypt:$BUILD/nptl -o $BUILD/dlfcn/libdl.so $BUILD/csu/abi-note.o -Wl,--whole-archive $BUILD/dlfcn/libdl_pic.a -Wl,--no-whole-archive $BUILD/elf/interp.os $BUILD/libc.so $BUILD/libc_nonshared.a $BUILD/elf/ld.so \ + -Wl,-Map,$BUILD/dlfcn/libdl.so.map + +echo - libmemusage.so +nacl-gcc -L$BUILD/../ld -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/work/nacl/2/googleclient/native_client/install/lib/ld-linux.so.2 -B$BUILD/csu/ -Wl,-soname=libmemusage.so -Wl,-z,relro -Wl,--hash-style=both -L$BUILD -L$BUILD/math -L$BUILD/elf -L$BUILD/dlfcn -L$BUILD/nss -L$BUILD/nis -L$BUILD/rt -L$BUILD/resolv -L$BUILD/crypt -L$BUILD/nptl -Wl,-rpath-link=$BUILD:$BUILD/math:$BUILD/elf:$BUILD/dlfcn:$BUILD/nss:$BUILD/nis:$BUILD/rt:$BUILD/resolv:$BUILD/crypt:$BUILD/nptl -o $BUILD/malloc/libmemusage.so $BUILD/csu/abi-note.o -Wl,--whole-archive $BUILD/malloc/libmemusage_pic.a -Wl,--no-whole-archive $BUILD/elf/interp.os $BUILD/dlfcn/libdl.so $BUILD/elf/ld.so \ + -Wl,-Map,$BUILD/malloc/libmemusage.so.map + +echo - libpthread.so +nacl-gcc -L$BUILD/../ld -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/work/nacl/3/googleclient/native_client/install/lib/ld-linux.so.2 -B$BUILD/nptl/ -B$BUILD/csu/ -B$BUILD/nptl/ -Wl,--version-script=$BUILD/libpthread.map -Wl,-soname=libpthread.so.0 -Wl,-z,relro -Wl,--hash-style=both -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst -e __nptl_main -L$BUILD -L$BUILD/math -L$BUILD/elf -L$BUILD/dlfcn -L$BUILD/nss -L$BUILD/nis -L$BUILD/rt -L$BUILD/resolv -L$BUILD/crypt -L$BUILD/nptl -Wl,-rpath-link=$BUILD:$BUILD/math:$BUILD/elf:$BUILD/dlfcn:$BUILD/nss:$BUILD/nis:$BUILD/rt:$BUILD/resolv:$BUILD/crypt:$BUILD/nptl -o $BUILD/nptl/libpthread.so $BUILD/csu/abi-note.o -Wl,--whole-archive $BUILD/nptl/libpthread_pic.a -Wl,--no-whole-archive $BUILD/elf/interp.os $BUILD/libc.so $BUILD/libc_nonshared.a $BUILD/elf/ld.so diff --git a/make-example-dynamic.sh b/make-example-dynamic.sh index 3546c79557..510d7b0d54 100755 --- a/make-example-dynamic.sh +++ b/make-example-dynamic.sh @@ -2,7 +2,7 @@ BUILDDIR=build DEST=hellow-dyn -../tools_bin/linux/sdk/nacl-sdk/bin/nacl-gcc \ +nacl-gcc \ -B$BUILDDIR/csu/ -L$BUILDDIR -Lld \ $BUILDDIR/elf/ld.so $BUILDDIR/libc_nonshared.a \ -g hellow.c -o $DEST \ diff --git a/make-example.sh b/make-example.sh index 0bd9d06e6a..9beef08d48 100755 --- a/make-example.sh +++ b/make-example.sh @@ -1,7 +1,7 @@ #!/bin/bash BUILDDIR=build -../tools_bin/linux/sdk/nacl-sdk/bin/nacl-gcc \ +nacl-gcc \ -B$BUILDDIR/csu/ -L$BUILDDIR -static -Wl,-T,elf_i386.x \ -g hellow.c -o hellow \ -Wl,-print-map > hellow.map diff --git a/myconfig.sh b/myconfig.sh index 6329951827..5188b624c0 100755 --- a/myconfig.sh +++ b/myconfig.sh @@ -10,12 +10,17 @@ mkdir kernel-headers cp -a /usr/include/asm /usr/include/asm-generic /usr/include/linux \ kernel-headers/ +if ! which nacl-gcc >/dev/null; then + echo Error: nacl-gcc not found on PATH + exit 1 +fi + BUILDDIR=build mkdir -p $BUILDDIR PREFIX=$(cd .. && pwd)/install cd $BUILDDIR ../configure --prefix=$PREFIX --host=i486-linux-gnu \ - CC="`pwd`/../../tools_bin/linux/sdk/nacl-sdk/bin/nacl-gcc -L`pwd`/../ld" \ + CC="`which nacl-gcc` -L`pwd`/../ld" \ CFLAGS="-march=i486 -pipe -fstrict-aliasing -O2 -g -mno-tls-direct-seg-refs" \ --with-headers=`pwd`/../kernel-headers --enable-kernel=2.2.0 # --disable-shared -- 2.11.4.GIT