Skip to content

Commit

Permalink
Merge pull request TritonDataCenter#13 from joyent/master
Browse files Browse the repository at this point in the history
update joyent commits
  • Loading branch information
plitc authored Nov 28, 2018
2 parents 6193793 + 7d13771 commit 20a0b68
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 320 deletions.
197 changes: 197 additions & 0 deletions Makefile.gcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# Copyright (c) 2018, Joyent, Inc.

#
# Shared makefile for building GCC versions. For the most part, the build is the
# same, but with different component versions.
#

#
# The gcc build system expects that the build is done from a separate objdir
# instead of in-place in the source.
#
SEPARATE_BUILD = yes

GCC = /opt/local/bin/gcc
CFLAGS = -g -O2
PREFIX = /usr/gcc/$(GCC_VER)

AUTOCONF_PREFIX = $(PREFIX)

AUTOCONF_OPTS += \
--with-ld=/usr/bin/ld \
--without-gnu-ld \
--with-gnu-as \
--with-as=$(DESTDIR)/usr/gnu/bin/gas \
--enable-languages="c,c++" \
--enable-shared \
--disable-nls

AUTOCONF_ENV += \
DESTDIR=$(DESTDIR) \
MAKE=$(MAKE)

OVERRIDES += \
$(AUTOCONF_CFLAGS) \
STAGE1_CFLAGS="$(CFLAGS)" \
CFLAGS_FOR_TARGET="$(CFLAGS)"

#
# Because we use a different build directory, we need to make sure we
# catch that when cleaning.
#
CLEANFILES += $(VER)-32.build $(VER)-32strap.build

#
# Unlike everything else, gcc is built to be a cross-compiler, really. It
# never runs on the target system, only the build system. So it should not
# be using the proto area's headers or libraries. Its own libraries will be
# built by the new compiler, and generally aren't using system headers anyway.
# This is not really completely true; for example, libstdc++. This will
# need more work to be really right. We only deliver the libraries.
#
AUTOCONF_CPPFLAGS =
AUTOCONF_LIBS =
GENLDFLAGS =

