Skip to content

Commit 884461b

Browse files
author
Keith M Wesolowski
committed
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
1 parent 72e119d commit 884461b

6 files changed

+127
-67
lines changed

Makefile.defs

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ BASE = $(PWD)
2525
DESTDIR = $(BASE)/../proto
2626
VER.32 = $(VER)-32$(STRAP)
2727
VER.64 = $(VER)-64$(STRAP)
28+
OBJ.32 = $(VER.32)$(SEPARATE_BUILD:yes=.build)
29+
OBJ.64 = $(VER.64)$(SEPARATE_BUILD:yes=.build)
2830

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

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

5052
BUILD32 = yes
5153
BUILD64 =
54+
SEPARATE_BUILD =
5255

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

@@ -87,8 +90,8 @@ AUTOCONF_LIBS = LIBS="$(LIBS)"
8790
AUTOCONF_LIBS.64 = LIBS="$(LIBS.64)"
8891

8992
AUTOCONF_OUT = config.status
90-
AUTOCONF_OUT.32 = $(VER.32)/$(AUTOCONF_OUT)
91-
AUTOCONF_OUT.64 = $(VER.64)/$(AUTOCONF_OUT)
93+
AUTOCONF_OUT.32 = $(OBJ.32)/$(AUTOCONF_OUT)
94+
AUTOCONF_OUT.64 = $(OBJ.64)/$(AUTOCONF_OUT)
9295

9396
AUTOCONF_PREFIX = /usr
9497

@@ -119,6 +122,7 @@ AUTOCONF_OPTS.32 = \
119122
AUTOCONF_OPTS.64 = \
120123
$(AUTOCONF_OPTS)
121124

125+
ALL_TGT =
122126
OVERRIDES = $(MAKE_VERBOSE)
123127

124128
TARBALL = $(VER).tar.gz

Makefile.targ

+20-12
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,41 @@
2424
all_autoconf: $(BUILD32:yes=all_autoconf_32) $(BUILD64:yes=all_autoconf_64)
2525

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

2930
all_autoconf_64: $(AUTOCONF_OUT.64)
30-
(cd $(VER.64); env - PATH=$(PATH) $(MAKE) $(PARALLEL) $(OVERRIDES.64))
31+
(cd $(OBJ.64); \
32+
env - PATH=$(PATH) $(MAKE) $(PARALLEL) $(OVERRIDES.64) $(ALL_TGT))
3133

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

