annotate native-compiler.sh @ 1809:9cdd90bdce76 draft

Grrr, forgot to check in a patch. Fix second stage cross compiler build with elf2flt by only building static libraries.
author Rob Landley <rob@landley.net>
date Thu, 05 Nov 2015 09:59:14 -0600
parents b6e4e49cec5e
children acaa88463c0c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
946
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
1007
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 998
diff changeset
3 # Build a compiler for a given target, using one or more existing simple
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 998
diff changeset
4 # cross compilers.
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 998
diff changeset
5
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 998
diff changeset
6 # This can be used to build a native compiler for an aribitrary target, or to
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 998
diff changeset
7 # build a more portable and capable cross compiler for an arbitrary host.
946
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
8
1083
cb4dbdb7f2cd Make BUILD_STATIC take comma separated list of packages, or "all" or "none". Default behavior should remain the same.
Rob Landley <rob@landley.net>
parents: 1034
diff changeset
9 # The new compiler is built --with-shared, with thread support, has uClibc++
1664
35b8949e9d9c Very basic musl support. Still needs debugging and to be enabled per-target.
Rob Landley <rob@landley.net>
parents: 1398
diff changeset
10 # installed, and is linked against musl (see BUILD_STATIC in config).
1007
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 998
diff changeset
11
1398
b74d36876c0a Replace read_arch_dir with load_target, which understands that sources/targets/$TARGET can be a file or a directory.
Rob Landley <rob@landley.net>
parents: 1209
diff changeset
12 source sources/include.sh && load_target "$1" || exit 1
946
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 check_for_base_arch || exit 0
1007
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 998
diff changeset
14
946
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 check_prerequisite "${ARCH}-cc"
1207
4021fb1183d7 Environment sanitizing screwed up the cross-compiler.sh wrapper. Fix it, rename PROGRAM_PREFIX to TOOLCHAIN_PREFIX, and put a guard around sources/include.sh so it's safe to include multiple times.
Rob Landley <rob@landley.net>
parents: 1130
diff changeset
16
1746
5f84cad1fdc9 Make the usr/ move only apply to native-compiler.sh and not cross-compiler.sh (which is a wrapper around native-compiler.sh).
Rob Landley <rob@landley.net>
parents: 1742
diff changeset
17 [ -z "$HOST_ARCH" ] && HOST_ARCH="$ARCH" && STAGE_DIR="$STAGE_DIR/usr" ||
5f84cad1fdc9 Make the usr/ move only apply to native-compiler.sh and not cross-compiler.sh (which is a wrapper around native-compiler.sh).
Rob Landley <rob@landley.net>
parents: 1742
diff changeset
18 check_prerequisite "${HOST_ARCH}-cc"
946
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
19
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 mkdir -p "$STAGE_DIR/bin" || dienow
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
21
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 # Build C Library
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
23
1763
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
24 if [ ! -z "$KARCH" ]
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
25 then
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
26 build_section linux-headers
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
27 if [ -z "$UCLIBC_CONFIG" ] || [ ! -z "$MUSL" ]
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
28 then
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
29 build_section musl
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
30 else
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
31 build_section uClibc
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
32 fi
1673
0f61292eab70 Add MUSL=1 config option to force musl build.
Rob Landley <rob@landley.net>
parents: 1664
diff changeset
33 fi
946
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
34
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 # Build binutils, gcc, and ccwrap
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
36
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
37 build_section binutils
1763
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
38 [ ! -z "$ELF2FLT" ] && build_section elf2flt
946
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 build_section gcc
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 build_section ccwrap
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
41
1034
27c38c82401d Move make, bash, and distcc builds into native-compiler.sh. (Break 'em out into sources/sections/*.build.)
Rob Landley <rob@landley.net>
parents: 1007
diff changeset
42 # Tell future packages to link against the libraries in the new compiler,
27c38c82401d Move make, bash, and distcc builds into native-compiler.sh. (Break 'em out into sources/sections/*.build.)
Rob Landley <rob@landley.net>
parents: 1007
diff changeset
43 # rather than the ones in the simple compiler.
946
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
44
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 export "$(echo $ARCH | sed 's/-/_/g')"_CCWRAP_TOPDIR="$STAGE_DIR"
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
46
1763
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
47 if [ ! -z "$KARCH" ]
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
48 then
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
49 # Add C++ standard library
1130
c222ae88733a Add NO_CPLUSPLUS config option, to skip c++ support entirely.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
50
1763
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
51 [ -z "$NO_CPLUSPLUS" ] && build_section uClibc++
946
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
52
1763
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
53 # For a native compiler, build make, bash, and distcc. (Yes, this is an old
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
54 # version of Bash. It's intentional.)
1034
27c38c82401d Move make, bash, and distcc builds into native-compiler.sh. (Break 'em out into sources/sections/*.build.)
Rob Landley <rob@landley.net>
parents: 1007
diff changeset
55
1763
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
56 if [ -z "$TOOLCHAIN_PREFIX" ]
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
57 then
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
58 build_section make
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
59 build_section bash
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
60 build_section distcc
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
61 cp "$SOURCES/toys/hdainit.sh" "$STAGE_DIR/../init" &&
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
62 mv "$STAGE_DIR"/{man,share/man} || dienow
b6e4e49cec5e Teach build to do an elf compiler, no libc or root filesystem if no KARCH in target.
Rob Landley <rob@landley.net>
parents: 1746
diff changeset
63 fi
1034
27c38c82401d Move make, bash, and distcc builds into native-compiler.sh. (Break 'em out into sources/sections/*.build.)
Rob Landley <rob@landley.net>
parents: 1007
diff changeset
64 fi
27c38c82401d Move make, bash, and distcc builds into native-compiler.sh. (Break 'em out into sources/sections/*.build.)
Rob Landley <rob@landley.net>
parents: 1007
diff changeset
65
1728
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1673
diff changeset
66 # Delete some unneeded files and strip everything else
1734
fbc625ba4098 Move man directory and delete info directory so lfs-bootstrap setup doesn't conflict with them when native-compiler built with SKIP_STRIP.
Rob Landley <rob@landley.net>
parents: 1731
diff changeset
67 rm -rf "$STAGE_DIR"/{info,libexec/gcc/*/*/install-tools} || dienow
1728
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1673
diff changeset
68 if [ -z "$SKIP_STRIP" ]
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1673
diff changeset
69 then
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1673
diff changeset
70 "${ARCH}-strip" --strip-unneeded "$STAGE_DIR"/lib/*.so
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1673
diff changeset
71 "${ARCH}-strip" "$STAGE_DIR"/{bin/*,sbin/*}
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1673
diff changeset
72 fi
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1673
diff changeset
73
946
b2cb36998d54 Helps to actually remember to add the new file.
Rob Landley <rob@landley.net>
parents:
diff changeset
74 create_stage_tarball