This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts and Makefile for bootstrapping and installing llgo
Also update the README.md file.
- Loading branch information
Showing
7 changed files
with
194 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ cmd/llgo-dist/llgo-dist | |
cmd/llgo-build/llgo-build | ||
llgo/llgo | ||
llgo/gotest.out* | ||
workdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
j = 1 | ||
prefix = /usr/local | ||
bootstrap = quick | ||
|
||
bootstrap: workdir/.bootstrap-stamp | ||
|
||
install: bootstrap | ||
./install.sh $(prefix) | ||
|
||
workdir/.bootstrap-stamp: workdir/.update-stamp bootstrap.sh *.go build/*.go cmd/gllgo/*.go debug/*.go | ||
./bootstrap.sh $(bootstrap) -j$(j) | ||
|
||
workdir/.update-stamp: update_libgo.sh | ||
./update_libgo.sh | ||
|
||
.SUFFIXES: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/sh -e | ||
|
||
llgodir=$(dirname "$0") | ||
llgodir=$(cd "$llgodir" && pwd) | ||
|
||
workdir=$llgodir/workdir | ||
gofrontenddir=$workdir/gofrontend | ||
gofrontend_builddir=$workdir/gofrontend_build | ||
|
||
bootstrap_type="$1" | ||
shift | ||
|
||
case "$bootstrap_type" in | ||
quick | full) | ||
;; | ||
|
||
*) | ||
echo "Bootstrap type must be 'quick' or 'full'" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Clean up any previous libgo stages. | ||
rm -rf $gofrontend_builddir/libgo* | ||
|
||
# Build a stage1 compiler with gc. | ||
(cd $llgodir/cmd/gllgo && go build -o $workdir/gllgo-stage1) | ||
|
||
# Build libgo with the stage1 compiler. | ||
mkdir -p $gofrontend_builddir/libgo-stage1 | ||
(cd $gofrontend_builddir/libgo-stage1 && $gofrontenddir/libgo/configure GOC="$workdir/gllgo-stage1 -no-prefix") | ||
make -C $gofrontend_builddir/libgo-stage1 "$@" | ||
|
||
# Set up a directory which when added to $PATH causes "gccgo" to resolve | ||
# to our stage1 compiler. This is necessary because the logic in "go build" | ||
# for locating the compiler is fixed. | ||
mkdir -p $gofrontend_builddir/stage1-path | ||
ln -sf $workdir/gllgo-stage1 $gofrontend_builddir/stage1-path/gccgo | ||
|
||
# Build a stage2 compiler using the stage1 compiler and libgo. | ||
gllgoflags="-no-prefix -L$gofrontend_builddir/libgo-stage1 -L$gofrontend_builddir/libgo-stage1/.libs -static-libgo" | ||
(cd $llgodir/cmd/gllgo && PATH=$gofrontend_builddir/stage1-path:$PATH go build -compiler gccgo -gccgoflags "$gllgoflags" -o $workdir/gllgo-stage2) | ||
|
||
# If this is a quick bootstrap, do not rebuild libgo with the stage2 compiler. | ||
# Instead, use the stage1 libgo. | ||
|
||
if [ "$bootstrap_type" == "full" ] ; then | ||
# Build libgo with the stage2 compiler. | ||
mkdir -p $gofrontend_builddir/libgo-stage2 | ||
(cd $gofrontend_builddir/libgo-stage2 && $gofrontenddir/libgo/configure GOC="$workdir/gllgo-stage2 -no-prefix") | ||
make -C $gofrontend_builddir/libgo-stage2 "$@" | ||
|
||
# Set up $gllgoflags to use the stage2 libgo. | ||
gllgoflags="-no-prefix -L$gofrontend_builddir/libgo-stage2 -L$gofrontend_builddir/libgo-stage2/.libs -static-libgo" | ||
fi | ||
|
||
# Set up a directory which when added to $PATH causes "gccgo" to resolve | ||
# to our stage2 compiler. | ||
mkdir -p $gofrontend_builddir/stage2-path | ||
ln -sf $workdir/gllgo-stage2 $gofrontend_builddir/stage2-path/gccgo | ||
|
||
# Build the stage3 compiler. | ||
(cd $llgodir/cmd/gllgo && PATH=$gofrontend_builddir/stage2-path:$PATH go build -compiler gccgo -gccgoflags "$gllgoflags" -o $workdir/gllgo-stage3) | ||
|
||
# Strip the compiler binaries. The binaries are currently only | ||
# expected to compare equal modulo debug info. | ||
strip -o $workdir/gllgo-stage2.stripped $workdir/gllgo-stage2 | ||
strip -o $workdir/gllgo-stage3.stripped $workdir/gllgo-stage3 | ||
|
||
cmp $workdir/gllgo-stage2.stripped $workdir/gllgo-stage3.stripped && \ | ||
echo "Bootstrap completed successfully" && touch $workdir/.bootstrap-stamp && exit 0 || \ | ||
echo "Bootstrap failed, binaries differ" && exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh -e | ||
|
||
prefix="$1" | ||
mkdir -p "$prefix" | ||
prefix=$(cd "$prefix" && pwd) | ||
|
||
llgodir=$(dirname "$0") | ||
|
||
workdir=$llgodir/workdir | ||
gofrontend_builddir=$workdir/gofrontend_build | ||
|
||
# Install the compiler binary. | ||
mkdir -p "$prefix/bin" | ||
cp $workdir/gllgo-stage3 "$prefix/bin/llgo" | ||
|
||
# Install llgo-go. | ||
cp $llgodir/llgo-go.sh "$prefix/bin/llgo-go" | ||
chmod +x "$prefix/bin/llgo-go" | ||
|
||
# Install libgo. If we did a quick bootstrap, only the stage1 libgo will exist. | ||
if [ -d "$gofrontend_builddir/libgo-stage2" ] ; then | ||
make -C $gofrontend_builddir/libgo-stage2 install "prefix=$prefix" | ||
else | ||
make -C $gofrontend_builddir/libgo-stage1 install "prefix=$prefix" | ||
fi | ||
|
||
# Set up the symlink required by llgo-go. | ||
mkdir -p "$prefix/lib/llgo/go-path" | ||
ln -sf ../../../bin/llgo "$prefix/lib/llgo/go-path/gccgo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh -e | ||
|
||
scriptpath=$(which "$0") | ||
scriptpath=$(readlink -f "$scriptpath") | ||
bindir=$(dirname "$scriptpath") | ||
prefix=$(dirname "$bindir") | ||
|
||
cmd="$1" | ||
|
||
case "$cmd" in | ||
build | get | install | run | test) | ||
shift | ||
PATH="$prefix/lib/llgo/go-path:$PATH" exec go "$cmd" -compiler gccgo "$@" | ||
;; | ||
|
||
*) | ||
exec go "$@" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/sh -e | ||
|
||
# Fetch libgo and its dependencies, and build the dependencies. | ||
# We build libgo itself while bootstrapping. | ||
|
||
llgodir=$(dirname "$0") | ||
llgodir=$(cd "$llgodir" && pwd) | ||
|
||
gofrontendrepo=https://code.google.com/p/gofrontend/ | ||
gofrontendrev=93286dc73be0 | ||
|
||
gccrepo=svn://gcc.gnu.org/svn/gcc/trunk | ||
gccrev=209880 | ||
|
||
workdir=$llgodir/workdir | ||
gofrontenddir=$workdir/gofrontend | ||
gofrontend_builddir=$workdir/gofrontend_build | ||
|
||
mkdir -p $workdir | ||
if [ -d $gofrontenddir/.hg ] ; then | ||
(cd $gofrontenddir && hg pull) | ||
else | ||
hg clone $gofrontendrepo $gofrontenddir | ||
fi | ||
(cd $gofrontenddir && hg update -r $gofrontendrev) | ||
|
||
# Some dependencies are stored in the gcc repository. | ||
# TODO(pcc): Ask iant about mirroring these dependencies into gofrontend. | ||
|
||
mkdir -p $gofrontenddir/include | ||
mkdir -p $gofrontenddir/libgcc | ||
for f in config.guess config-ml.in config.sub depcomp \ | ||
install-sh ltmain.sh missing move-if-change \ | ||
include/dwarf2.{def,h} libgcc/unwind-pe.h ; do | ||
svn cat -r $gccrev $gccrepo/$f > $gofrontenddir/$f | ||
done | ||
|
||
# Avoid pulling in a bunch of unneeded gcc headers. | ||
echo "#define IS_ABSOLUTE_PATH(path) ((path)[0] == '/')" > $gofrontenddir/include/filenames.h | ||
|
||
for d in libatomic libbacktrace libffi ; do | ||
svn co -r $gccrev $gccrepo/$d $gofrontenddir/$d | ||
mkdir -p $gofrontend_builddir/$d | ||
(cd $gofrontend_builddir/$d && $gofrontenddir/$d/configure CFLAGS=-fPIC) | ||
make -C $gofrontend_builddir/$d -j4 | ||
done | ||
|
||
touch $workdir/.update-stamp |