PATCHES = Patches/*
ALL_TGT = bootstrap

include ../Makefile.targ
include ../Makefile.targ.autoconf

MPFR_TARBALL ?= $(MPFR_VER).tar.bz2
GMP_TARBALL ?= $(GMP_VER).tar.bz2
MPC_TARBALL ?= $(MPC_VER).tar.gz

#
# To reduce repository size, the source files are stored in Manta and
# need to be downloaded (excluding gcc4).
#
$(TARBALL) $(MPFR_TARBALL) $(GMP_TARBALL) $(MPC_TARBALL):
if [[ ! -f [email protected] ]]; then \
echo "Missing required digest file!"; \
exit 1; \
fi; \
curl -o [email protected] $(FETCH_BASE)/$@
digest -a sha1 [email protected] > [email protected]
cmp -s [email protected] [email protected]
rm -f [email protected]
mv [email protected] $@

#
# We could use the support libraries from the build system (since the compiler
# will be run here), but there's no good way to make gcc build itself correctly
# if we do. There are two main problems:
#
# 1. Stage2 and later cc1 and company don't honour any combination of LDFLAGS,
# LDFLAGS_FOR_TARGET, BOOT_LDFLAGS, STAGE2_LDFLAGS, etc. The only ways to
# get these things built with -R/opt/local/lib are to use LD_OPTIONS, which will
# yield the wrong results for libraries, or to hack configure.
#
# 2. Even if we could get -R/opt/local/lib into these programs without building
# the libraries incorrectly, it would still be wrong. The pkgsrc lib directory
# on many systems contains libgcc_s.so.1; however, cc1 was built by the stage2
# compiler and should find the libgcc that matches that compiler. That happens
# to be the one we just built, not the pkgsrc one.
#
# Instead we build these libraries directly ourselves.
#
ifeq ($(GCC_VER),4)
$(AUTOCONF_OUT.32): | $(VER.32)/mpfr $(VER.32)/gmp
else
$(AUTOCONF_OUT.32): | $(VER.32)/mpfr $(VER.32)/gmp $(VER.32)/mpc
endif

$(VER.32)/mpfr: $(MPFR_TARBALL) | $(VER.32)
-rm -rf $@
mkdir -p .unpack32
gtar x -C .unpack32 --no-same-owner -f $(MPFR_TARBALL)
mv -f .unpack32/$(MPFR_VER) ./$@
-rmdir .unpack32
chmod 755 $@/configure
touch $@/configure

$(VER.32)/gmp: $(GMP_TARBALL) | $(VER.32)
-rm -rf $@
mkdir -p .unpack32
gtar x -C .unpack32 --no-same-owner -f $(GMP_TARBALL)
mv -f .unpack32/$(GMP_VER) ./$@
-rmdir .unpack32
chmod 755 $@/configure
touch $@/configure

$(VER.32)/mpc: $(MPC_TARBALL) | $(VER.32)
-rm -rf $@
mkdir -p .unpack32
gtar x -C .unpack32 --no-same-owner -f $(MPC_TARBALL)
mv -f .unpack32/$(MPC_VER) ./$@
-rmdir .unpack32
chmod 755 $@/configure
touch $@/configure

LIBTAR=$(STRAPPROTO)/gcclibs.tar.gz

ifeq ($(STRAP),strap)

#
# The runtime libraries that we build into proto.strap should be made to search
# for their dependencies there as well, so that programs built to run on the
# build machine (from proto.strap) find the correct copies of these libraries.
# (Currently, this is only relevant for libstdc++.)
#
# Before we do so, however, we'll keep copies for the non-strap build to pick
# up.
#
# We should also remove the "fixed" includes: they are just bad copies of the
# potentially old system headers.
#
# During a strap build, all compiler versions are built under
# proto.strap/usr/gcc/X. For the primary compiler, we symlink into
# proto.strap/usr/bin/gcc etc.
#
FIXLIBS = libgcc_s.so libstdc++.so libssp.so
LIBDIR=$(DESTDIR)/$(PREFIX)/lib

.PHONY: strapfix
strapfix:
[[ -h $(LIBDIR)/64 ]] || ln -s amd64 $(LIBDIR)/64
ifeq ($(PRIMARY_COMPILER),gcc$(GCC_VER))
mkdir -p $(DESTDIR)/usr/bin
for f in gcc g++ cpp; do \
ln -sf $(DESTDIR)/$(PREFIX)/bin/$$f $(DESTDIR)/usr/bin/$$f; \
done
rm -f $(LIBTAR)
for lib in $(FIXLIBS); do \
(cd $(LIBDIR)/.. && gtar uvf $(LIBTAR) \
lib/$$lib.* lib/64/$$lib.*) ; \
done
endif
find $(LIBDIR) -name include-fixed | xargs rm -rf
for lib in $(FIXLIBS); do \
/usr/bin/elfedit -e 'dyn:runpath $(LIBDIR)' $(LIBDIR)/$$lib ; \
/usr/bin/elfedit -e 'dyn:runpath $(LIBDIR)/64' \
$(LIBDIR)/64/$$lib ; \
done


else

#
# A non-strap build: do not install anything other than our saved copy of the
# runtime libraries. This should only happen for the primary compiler.
#
.PHONY: fixup
fixup:
cd $(DESTDIR)/usr && gtar xvf $(LIBTAR)

endif
152 changes: 8 additions & 144 deletions gcc4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,150 +23,14 @@
# Copyright (c) 2018, Joyent, Inc. All rights reserved.
#

VER = gcc-4.4.4
MPFR_VER = mpfr-3.1.2
GMP_VER = gmp-5.1.1
PREFIX = /usr/gcc/4

include ../Makefile.defs

SEPARATE_BUILD = yes

GCC = /opt/local/bin/gcc
GXX = /bin/false
CFLAGS = -nostdinc -isystem /usr/include -g -O2

AUTOCONF_PREFIX = $(PREFIX)

AUTOCONF_OPTS += \
--with-ld=/usr/bin/ld \
--without-gnu-ld \
--with-gnu-as \
--with-as=$(DESTDIR)/usr/gnu/bin/gas \
--enable-languages="c,c++" \
--enable-shared \
--disable-nls

AUTOCONF_ENV += \
DESTDIR=$(DESTDIR) \
MAKE=$(MAKE)

OVERRIDES += \
$(AUTOCONF_CFLAGS) \
STAGE1_CFLAGS="$(CFLAGS)" \
CFLAGS_FOR_TARGET="$(CFLAGS)"

#
# Because we use a different build directory, we need to make sure we
# catch that when cleaning.
#
CLEANFILES += $(VER)-32.build $(VER)-32strap.build

#
# Unlike everything else, gcc is built to be a cross-compiler, really. It
# never runs on the target system, only the build system. So it should not
# be using the proto area's headers or libraries. Its own libraries will be
# built by the new compiler, and generally aren't using system headers anyway.
# This is not really completely true; for example, libstdc++. This will
# need more work to be really right. We only deliver the libraries.
#
AUTOCONF_CPPFLAGS =
AUTOCONF_LIBS =
GENLDFLAGS =

PATCHES = Patches/*
ALL_TGT = bootstrap

include ../Makefile.targ
include ../Makefile.targ.autoconf

#
# We could use the mpfr and gmp from the build system (since the compiler will
# be run here), but there's no good way to make gcc build itself correctly if
# we do. There are two main problems:
#
# 1. Stage2 and later cc1 and company don't honour any combination of LDFLAGS,
# LDFLAGS_FOR_TARGET, BOOT_LDFLAGS, STAGE2_LDFLAGS, etc. The only ways to
# get these things built with -R/opt/local/lib are to use LD_OPTIONS, which will
# yield the wrong results for libraries, or to hack configure.
#
# 2. Even if we could get -R/opt/local/lib into these programs without building
# the libraries incorrectly, it would still be wrong. The pkgsrc lib directory
# on many systems contains libgcc_s.so.1; however, cc1 was built by the stage2
# compiler and should find the libgcc that matches that compiler. That happens
# to be the one we just built, not the pkgsrc one.
#
# Instead we have mpfr and gmp built as part of the gcc build itself.
#
$(AUTOCONF_OUT.32): | $(VER.32)/mpfr $(VER.32)/gmp

$(VER.32)/mpfr: $(MPFR_VER).tar.gz | $(VER.32)
-rm -rf $@
mkdir -p .unpack32
gtar x -C .unpack32 -z --no-same-owner -f $(MPFR_VER).tar.gz
mv -f .unpack32/$(MPFR_VER) ./$@
-rmdir .unpack32
chmod 755 $@/configure
touch $@/configure

$(VER.32)/gmp: $(GMP_VER).tar.bz2 | $(VER.32)
-rm -rf $@
mkdir -p .unpack32
gtar x -C .unpack32 -j --no-same-owner -f $(GMP_VER).tar.bz2
mv -f .unpack32/$(GMP_VER) ./$@
-rmdir .unpack32
chmod 755 $@/configure
touch $@/configure

LIBTAR=$(STRAPPROTO)/gcclibs.tar.gz

ifeq ($(STRAP),strap)

#
# The runtime libraries that we build into proto.strap should be made to search
# for their dependencies there as well, so that programs built to run on the
# build machine (from proto.strap) find the correct copies of these libraries.
# (Currently, this is only relevant for libstdc++.)
#
# Before we do so, however, we'll keep copies for the non-strap build to pick
# up.
#
# We should also remove the "fixed" includes: they are just bad copies of the
# potentially old system headers.
#
FIXLIBS = libgcc_s.so libstdc++.so libssp.so
LIBDIR=$(DESTDIR)/$(PREFIX)/lib

.PHONY: strapfix
strapfix:
[[ -h $(LIBDIR)/64 ]] || ln -s amd64 $(LIBDIR)/64
ifeq ($(PRIMARY_COMPILER),gcc4)
mkdir -p $(DESTDIR)/usr/bin
for f in gcc g++ cpp; do \
ln -sf $(DESTDIR)/$(PREFIX)/bin/$$f $(DESTDIR)/usr/bin/$$f; \
done
rm -f $(LIBTAR)
for lib in $(FIXLIBS); do \
(cd $(LIBDIR)/.. && gtar uvf $(LIBTAR) \
lib/$$lib.* lib/64/$$lib.*) ; \
done
endif
find $(LIBDIR) -name include-fixed | xargs rm -rf
for lib in $(FIXLIBS); do \
/usr/bin/elfedit -e 'dyn:runpath $(LIBDIR)' $(LIBDIR)/$$lib ; \
/usr/bin/elfedit -e 'dyn:runpath $(LIBDIR)/64' \
$(LIBDIR)/64/$$lib ; \
done


else

#
# A non-strap build: do not install anything other than our saved copy of the
# runtime libraries. This should only happen for the primary compiler.
#
.PHONY: fixup
fixup:
cd $(DESTDIR)/usr && gtar xvf $(LIBTAR)
GCC_VER = 4
VER = gcc-4.4.4
MPFR_VER = mpfr-3.1.2
MPFR_TARBALL = $(MPFR_VER).tar.gz
GMP_VER = gmp-5.1.1
GXX = /bin/false
CFLAGS = -nostdinc -isystem /usr/include -g -O2

endif
include ../Makefile.gcc
Loading

0 comments on commit 20a0b68

Please sign in to comment.