]> git.mdlowis.com Git - proto/aardvark-linux.git/commitdiff
Build binutils and clang statically
authorMike D. Lowis <mike.lowis@gentex.com>
Mon, 22 Jun 2015 19:18:40 +0000 (15:18 -0400)
committerMike D. Lowis <mike.lowis@gentex.com>
Mon, 22 Jun 2015 19:18:40 +0000 (15:18 -0400)
build.sh

index afc67a3d4847a7ca6a259cd7aca3ba691c39571a..6def19d26a653cc3c7f1e1e45759201dc26c08f8 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -39,43 +39,46 @@ mkdir -p "$AL_TARBALLS/binutils/build"
 cd "$AL_TARBALLS/binutils/build"
 if [ ! -f Makefile ]; then
     ../configure \
-       --prefix="$AL_TOOLS" \
-       --with-sysroot="$AL" \
-       --with-lib-path="$AL_TOOLS" \
-       --target="$AL_TGT" \
-       --disable-shared \
-       --disable-nls \
-       --disable-werror 
+        LDFLAGS="--static" \
+        --prefix="$AL_TOOLS" \
+        --with-sysroot="$AL" \
+        --with-lib-path="$AL_TOOLS" \
+        --target="$AL_TGT" \
+        --disable-shared \
+        --disable-nls \
+        --disable-werror
 fi
-if [ ! -f "$AL_TOOLS/bin/ar" ]; then
+if [ ! -f "$AL_TOOLS/bin/$AL_TGT-ar" ]; then
     make
     make install
 fi
 cd $AL
 
-# Test that the new linker works
-echo 'int main(int argc, char** argv) { return 0; }' > test.c
-gcc -o test test.c
-rm test test.c
-which ld
-
 # Build clang and install it in the
 mkdir -p "$AL_TARBALLS/llvm/build"
 cd "$AL_TARBALLS/llvm/build"
 if [ ! -f Makefile ]; then
-    cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$AL_TOOLS" -DBUILD_SHARED_LIBS=OFF ../
+    LDFLAGS="-static" cmake -G"Unix Makefiles" \
+        -DCMAKE_BUILD_TYPE=Release \
+        -DCMAKE_INSTALL_PREFIX="$AL_TOOLS" \
+        -DBUILD_SHARED_LIBS=OFF \
+        -DLLVM_BUILD_TOOLS=OFF \
+        -DLLVM_BUILD_EXAMPLES=OFF \
+        -DLLVM_BUILD_TESTS=OFF \
+        ../
 fi
 if [ ! -f "$AL_TOOLS/bin/clang" ]; then
-    make clang
+    make LDFLAGS="-static" clang
     make install
 fi
 
-## Test that the new clang binary works
-#echo 'int main(int argc, char** argv) { return 0; }' > test.c
-#clang -o test test.c
-#if [ "0" -ne "`readelf -d test | grep -c '0x'`" ]; then
-#    echo "Expected toolchain to compile statically but target was dynamically linked."
-#    exit 1
-#else
-#    rm test test.c
-#fi
+# Test that the new clang binary works
+echo 'int main(int argc, char** argv) { return 0; }' > cctest.c
+clang -static -target $AL_TGT -o cctest cctest.c
+if [ "0" -ne "`readelf -d cctest | grep -c '0x'`" ]; then
+    rm cctest cctest.c
+    echo "Expected toolchain to compile statically but target was dynamically linked."
+    exit 1
+else
+    rm cctest cctest.c
+fi