From a9aa54f601ca6fcf80c9a281357689ceeb80681a Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Thu, 27 Jun 2019 12:47:18 -0400 Subject: [PATCH 1/3] add support for using devtoolset-8 in built clang --- scripts/clang-devtoolset8-support.patch | 55 +++++++++++++++++++++++++ scripts/helpers/eosio.sh | 5 ++- 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 scripts/clang-devtoolset8-support.patch diff --git a/scripts/clang-devtoolset8-support.patch b/scripts/clang-devtoolset8-support.patch new file mode 100644 index 00000000000..64a946e26cd --- /dev/null +++ b/scripts/clang-devtoolset8-support.patch @@ -0,0 +1,55 @@ +From 32b65345c5760295d04c95e0abb3653fe20ffd16 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Tue, 9 Apr 2019 13:26:10 +0000 +Subject: [PATCH] Add support for detection of devtoolset-8 + +Summary: +The current llvm/clang et al. project can be built with the latest developer toolset (devtoolset-8) on RHEL, which provides GCC 8.2.1. +However, the result compiler will not identify this toolset itself when compiling programs, which is of course not desirable. + +After the patch - which simply adds the name of the developer toolset to the existing list - it gets identified and selected, as shown below: + +[bamboo@bamboo llvm-project]$ clang -v +clang version 9.0.0 (https://github.com/llvm/llvm-project.git e5ac385fb1ffa4bd3875ea6a4d24efdbd7814572) +Target: x86_64-unknown-linux-gnu +Thread model: posix +InstalledDir: /home/bamboo/llvm/bin +Found candidate GCC installation: /opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.2.1 +Found candidate GCC installation: /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7 +Found candidate GCC installation: /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8 +Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2 +Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5 +Selected GCC installation: /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8 +Candidate multilib: .;@m64 +Candidate multilib: 32;@m32 +Selected multilib: .;@m64 + +Patch By: Radu-Adrian Popescu + +Reviewers: tstellar, fedor.sergeev + +Reviewed By: tstellar + +Subscribers: jdoerfert, cfe-commits + +Tags: #clang + +Differential Revision: https://reviews.llvm.org/D59987 + +llvm-svn: 358002 +--- + clang/lib/Driver/ToolChains/Gnu.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp +index 2a58f0f7142..8915e3f948f 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -1875,6 +1875,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( + // Non-Solaris is much simpler - most systems just go with "/usr". + if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) { + // Yet, still look for RHEL devtoolsets. ++ Prefixes.push_back("/opt/rh/devtoolset-8/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-7/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-6/root/usr"); + Prefixes.push_back("/opt/rh/devtoolset-4/root/usr"); diff --git a/scripts/helpers/eosio.sh b/scripts/helpers/eosio.sh index d64cec238e0..34fbacac445 100755 --- a/scripts/helpers/eosio.sh +++ b/scripts/helpers/eosio.sh @@ -312,9 +312,10 @@ function build-clang() { && cd lld && git checkout $PINNED_COMPILER_LLD_COMMIT && cd ../ \ && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/polly.git \ && cd polly && git checkout $PINNED_COMPILER_POLLY_COMMIT && cd ../ \ - && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/clang.git clang && cd clang/tools \ + && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/clang.git clang && cd clang \ && git checkout $PINNED_COMPILER_CLANG_COMMIT \ - && mkdir extra && cd extra \ + && patch -p2 < \"$REPO_ROOT/scripts/clang-devtoolset8-support.patch\" \ + && cd tools && mkdir extra && cd extra \ && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/clang-tools-extra.git \ && cd clang-tools-extra && git checkout $PINNED_COMPILER_CLANG_TOOLS_EXTRA_COMMIT && cd .. \ && cd ../../../../projects \ From 30fe76f4dd39fcac3a78616ef17dee52ee15b6c0 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Thu, 27 Jun 2019 14:14:43 -0400 Subject: [PATCH 2/3] go back to devtoolset-8 on centos7 --- scripts/eosio_build_centos.sh | 12 ++++++------ scripts/helpers/general.sh | 8 ++++---- tests/bash-bats/eosio_build_centos.sh | 10 +++++----- tests/bash-bats/helpers/functions.sh | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/eosio_build_centos.sh b/scripts/eosio_build_centos.sh index e037f985106..9e20e86df55 100755 --- a/scripts/eosio_build_centos.sh +++ b/scripts/eosio_build_centos.sh @@ -12,14 +12,14 @@ echo "Disk space available: ${DISK_AVAIL}G" echo "" -# Repo necessary for rh-python3 and devtoolset-7 +# Repo necessary for rh-python3 and devtoolset-8 ensure-scl -# GCC7 for Centos / Needed for CMAKE install even if we're pinning +# GCC8 for Centos / Needed for CMAKE install even if we're pinning ensure-devtoolset -if [[ -d /opt/rh/devtoolset-7 ]]; then - echo "${COLOR_CYAN}[Enabling Centos devtoolset-7 (so we can use GCC 7)]${COLOR_NC}" - execute-always source /opt/rh/devtoolset-7/enable - echo " - ${COLOR_GREEN}Centos devtoolset-7 successfully enabled!${COLOR_NC}" +if [[ -d /opt/rh/devtoolset-8 ]]; then + echo "${COLOR_CYAN}[Enabling Centos devtoolset-8 (so we can use GCC 8)]${COLOR_NC}" + execute-always source /opt/rh/devtoolset-8/enable + echo " - ${COLOR_GREEN}Centos devtoolset-8 successfully enabled!${COLOR_NC}" fi # Ensure packages exist ensure-yum-packages "${REPO_ROOT}/scripts/eosio_build_centos7_deps" diff --git a/scripts/helpers/general.sh b/scripts/helpers/general.sh index 3f9e64981b3..4fc4761fda1 100755 --- a/scripts/helpers/general.sh +++ b/scripts/helpers/general.sh @@ -152,16 +152,16 @@ function ensure-scl() { } function ensure-devtoolset() { - echo "${COLOR_CYAN}[Ensuring installation of devtoolset-7]${COLOR_NC}" - DEVTOOLSET=$( rpm -qa | grep -E 'devtoolset-7-[0-9].*' || true ) + echo "${COLOR_CYAN}[Ensuring installation of devtoolset-8]${COLOR_NC}" + DEVTOOLSET=$( rpm -qa | grep -E 'devtoolset-8-[0-9].*' || true ) if [[ -z "${DEVTOOLSET}" ]]; then while true; do [[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Not Found: Do you wish to install it? (y/n)?${COLOR_NC}" && read -p " " PROCEED echo "" case $PROCEED in "" ) echo "What would you like to do?";; - 0 | true | [Yy]* ) install-package devtoolset-7; break;; - 1 | false | [Nn]* ) echo " - User aborted installation of devtoolset-7."; break;; + 0 | true | [Yy]* ) install-package devtoolset-8; break;; + 1 | false | [Nn]* ) echo " - User aborted installation of devtoolset-8."; break;; * ) echo "Please type 'y' for yes or 'n' for no.";; esac done diff --git a/tests/bash-bats/eosio_build_centos.sh b/tests/bash-bats/eosio_build_centos.sh index 7e25f3af292..c7927b4a38d 100644 --- a/tests/bash-bats/eosio_build_centos.sh +++ b/tests/bash-bats/eosio_build_centos.sh @@ -25,12 +25,12 @@ export TEST_LABEL="[eosio_build_centos]" set_system_vars # Obtain current machine's resources and set the necessary variables (like JOBS, etc) execute-always yum -y --enablerepo=extras install centos-release-scl &>/dev/null - install-package devtoolset-7 WETRUN &>/dev/null - # Ensure SCL and devtoolset-7 for c++ binary installation + install-package devtoolset-8 WETRUN &>/dev/null + # Ensure SCL and devtoolset-8 for c++ binary installation run bash -c "printf \"y\n%.0s\" {1..100}| ./${SCRIPT_LOCATION} -i /NEWPATH" [[ ! -z $(echo "${output}" | grep "centos-release-scl-2-3.el7.centos.noarch found") ]] || exit - [[ ! -z $(echo "${output}" | grep "devtoolset-7.* found") ]] || exit - [[ ! -z $(echo "${output}" | grep "Executing: source /opt/rh/devtoolset-7/enable") ]] || exit + [[ ! -z $(echo "${output}" | grep "devtoolset-8.* found") ]] || exit + [[ ! -z $(echo "${output}" | grep "Executing: source /opt/rh/devtoolset-8/enable") ]] || exit [[ ! -z $(echo "${output}" | grep "Executing: make -j${JOBS}") ]] || exit [[ ! -z $(echo "${output}" | grep "Starting EOSIO Dependency Install") ]] || exit [[ ! -z $(echo "${output}" | grep "Executing: eval /usr/bin/yum -y update") ]] || exit @@ -41,6 +41,6 @@ export TEST_LABEL="[eosio_build_centos]" [[ ! -z $(echo "${output}" | grep "Starting EOSIO Build") ]] || exit [[ ! -z $(echo "${output}" | grep "make -j${CPU_CORES}") ]] || exit [[ ! -z $(echo "${output}" | grep "EOSIO has been successfully built") ]] || exit - uninstall-package devtoolset-7* WETRUN &>/dev/null + uninstall-package devtoolset-8* WETRUN &>/dev/null uninstall-package centos-release-scl WETRUN &>/dev/null } \ No newline at end of file diff --git a/tests/bash-bats/helpers/functions.sh b/tests/bash-bats/helpers/functions.sh index fe720dc6f5f..f8edaea624a 100644 --- a/tests/bash-bats/helpers/functions.sh +++ b/tests/bash-bats/helpers/functions.sh @@ -21,7 +21,7 @@ function teardown() { # teardown is run once after each test, even if it fails uninstall-package which WETRUN export SUDO_FORCE_REMOVE=yes uninstall-package sudo WETRUN - uninstall-package devtoolset-7* WETRUN + uninstall-package devtoolset-8* WETRUN uninstall-package centos-release-scl uninstall-package gcc-c++ WETRUN if [[ $NAME == 'Ubuntu' ]]; then From ea492bde49b0dc3f9b1088e864ed97339ab9d978 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Thu, 27 Jun 2019 16:18:51 -0400 Subject: [PATCH 3/3] add patch as a required dep --- scripts/eosio_build_amazonlinux2_deps | 3 ++- scripts/eosio_build_centos7_deps | 3 ++- scripts/eosio_build_ubuntu_deps | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/eosio_build_amazonlinux2_deps b/scripts/eosio_build_amazonlinux2_deps index c599e9b1ae4..4017586125e 100755 --- a/scripts/eosio_build_amazonlinux2_deps +++ b/scripts/eosio_build_amazonlinux2_deps @@ -19,4 +19,5 @@ python-devel,rpm -qa libedit-devel,rpm -qa doxygen,rpm -qa graphviz,rpm -qa -clang,rpm -qa \ No newline at end of file +clang,rpm -qa +patch,rpm -qa \ No newline at end of file diff --git a/scripts/eosio_build_centos7_deps b/scripts/eosio_build_centos7_deps index 7f32fada681..60452c66252 100644 --- a/scripts/eosio_build_centos7_deps +++ b/scripts/eosio_build_centos7_deps @@ -17,4 +17,5 @@ rh-python36,rpm -qa gettext-devel,rpm -qa file,rpm -qa libusbx-devel,rpm -qa -libcurl-devel,rpm -qa \ No newline at end of file +libcurl-devel,rpm -qa +patch,rpm -qa \ No newline at end of file diff --git a/scripts/eosio_build_ubuntu_deps b/scripts/eosio_build_ubuntu_deps index bfb6b776148..e27bee25952 100644 --- a/scripts/eosio_build_ubuntu_deps +++ b/scripts/eosio_build_ubuntu_deps @@ -21,4 +21,5 @@ sudo,dpkg -s ruby,dpkg -s libusb-1.0-0-dev,dpkg -s libcurl4-gnutls-dev,dpkg -s -pkg-config,dpkg -s \ No newline at end of file +pkg-config,dpkg -s +patch,dpkg -s \ No newline at end of file