Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
OS-2123 multilib: gcc can't install in parallel
OS-2124 multilib: gcc needs to know that /opt/local/lib isn't in the runpath
  • Loading branch information
Keith M Wesolowski committed Apr 22, 2013
1 parent 72e119d commit 884461b
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 67 deletions.
8 changes: 6 additions & 2 deletions Makefile.defs
Expand Up @@ -25,6 +25,8 @@ BASE = $(PWD)
DESTDIR = $(BASE)/../proto
VER.32 = $(VER)-32$(STRAP)
VER.64 = $(VER)-64$(STRAP)
OBJ.32 = $(VER.32)$(SEPARATE_BUILD:yes=.build)
OBJ.64 = $(VER.64)$(SEPARATE_BUILD:yes=.build)

PATH = $(DESTDIR)/usr/bin:/usr/bin:/usr/sbin:/sbin:/opt/local/bin

Expand All @@ -49,6 +51,7 @@ SYSLIBDIRS = /usr/lib /lib

BUILD32 = yes
BUILD64 =
SEPARATE_BUILD =

CPPFLAGS = $(SYSINCDIRS:%=-isystem $(DESTDIR)/%)

Expand Down Expand Up @@ -87,8 +90,8 @@ AUTOCONF_LIBS = LIBS="$(LIBS)"
AUTOCONF_LIBS.64 = LIBS="$(LIBS.64)"

AUTOCONF_OUT = config.status
AUTOCONF_OUT.32 = $(VER.32)/$(AUTOCONF_OUT)
AUTOCONF_OUT.64 = $(VER.64)/$(AUTOCONF_OUT)
AUTOCONF_OUT.32 = $(OBJ.32)/$(AUTOCONF_OUT)
AUTOCONF_OUT.64 = $(OBJ.64)/$(AUTOCONF_OUT)

AUTOCONF_PREFIX = /usr

Expand Down Expand Up @@ -119,6 +122,7 @@ AUTOCONF_OPTS.32 = \
AUTOCONF_OPTS.64 = \
$(AUTOCONF_OPTS)

ALL_TGT =
OVERRIDES = $(MAKE_VERBOSE)

TARBALL = $(VER).tar.gz
Expand Down
32 changes: 20 additions & 12 deletions Makefile.targ
Expand Up @@ -24,39 +24,41 @@
all_autoconf: $(BUILD32:yes=all_autoconf_32) $(BUILD64:yes=all_autoconf_64)

all_autoconf_32: $(AUTOCONF_OUT.32)
(cd $(VER.32); env - PATH=$(PATH) $(MAKE) $(PARALLEL) $(OVERRIDES))
(cd $(OBJ.32); \
env - PATH=$(PATH) $(MAKE) $(PARALLEL) $(OVERRIDES) $(ALL_TGT))

all_autoconf_64: $(AUTOCONF_OUT.64)
(cd $(VER.64); env - PATH=$(PATH) $(MAKE) $(PARALLEL) $(OVERRIDES.64))
(cd $(OBJ.64); \
env - PATH=$(PATH) $(MAKE) $(PARALLEL) $(OVERRIDES.64) $(ALL_TGT))

install_autoconf: $(BUILD32:yes=install_autoconf_32) \
$(BUILD64:yes=install_autoconf_64)

install_autoconf_32: all
mkdir -p $(DESTDIR)
(cd $(VER.32); \
(cd $(OBJ.32); \
env - PATH=$(PATH) \
$(MAKE) $(install_PARALLEL) $(OVERRIDES) DESTDIR=$(DESTDIR) install)

install_autoconf_64: all
mkdir -p $(DESTDIR)
(cd $(VER.64); \
(cd $(OBJ.64); \
env - PATH=$(PATH) \
$(MAKE) $(install_PARALLEL) $(OVERRIDES.64) DESTDIR=$(DESTDIR) \
install)

$(AUTOCONF_OUT.32): $(VER.32)/configure
(cd $(VER.32); \
$(AUTOCONF_OUT.32): $(VER.32)/configure | $(OBJ.32)
(cd $(OBJ.32); \
env - PATH=$(PATH) $(AUTOCONF_ENV) \
./configure $(AUTOCONF_OPTS.32))
$(SEPARATE_BUILD:yes=../$(VER.32)/)./configure $(AUTOCONF_OPTS.32))

$(AUTOCONF_OUT.64): $(VER.64)/configure
$(AUTOCONF_OUT.64): $(VER.64)/configure | $(OBJ.64)
(cd $(VER.64); \
env - PATH=$(PATH) $(AUTOCONF_ENV.64) \
./configure $(AUTOCONF_OPTS.64))
$(SEPARATE_BUILD:yes=../$(VER.64)/)./configure $(AUTOCONF_OPTS.64))

$(VER.32)/$(UNPACK_SENTINEL): $(TARBALL)
-rm -rf $(VER.32)
-rm -rf $(VER.32) $(OBJ.32)
mkdir -p .unpack32
gtar x -C .unpack32 $(TARBALL_COMPRESS) --no-same-owner -f $(TARBALL)
$(APPLY_PATCHES.32)
Expand All @@ -66,7 +68,7 @@ $(VER.32)/$(UNPACK_SENTINEL): $(TARBALL)
touch $(VER.32)/$(UNPACK_SENTINEL)

$(VER.64)/$(UNPACK_SENTINEL): $(TARBALL)
-rm -rf $(VER.64)
-rm -rf $(VER.64) $(OBJ.64)
mkdir -p .unpack64
gtar x -C .unpack64 $(TARBALL_COMPRESS) --no-same-owner -f $(TARBALL)
$(APPLY_PATCHES.64)
Expand All @@ -75,6 +77,12 @@ $(VER.64)/$(UNPACK_SENTINEL): $(TARBALL)
$(FROB_SENTINEL.64)
touch $(VER.64)/$(UNPACK_SENTINEL)

$(VER.32).build: $(VER.32)/$(UNPACK_SENTINEL)
mkdir -p "$@"

$(VER.64).build: $(VER.64)/$(UNPACK_SENTINEL)
mkdir -p "$@"

clean:
-rm -rf $(VER) $(VER.32) $(VER.64) .unpack32 .unpack64 $(CLEANFILES) \
$(VER.32)strap $(VER.64)strap
$(VER.32)strap $(VER.64)strap $(OBJ.32) $(OBJ.64)
126 changes: 73 additions & 53 deletions gcc4/Makefile
Expand Up @@ -23,68 +23,88 @@
# Copyright (c) 2013, Joyent, Inc. All rights reserved.
#

#
# This makefile has not been adapted to use the infrastructure because of
# the need to build in a separate subdirectory from the source. This could
# be accommodated without excessive effort but is a highly unusual pattern.
#

VER = gcc-4.4.4
MPFR_VER = mpfr-3.1.2
GMP_VER = gmp-5.1.1

include ../Makefile.defs

CLEANFILES += $(VER)-i386-build
SEPARATE_BUILD = yes

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

include ../Makefile.targ
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)"