3537
install_autoconf_32: all
3638
mkdir -p $(DESTDIR)
37-
(cd $(VER.32); \
39+
(cd $(OBJ.32); \
3840
env - PATH=$(PATH) \
3941
$(MAKE) $(install_PARALLEL) $(OVERRIDES) DESTDIR=$(DESTDIR) install)
4042

4143
install_autoconf_64: all
4244
mkdir -p $(DESTDIR)
43-
(cd $(VER.64); \
45+
(cd $(OBJ.64); \
4446
env - PATH=$(PATH) \
4547
$(MAKE) $(install_PARALLEL) $(OVERRIDES.64) DESTDIR=$(DESTDIR) \
4648
install)
4749

48-
$(AUTOCONF_OUT.32): $(VER.32)/configure
49-
(cd $(VER.32); \
50+
$(AUTOCONF_OUT.32): $(VER.32)/configure | $(OBJ.32)
51+
(cd $(OBJ.32); \
5052
env - PATH=$(PATH) $(AUTOCONF_ENV) \
51-
./configure $(AUTOCONF_OPTS.32))
53+
$(SEPARATE_BUILD:yes=../$(VER.32)/)./configure $(AUTOCONF_OPTS.32))
5254

53-
$(AUTOCONF_OUT.64): $(VER.64)/configure
55+
$(AUTOCONF_OUT.64): $(VER.64)/configure | $(OBJ.64)
5456
(cd $(VER.64); \
5557
env - PATH=$(PATH) $(AUTOCONF_ENV.64) \
56-
./configure $(AUTOCONF_OPTS.64))
58+
$(SEPARATE_BUILD:yes=../$(VER.64)/)./configure $(AUTOCONF_OPTS.64))
5759

5860
$(VER.32)/$(UNPACK_SENTINEL): $(TARBALL)
59-
-rm -rf $(VER.32)
61+
-rm -rf $(VER.32) $(OBJ.32)
6062
mkdir -p .unpack32
6163
gtar x -C .unpack32 $(TARBALL_COMPRESS) --no-same-owner -f $(TARBALL)
6264
$(APPLY_PATCHES.32)
@@ -66,7 +68,7 @@ $(VER.32)/$(UNPACK_SENTINEL): $(TARBALL)
6668
touch $(VER.32)/$(UNPACK_SENTINEL)
6769

6870
$(VER.64)/$(UNPACK_SENTINEL): $(TARBALL)
69-
-rm -rf $(VER.64)
71+
-rm -rf $(VER.64) $(OBJ.64)
7072
mkdir -p .unpack64
7173
gtar x -C .unpack64 $(TARBALL_COMPRESS) --no-same-owner -f $(TARBALL)
7274
$(APPLY_PATCHES.64)
@@ -75,6 +77,12 @@ $(VER.64)/$(UNPACK_SENTINEL): $(TARBALL)
7577
$(FROB_SENTINEL.64)
7678
touch $(VER.64)/$(UNPACK_SENTINEL)
7779

80+
$(VER.32).build: $(VER.32)/$(UNPACK_SENTINEL)
81+
mkdir -p "$@"
82+
83+
$(VER.64).build: $(VER.64)/$(UNPACK_SENTINEL)
84+
mkdir -p "$@"
85+
7886
clean:
7987
-rm -rf $(VER) $(VER.32) $(VER.64) .unpack32 .unpack64 $(CLEANFILES) \
80-
$(VER.32)strap $(VER.64)strap
88+
$(VER.32)strap $(VER.64)strap $(OBJ.32) $(OBJ.64)

gcc4/Makefile

+73-53
Original file line numberDiff line numberDiff line change
@@ -23,68 +23,88 @@
2323
# Copyright (c) 2013, Joyent, Inc. All rights reserved.
2424
#
2525

26-
#
27-
# This makefile has not been adapted to use the infrastructure because of
28-
# the need to build in a separate subdirectory from the source. This could
29-
# be accommodated without excessive effort but is a highly unusual pattern.
30-
#
31-
3226
VER = gcc-4.4.4
27+
MPFR_VER = mpfr-3.1.2
28+
GMP_VER = gmp-5.1.1
3329

3430
include ../Makefile.defs
3531

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

3834
GCC = /opt/local/bin/gcc
3935
GXX = /bin/false
36+
CFLAGS = -nostdinc -isystem /usr/include -g -O2
4037

41-
include ../Makefile.targ
38+
AUTOCONF_OPTS += \
39+
--with-ld=/usr/bin/ld \
40+
--without-gnu-ld \
41+
--with-gnu-as \
42+
--with-as=$(DESTDIR)/usr/gnu/bin/gas \
43+
--enable-languages="c,c++" \
44+
--enable-shared \
45+
--disable-nls
46+
47+
AUTOCONF_ENV += \
48+
DESTDIR=$(DESTDIR) \
49+
MAKE=$(MAKE)
50+
51+
OVERRIDES += \
52+
$(AUTOCONF_CFLAGS) \
53+
STAGE1_CFLAGS="$(CFLAGS)" \
54+
CFLAGS_FOR_TARGET="$(CFLAGS)"
55+
56+
#
57+
# Unlike everything else, gcc is built to be a cross-compiler, really. It
58+
# never runs on the target system, only the build system. So it should not
59+
# be using the proto area's headers or libraries. Its own libraries will be
60+
# built by the new compiler, and generally aren't using system headers anyway.
61+
# This is not really completely true; for example, libstdc++, and this will
62+
# need more work to be really right. We only deliver the libraries.
63+
#
64+
AUTOCONF_CPPFLAGS =
65+
AUTOCONF_LIBS =
66+
GENLDFLAGS =
67+
68+
PATCHES = Patches/*
69+
ALL_TGT = bootstrap
4270

43-
all: $(VER)-i386-build/config.status
44-
(cd $(VER)-i386-build; env - \
45-
CC=$(GCC) \
46-
CFLAGS="-g -O2" \
47-
DESTDIR=$(DESTDIR) \
48-
PATH=$(PATH) \
49-
STAGE1_CFLAGS="-g -O2" \
50-
CFLAGS_FOR_TARGET="-g -O2" \
51-
MAKE=gmake gmake \
52-
CFLAGS="-g -O2" \
53-
STAGE1_CFLAGS="-g -O2" \
54-
CFLAGS_FOR_TARGET="-g -O2" $(PARALLEL) bootstrap)
71+
include ../Makefile.targ
72+
include ../Makefile.targ.autoconf
5573

56-
install: all
57-
(cd $(VER)-i386-build; env - \
58-
CC=$(GCC) \
59-
CFLAGS="-g -O2" \
60-
STAGE1_CFLAGS="-g -O2" \
61-
CFLAGS_FOR_TARGET="-g -O2" \
62-
DESTDIR=$(DESTDIR) \
63-
PATH=$(PATH) \
64-
MAKE=gmake gmake \
65-
CFLAGS="-g -O2" \
66-
STAGE1_CFLAGS="-g -O2" \
67-
CFLAGS_FOR_TARGET="-g -O2" $(PARALLEL) install)
74+
#
75+
# We could use the mpfr and gmp from the build system (since the compiler will
76+
# be run here), but there's no good way to make gcc build itself correctly if
77+
# we do. There are two main problems:
78+
#
79+
# 1. Stage2 and later cc1 and company don't honour any combination of LDFLAGS,
80+
# LDFLAGS_FOR_TARGET, BOOT_LDFLAGS, STAGE2_LDFLAGS, etc. So the only ways to
81+
# get these things built with -R/opt/local/lib are to use LD_OPTIONS which will
82+
# yield the wrong results for libraries or to hack configure.
83+
#
84+
# 2. Even if we could get -R/opt/local/lib into these programs without building
85+
# the libraries incorrectly, it would still be wrong. The pkgsrc lib directory
86+
# on many systems contains libgcc_s.so.1; however, cc1 was built by the stage2
87+
# compiler and should find the libgcc that matches that compiler. That happens
88+
# to be the one we just built, not the pkgsrc one.
89+
#
90+
# So Instead we have mpfr and gmp built as part of the gcc build itself.
91+
#
92+
$(AUTOCONF_OUT.32): | $(VER.32)/mpfr $(VER.32)/gmp
6893

69-
$(VER)-i386-build/config.status: $(VER)-i386-build $(VER.32)/configure
70-
(cd $(VER)-i386-build; env - \
71-
CC=$(GCC) \
72-
CFLAGS="-g -O2" \
73-
DESTDIR=$(DESTDIR) \
74-
PATH=$(PATH) \
75-
MAKE=gmake \
76-
../$(VER.32)/configure \
77-
--prefix=/usr \
78-
--with-ld=/usr/bin/ld \
79-
--without-gnu-ld \
80-
--with-gnu-as \
81-
--with-as=$(DESTDIR)/usr/gnu/bin/gas \
82-
--enable-languages="c,c++" \
83-
--enable-shared \
84-
--with-gmp=/opt/local \
85-
--with-mpfr=/opt/local \
86-
--disable-nls \
87-
--with-included-gettext)
94+
$(VER.32)/mpfr: $(MPFR_VER).tar.gz | $(VER.32)
95+
-rm -rf $@
96+
mkdir -p .unpack32
97+
gtar x -C .unpack32 -z --no-same-owner -f $(MPFR_VER).tar.gz
98+
mv -f .unpack32/$(MPFR_VER) ./$@
99+
-rmdir .unpack32
100+
chmod 755 $@/configure
101+
touch $@/configure
88102

89-
$(VER)-i386-build:
90-
mkdir -p $@
103+
$(VER.32)/gmp: $(GMP_VER).tar.bz2 | $(VER.32)
104+
-rm -rf $@
105+
mkdir -p .unpack32
106+
gtar x -C .unpack32 -j --no-same-owner -f $(GMP_VER).tar.bz2
107+
mv -f .unpack32/$(GMP_VER) ./$@
108+
-rmdir .unpack32
109+
chmod 755 $@/configure
110+
touch $@/configure

gcc4/Patches/mpfr-intree.diff

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff -ur gcc-4.4.4/configure gcc-4.4.4-32strap/configure
2+
--- gcc-4.4.4/configure 2012-12-18 22:07:07.000000000 +0000
3+
+++ gcc-4.4.4-32strap/configure 2013-04-22 18:05:25.747813505 +0000
4+
@@ -4542,8 +4542,8 @@
5+
gmplibs="-L$with_mpfr_lib $gmplibs"
6+
fi
7+
if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
8+
- gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/.libs -L$$r/$(HOST_SUBDIR)/mpfr/_libs '"$gmplibs"
9+
- gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
10+
+ gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/.libs -L$$r/$(HOST_SUBDIR)/mpfr/src/_libs '"$gmplibs"
11+
+ gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr/src '"$gmpinc"
12+
# Do not test the mpfr version. Assume that it is sufficient, since
13+
# it is in the source tree, and the library has not been built yet
14+
# but it would be included on the link line in the version check below
15+
diff -ur gcc-4.4.4/configure.ac gcc-4.4.4-32strap/configure.ac
16+
--- gcc-4.4.4/configure.ac 2012-12-18 22:07:07.000000000 +0000
17+
+++ gcc-4.4.4-32strap/configure.ac 2013-04-22 18:05:05.314274252 +0000
18+
@@ -1216,8 +1216,8 @@
19+
gmplibs="-L$with_mpfr_lib $gmplibs"
20+
fi
21+
if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
22+
- gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/.libs -L$$r/$(HOST_SUBDIR)/mpfr/_libs '"$gmplibs"
23+
- gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
24+
+ gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/.libs -L$$r/$(HOST_SUBDIR)/mpfr/src/_libs '"$gmplibs"
25+
+ gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr/src '"$gmpinc"
26+
# Do not test the mpfr version. Assume that it is sufficient, since
27+
# it is in the source tree, and the library has not been built yet
28+
# but it would be included on the link line in the version check below

gcc4/gmp-5.1.1.tar.bz2

2.11 MB
Binary file not shown.

gcc4/mpfr-3.1.2.tar.gz

1.55 MB
Binary file not shown.

0 commit comments

Comments
 (0)