From aa7a390b45b95a031523a60231840daede51402c Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Thu, 27 Oct 2016 13:26:20 +0100 Subject: [PATCH] gcc-4.8: The revisit 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 --- ...ble-multiarch-like-suffixed-lib-dirs.patch | 12 +++ gcc-4.8/0003-Disable-usr-local.patch | 13 +++ gcc-4.8/build.sh | 90 ++++++++----------- gcc-4.8/meta.yaml | 16 +++- gcc-4.8/run_test.py | 22 ----- 5 files changed, 75 insertions(+), 78 deletions(-) create mode 100644 gcc-4.8/0002-Disable-multiarch-like-suffixed-lib-dirs.patch create mode 100644 gcc-4.8/0003-Disable-usr-local.patch delete mode 100644 gcc-4.8/run_test.py diff --git a/gcc-4.8/0002-Disable-multiarch-like-suffixed-lib-dirs.patch b/gcc-4.8/0002-Disable-multiarch-like-suffixed-lib-dirs.patch new file mode 100644 index 000000000..57f25c8b8 --- /dev/null +++ b/gcc-4.8/0002-Disable-multiarch-like-suffixed-lib-dirs.patch @@ -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) diff --git a/gcc-4.8/0003-Disable-usr-local.patch b/gcc-4.8/0003-Disable-usr-local.patch new file mode 100644 index 000000000..971fc0b93 --- /dev/null +++ b/gcc-4.8/0003-Disable-usr-local.patch @@ -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; diff --git a/gcc-4.8/build.sh b/gcc-4.8/build.sh index 83b66e264..94202a4eb 100644 --- a/gcc-4.8/build.sh +++ b/gcc-4.8/build.sh @@ -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 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}" \ @@ -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 \ @@ -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 @@ -95,7 +84,7 @@ 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 @@ -103,11 +92,8 @@ else 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) diff --git a/gcc-4.8/meta.yaml b/gcc-4.8/meta.yaml index dab1af55a..40de33989 100644 --- a/gcc-4.8/meta.yaml +++ b/gcc-4.8/meta.yaml @@ -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: diff --git a/gcc-4.8/run_test.py b/gcc-4.8/run_test.py deleted file mode 100644 index 64dd8ef33..000000000 --- a/gcc-4.8/run_test.py +++ /dev/null @@ -1,22 +0,0 @@ -import subprocess -import os - -def otool(path): - "thin wrapper around otool -L" - lines = subprocess.check_output(['otool', '-L', path]).decode('utf-8').splitlines() - assert lines[0].startswith(path), path - res = [] - for line in lines[1:]: - assert line[0] == '\t' - res.append(line.split()[0]) - return res - -def assert_relative_osx(path): - for name in otool(path): - assert not 'placehold' in name, path - -prefix = os.environ['PREFIX'] - -for f in os.listdir(os.path.join(prefix, 'lib')): - if f.endswith('dylib'): - assert_relative_osx(os.path.join(prefix, 'lib', f))