#
# 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++, and this will
# need more work to be really right. We only deliver the libraries.
#
AUTOCONF_CPPFLAGS =
AUTOCONF_LIBS =
GENLDFLAGS =

PATCHES = Patches/*
ALL_TGT = bootstrap

all: $(VER)-i386-build/config.status
(cd $(VER)-i386-build; env - \
CC=$(GCC) \
CFLAGS="-g -O2" \
DESTDIR=$(DESTDIR) \
PATH=$(PATH) \
STAGE1_CFLAGS="-g -O2" \
CFLAGS_FOR_TARGET="-g -O2" \
MAKE=gmake gmake \
CFLAGS="-g -O2" \
STAGE1_CFLAGS="-g -O2" \
CFLAGS_FOR_TARGET="-g -O2" $(PARALLEL) bootstrap)
include ../Makefile.targ
include ../Makefile.targ.autoconf

install: all
(cd $(VER)-i386-build; env - \
CC=$(GCC) \
CFLAGS="-g -O2" \
STAGE1_CFLAGS="-g -O2" \
CFLAGS_FOR_TARGET="-g -O2" \
DESTDIR=$(DESTDIR) \
PATH=$(PATH) \
MAKE=gmake gmake \
CFLAGS="-g -O2" \
STAGE1_CFLAGS="-g -O2" \
CFLAGS_FOR_TARGET="-g -O2" $(PARALLEL) install)
#
# 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. So 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.
#
# So Instead we have mpfr and gmp built as part of the gcc build itself.
#
$(AUTOCONF_OUT.32): | $(VER.32)/mpfr $(VER.32)/gmp

$(VER)-i386-build/config.status: $(VER)-i386-build $(VER.32)/configure
(cd $(VER)-i386-build; env - \
CC=$(GCC) \
CFLAGS="-g -O2" \
DESTDIR=$(DESTDIR) \
PATH=$(PATH) \
MAKE=gmake \
../$(VER.32)/configure \
--prefix=/usr \
--with-ld=/usr/bin/ld \
--without-gnu-ld \
--with-gnu-as \
--with-as=$(DESTDIR)/usr/gnu/bin/gas \
--enable-languages="c,c++" \
--enable-shared \
--with-gmp=/opt/local \
--with-mpfr=/opt/local \
--disable-nls \
--with-included-gettext)
$(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)-i386-build:
mkdir -p $@
$(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
28 changes: 28 additions & 0 deletions gcc4/Patches/mpfr-intree.diff
@@ -0,0 +1,28 @@
diff -ur gcc-4.4.4/configure gcc-4.4.4-32strap/configure
--- gcc-4.4.4/configure 2012-12-18 22:07:07.000000000 +0000
+++ gcc-4.4.4-32strap/configure 2013-04-22 18:05:25.747813505 +0000
@@ -4542,8 +4542,8 @@
gmplibs="-L$with_mpfr_lib $gmplibs"
fi
if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
- gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/.libs -L$$r/$(HOST_SUBDIR)/mpfr/_libs '"$gmplibs"
- gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
+ gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/.libs -L$$r/$(HOST_SUBDIR)/mpfr/src/_libs '"$gmplibs"
+ gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr/src '"$gmpinc"
# Do not test the mpfr version. Assume that it is sufficient, since
# it is in the source tree, and the library has not been built yet
# but it would be included on the link line in the version check below
diff -ur gcc-4.4.4/configure.ac gcc-4.4.4-32strap/configure.ac
--- gcc-4.4.4/configure.ac 2012-12-18 22:07:07.000000000 +0000
+++ gcc-4.4.4-32strap/configure.ac 2013-04-22 18:05:05.314274252 +0000
@@ -1216,8 +1216,8 @@
gmplibs="-L$with_mpfr_lib $gmplibs"
fi
if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
- gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/.libs -L$$r/$(HOST_SUBDIR)/mpfr/_libs '"$gmplibs"
- gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
+ gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/.libs -L$$r/$(HOST_SUBDIR)/mpfr/src/_libs '"$gmplibs"
+ gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr/src '"$gmpinc"
# Do not test the mpfr version. Assume that it is sufficient, since
# it is in the source tree, and the library has not been built yet
# but it would be included on the link line in the version check below
Binary file added gcc4/gmp-5.1.1.tar.bz2
Binary file not shown.
Binary file added gcc4/mpfr-3.1.2.tar.gz
Binary file not shown.

0 comments on commit 884461b

Please sign in to comment.