Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

Commit

Permalink
gcc-4.8: The revisit
Browse files Browse the repository at this point in the history
Remove GCC_PREFIX entirely, do not apply my fix for it either.
Remove .la files. They are considered harmful.
Fix lib search path (it must never be lib64, CMake reads this).
Disable /usr/local partly due to Homebrew, partly for reproducibility.

gcc-4.8: The revisit
  • Loading branch information
mingwandroid committed Oct 28, 2016
1 parent 03838ce commit aa7a390
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 78 deletions.
12 changes: 12 additions & 0 deletions gcc-4.8/0002-Disable-multiarch-like-suffixed-lib-dirs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -urN gcc-4.8.5.orig/gcc/config/i386/t-linux64 gcc-4.8.5/gcc/config/i386/t-linux64
--- gcc-4.8.5.orig/gcc/config/i386/t-linux64 2016-10-25 10:46:50.688505276 +0100
+++ gcc-4.8.5/gcc/config/i386/t-linux64 2016-10-25 10:48:43.730955397 +0100
@@ -33,6 +33,6 @@
comma=,
MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+MULTILIB_OSDIRNAMES = m64=../lib$(call if_multiarch,:x86_64-linux-gnu)
MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+MULTILIB_OSDIRNAMES+= mx32=../lib$(call if_multiarch,:x86_64-linux-gnux32)
13 changes: 13 additions & 0 deletions gcc-4.8/0003-Disable-usr-local.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff -urN gcc-4.8.5.orig/gcc/cppdefault.c gcc-4.8.5/gcc/cppdefault.c
--- gcc-4.8.5.orig/gcc/cppdefault.c 2016-10-25 10:46:42.848329208 +0100
+++ gcc-4.8.5/gcc/cppdefault.c 2016-10-25 11:08:08.809102425 +0100
@@ -35,6 +35,9 @@
# undef CROSS_INCLUDE_DIR
#endif

+/* This is mostly for macOS where Homebrew tends to live in /usr/local */
+#undef LOCAL_INCLUDE_DIR
+
const struct default_include cpp_include_defaults[]
#ifdef INCLUDE_DEFAULTS
= INCLUDE_DEFAULTS;
90 changes: 38 additions & 52 deletions gcc-4.8/build.sh
Original file line number Diff line number Diff line change
@@ -1,48 +1,25 @@
# Install gcc to its very own prefix.
# GCC must not be installed to the same prefix as the environment,
# because $GCC_PREFIX/include is automatically considered to be a
# "system" header path.
# That could cause -I$PREFIX/include to be essentially ignored in users' recipes
# (It would still be on the search path, but it would be in the wrong position in the search order.)
# .. Unfortunately:
# 1. Worked by relying on failure to relocate paths (until this commit).
# 2. .. and then not finding unrelocated folders, worse, if build from /root/miniconda3 as linux-32 4.8.5-3 was
# 3. .. led to 'Permission denied' failures from attempting to still access those unrelocated paths.
# The current implementation fixes it by making libiberty's relocation code capable of handling '..' and then
# configuring the various other (non-prefix) dirs as relative to '${GCC_PREFIX}/..'. This turns the two
# 'Permission Denied' errors into 'ignoring duplicate directory'.
# I disagree with the motivation behind this change. What it does is prevents #include <GL/gl.h> from finding
# Conda's version of gl.h, should we wish to use a custom one (angleproject for example) unless the user
# specifies -I${PREFIX}/include, and when they do that, that path is added to the *front* of the system
# includes path, which is *not* where it is meant to be. It is meant to appear between /usr/local/include and
# /usr/include as a block of 3 final system includes, and all of that comes after GCCs own headers and those
# from libstdc++. I will revist this later.
mkdir "${PREFIX}"/gcc

GCC_PREFIX="$PREFIX/gcc"
mkdir "$GCC_PREFIX"

ln -s "$PREFIX/lib" "$PREFIX/lib64"

# Please leave this here. It allows quickly testing on Linux.
# Please leave this here. It allows quick build and debug turnaround on Linux.
_DEBUG=0
declare -a extra_config
if [[ "${_DEBUG}" == "1" ]]; then
extra_config+=(--enable-languages=c,cxx)
extra_config+=(--with-build-config=bootstrap-O1)
extra_config+=(--enable-languages=c)
extra_config+=(--disable-bootstrap)
fi

if [ "$(uname)" == "Darwin" ]; then
# On Mac, we expect that the user has installed the xcode command-line utilities (via the 'xcode-select' command).
# The system's libstdc++.6.dylib will be located in /usr/lib, and we need to help the gcc build find it.
export LDFLAGS="-Wl,-headerpad_max_install_names -Wl,-L${PREFIX}/lib -Wl,-L/usr/lib"
export DYLD_FALLBACK_LIBRARY_PATH="$PREFIX/lib:/usr/lib"
export DYLD_FALLBACK_LIBRARY_PATH="${PREFIX}/lib:/usr/lib"

./configure \
--prefix="${GCC_PREFIX}" \
--with-gxx-include-dir="${GCC_PREFIX}/include/c++" \
--bindir="${GCC_PREFIX}/../bin" \
--datarootdir="${GCC_PREFIX}/../share" \
--libdir="${GCC_PREFIX}/../lib" \
--prefix="${PREFIX}" \
--with-gxx-include-dir="${PREFIX}"/gcc/include/c++ \
--bindir="${PREFIX}"/bin \
--datarootdir="${PREFIX}"/share \
--libdir="${PREFIX}"/lib \
--with-gmp="${PREFIX}" \
--with-mpfr="${PREFIX}" \
--with-mpc="${PREFIX}" \
Expand All @@ -61,18 +38,30 @@ else
# lsb_release can complain about LSB modules in stderr, so we
# ignore that.

lsb_release -a 1> "${PREFIX}/share/conda-gcc-build-machine-os-details"
lsb_release -a 1> "${PREFIX}"/share/conda-gcc-build-machine-os-details
if [[ ! -f /usr/lib/crtn.o ]]; then
if [[ -f /usr/lib64/crtn.o ]]; then
[[ -d host-x86_64-unknown-linux-gnu/lib/gcc ]] || mkdir -p host-x86_64-unknown-linux-gnu/lib/gcc
cp -rf /usr/lib64/crt*.o host-x86_64-unknown-linux-gnu/lib/gcc/
[[ -d "${PREFIX}"/lib ]] || mkdir -p "${PREFIX}"/lib
cp -rf /usr/lib64/crt*.o "${PREFIX}"/lib
else
echo "Fatal: Cannot find crt*.o"
exit 1
fi
fi

./configure \
--prefix="${GCC_PREFIX}" \
--with-gxx-include-dir="$GCC_PREFIX/include/c++" \
--bindir="${GCC_PREFIX}/../bin" \
--datarootdir="${GCC_PREFIX}/../share" \
--libdir="${GCC_PREFIX}/../lib" \
--with-gmp="$PREFIX" \
--with-mpfr="$PREFIX" \
--with-mpc="$PREFIX" \
--with-isl="$PREFIX" \
--with-cloog="$PREFIX" \
--prefix="${PREFIX}" \
--with-gxx-include-dir="${PREFIX}"/gcc/include/c++ \
--bindir="${PREFIX}"/bin \
--datarootdir="${PREFIX}"/share \
--libdir="${PREFIX}"/lib \
--with-gmp="${PREFIX}" \
--with-mpfr="${PREFIX}" \
--with-mpc="${PREFIX}" \
--with-isl="${PREFIX}" \
--with-cloog="${PREFIX}" \
--enable-checking=release \
--with-tune=generic \
--disable-multilib \
Expand All @@ -85,7 +74,7 @@ if [[ "${_DEBUG}" == "1" ]]; then
find . -name Makefile -print0 | xargs -0 sed -i 's,-O2,-O0,'
USED_CXXFLAGS="${CXXFLAGS} -ggdb -O0"
USED_CFLAGS="${CFLAGS} -ggdb -O0"
make STAGE1_CXXFLAGS="${USD_CXXFLAGS}" STAGE1_CFLAGS="${USED_CFLAGS}" all-stage1
make STAGE1_CXXFLAGS="${USD_CXXFLAGS}" STAGE1_CFLAGS="${USED_CFLAGS}"
# We don't get debug symbols for main() without this, weird.
if [[ $(uname -m) == i686 ]]; then
_BUILDDIR=host-i686-pc-linux-gnu
Expand All @@ -95,19 +84,16 @@ if [[ "${_DEBUG}" == "1" ]]; then
pushd ${_BUILDDIR}
find . -name Makefile -print0 | xargs -0 sed -i 's,-O2,-O0,'
rm -f gcc.o xgcc xg++
make -j"${CPU_COUNT}"
[[ -f Makefile ]] && make
popd
make install
else
make -j"${CPU_COUNT}"
make install-strip
fi

rm "$PREFIX"/lib64

#Fix libtool paths
find "$PREFIX" -name '*.la' -print0 | xargs -0 sed -i.backup 's%lib/../lib64%lib%g'
find "$PREFIX" -name '*la.backup' -print0 | xargs -0 rm -f
# Remove libtool .la files.
find "${PREFIX}" -name '*la' -print0 | xargs -0 rm -f

# Link cc to gcc
(cd "$PREFIX"/bin && ln -s gcc cc)
(cd "${PREFIX}"/bin && ln -s gcc cc)
16 changes: 12 additions & 4 deletions gcc-4.8/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ source:
url: http://www.netgull.com/gcc/releases/gcc-4.8.5/gcc-4.8.5.tar.bz2
md5: 80d2c2982a3392bb0b89673ff136e223
patches:
- 0001-Libiberty-normalize-split-directories.patch
# 0001- no longer needed. GCC_PREFIX is gone (though c++ headers still in `${PREFIX}/gcc`)
# - 0001-Libiberty-normalize-split-directories.patch
# --print-search-dirs needs to agree with conda's library layout for various reasons.
# One being that otherwise `-lsomelib` will not find the library in `$CONDA_PREFIX/lib`
# An example of where this is critical is in CMake which omits the full filepath when it
# assumes the compiler will find it without that. This is *also* a bug in CMake as it
# should have asked the compiler for its real library search dirs via `--print-search-dirs`
# instead of assuming `$PREFIX/lib`.
- 0002-Disable-multiarch-like-suffixed-lib-dirs.patch
# We never want local software (or Homebrew) leaking into our software.
- 0003-Disable-usr-local.patch

# GCC relocates itself correctly under most circumstances, and 0001-.patch
# along with using ${GCC_PREFIX}/.. fixes the issues with our configuration.
build:
detect_binary_files_with_prefix: false
number: 6
number: 7

requirements:
build:
Expand Down
22 changes: 0 additions & 22 deletions gcc-4.8/run_test.py

This file was deleted.

0 comments on commit aa7a390

Please sign in to comment.