Exemplo n.º 1
0
    def disable_lto_mpfr_old_gcc(self, objdir):
        """
        # if GCC version used to build stage 1 is too old, build MPFR without LTO in stage 1
        # required for e.g. CentOS 6, cfr. https://github.com/easybuilders/easybuild-easyconfigs/issues/6374
        """
        self.log.info(
            "Checking whether we are trying to build a recent MPFR with an old GCC..."
        )

        # try to figure out MPFR version being built
        mpfr_ver = '0.0'
        mpfr_dirs = glob.glob(os.path.join(self.builddir, 'mpfr-*'))
        if len(mpfr_dirs) == 1:
            mpfr_dir = mpfr_dirs[0]
            res = re.search('(?P<mpfr_ver>[0-9.]+)$', mpfr_dir)
            if res:
                mpfr_ver = res.group('mpfr_ver')
                self.log.info(
                    "Found MPFR version %s (based name of MPFR source dir: %s)",
                    mpfr_ver, mpfr_dir)
            else:
                self.log.warning(
                    "Failed to determine MPFR version from '%s', assuming v%s",
                    mpfr_dir, mpfr_ver)
        else:
            self.log.warning(
                "Failed to isolate MPFR source dir to determine MPFR version, assuming v%s",
                mpfr_ver)

        # for MPFR v4.x & newer, we need a recent GCC that supports -flto
        if LooseVersion(mpfr_ver) >= LooseVersion('4.0'):
            # check GCC version being used
            # GCC 4.5 is required for -flto (cfr. https://gcc.gnu.org/gcc-4.5/changes.html)
            gcc_ver = get_gcc_version()
            min_gcc_ver_lto = '4.5'
            if gcc_ver is None:
                self.log.warning(
                    "Failed to determine GCC version, assuming it's recent enough..."
                )
            elif LooseVersion(gcc_ver) < LooseVersion(min_gcc_ver_lto):
                self.log.info(
                    "Configuring MPFR to build without LTO in stage 1 (GCC %s is too old: < %s)!",
                    gcc_ver, min_gcc_ver_lto)

                # patch GCC's Makefile to inject --disable-lto when building MPFR
                stage1_makefile = os.path.join(objdir, 'Makefile')
                regex_subs = [
                    (r'(--with-gmp-lib=\$\$r/\$\(HOST_SUBDIR\)/gmp/.libs) \\',
                     r'\1 --disable-lto \\')
                ]
                apply_regex_substitutions(stage1_makefile, regex_subs)
            else:
                self.log.info(
                    "GCC %s (>= %s) is OK for building MPFR in stage 1 with LTO enabled",
                    gcc_ver, min_gcc_ver_lto)
Exemplo n.º 2
0
def get_tbb_gccprefix():
    """
    Find the correct gcc version for the lib dir of TBB
    """
    # using get_software_version('GCC') won't work if the system toolchain is used
    gccversion = get_software_version('GCC')
    # manual approach to at least have the system version of gcc
    if not gccversion:
        gccversion = get_gcc_version()

    # TBB directory structure
    # https://www.threadingbuildingblocks.org/docs/help/tbb_userguide/Linux_OS.htm
    tbb_gccprefix = 'gcc4.4'  # gcc version 4.4 or higher that may or may not support exception_ptr
    if gccversion:
        gccversion = LooseVersion(gccversion)
        if gccversion >= LooseVersion("4.1") and gccversion < LooseVersion("4.4"):
            tbb_gccprefix = 'gcc4.1'  # gcc version number between 4.1 and 4.4 that do not support exception_ptr

    return tbb_gccprefix
Exemplo n.º 3
0
def get_tbb_gccprefix():
    """
    Find the correct gcc version for the lib dir of TBB
    """
    # using get_software_version('GCC') won't work, while the compiler toolchain is dummy:dummy, which does not
    # load dependencies.
    gccversion = get_software_version('GCC')
    # manual approach to at least have the system version of gcc
    if not gccversion:
        gccversion = get_gcc_version()

    # TBB directory structure
    # https://www.threadingbuildingblocks.org/docs/help/tbb_userguide/Linux_OS.htm
    tbb_gccprefix = 'gcc4.4'  # gcc version 4.4 or higher that may or may not support exception_ptr
    if gccversion:
        gccversion = LooseVersion(gccversion)
        if gccversion >= LooseVersion("4.1") and gccversion < LooseVersion("4.4"):
            tbb_gccprefix = 'gcc4.1'  # gcc version number between 4.1 and 4.4 that do not support exception_ptr

    return tbb_gccprefix
Exemplo n.º 4
0
    def disable_lto_mpfr_old_gcc(self, objdir):
        """
        # if GCC version used to build stage 1 is too old, build MPFR without LTO in stage 1
        # required for e.g. CentOS 6, cfr. https://github.com/easybuilders/easybuild-easyconfigs/issues/6374
        """
        self.log.info("Checking whether we are trying to build a recent MPFR with an old GCC...")

        # try to figure out MPFR version being built
        mpfr_ver = '0.0'
        mpfr_dirs = glob.glob(os.path.join(self.builddir, 'mpfr-*'))
        if len(mpfr_dirs) == 1:
            mpfr_dir = mpfr_dirs[0]
            res = re.search('(?P<mpfr_ver>[0-9.]+)$', mpfr_dir)
            if res:
                mpfr_ver = res.group('mpfr_ver')
                self.log.info("Found MPFR version %s (based name of MPFR source dir: %s)", mpfr_ver, mpfr_dir)
            else:
                self.log.warning("Failed to determine MPFR version from '%s', assuming v%s", mpfr_dir, mpfr_ver)
        else:
            self.log.warning("Failed to isolate MPFR source dir to determine MPFR version, assuming v%s", mpfr_ver)

        # for MPFR v4.x & newer, we need a recent GCC that supports -flto
        if LooseVersion(mpfr_ver) >= LooseVersion('4.0'):
            # check GCC version being used
            # GCC 4.5 is required for -flto (cfr. https://gcc.gnu.org/gcc-4.5/changes.html)
            gcc_ver = get_gcc_version()
            min_gcc_ver_lto = '4.5'
            if gcc_ver is None:
                self.log.warning("Failed to determine GCC version, assuming it's recent enough...")
            elif LooseVersion(gcc_ver) < LooseVersion(min_gcc_ver_lto):
                self.log.info("Configuring MPFR to build without LTO in stage 1 (GCC %s is too old: < %s)!",
                              gcc_ver, min_gcc_ver_lto)

                # patch GCC's Makefile to inject --disable-lto when building MPFR
                stage1_makefile = os.path.join(objdir, 'Makefile')
                regex_subs = [(r'(--with-gmp-lib=\$\$r/\$\(HOST_SUBDIR\)/gmp/.libs) \\', r'\1 --disable-lto \\')]
                apply_regex_substitutions(stage1_makefile, regex_subs)
            else:
                self.log.info("GCC %s (>= %s) is OK for building MPFR in stage 1 with LTO enabled",
                              gcc_ver, min_gcc_ver_lto)
Exemplo n.º 5
0
 def test_gcc_version_darwin(self):
     """Test getting gcc version (mocked for Darwin)."""
     st.get_os_type = lambda: st.DARWIN
     st.run_cmd = lambda *args, **kwargs: (
         "Apple LLVM version 7.0.0 (clang-700.1.76)", 0)
     self.assertEqual(get_gcc_version(), None)
Exemplo n.º 6
0
 def test_gcc_version_linux(self):
     """Test getting gcc version (mocked for Linux)."""
     st.get_os_type = lambda: st.LINUX
     st.run_cmd = mocked_run_cmd
     self.assertEqual(get_gcc_version(), '5.1.1')
Exemplo n.º 7
0
 def test_gcc_version_native(self):
     """Test getting gcc version."""
     gcc_version = get_gcc_version()
     self.assertTrue(
         isinstance(gcc_version, basestring) or gcc_version == None)
Exemplo n.º 8
0
 def test_gcc_version_darwin(self):
     """Test getting gcc version (mocked for Darwin)."""
     st.get_os_type = lambda: st.DARWIN
     st.run_cmd = lambda *args, **kwargs: ("Apple LLVM version 7.0.0 (clang-700.1.76)", 0)
     self.assertEqual(get_gcc_version(), None)
Exemplo n.º 9
0
 def test_gcc_version_linux(self):
     """Test getting gcc version (mocked for Linux)."""
     st.get_os_type = lambda: st.LINUX
     st.run_cmd = mocked_run_cmd
     self.assertEqual(get_gcc_version(), '5.1.1')
Exemplo n.º 10
0
 def test_gcc_version_native(self):
     """Test getting gcc version."""
     gcc_version = get_gcc_version()
     self.assertTrue(isinstance(gcc_version, basestring) or gcc_version == UNKNOWN)
Exemplo n.º 11
0
    def disable_lto_mpfr_old_gcc(self, objdir):
        """
        # if GCC version used to build stage 1 is too old, build MPFR without LTO in stage 1
        # required for e.g. CentOS 6, cfr. https://github.com/easybuilders/easybuild-easyconfigs/issues/6374
        """
        self.log.info(
            "Checking whether we are trying to build a recent MPFR with an old GCC..."
        )

        # try to figure out MPFR version being built
        mpfr_ver = '0.0'
        mpfr_dirs = glob.glob(os.path.join(self.builddir, 'mpfr-*'))
        if len(mpfr_dirs) == 1:
            mpfr_dir = mpfr_dirs[0]
            res = re.search('(?P<mpfr_ver>[0-9.]+)$', mpfr_dir)
            if res:
                mpfr_ver = res.group('mpfr_ver')
                self.log.info(
                    "Found MPFR version %s (based name of MPFR source dir: %s)",
                    mpfr_ver, mpfr_dir)
            else:
                self.log.warning(
                    "Failed to determine MPFR version from '%s', assuming v%s",
                    mpfr_dir, mpfr_ver)
        else:
            self.log.warning(
                "Failed to isolate MPFR source dir to determine MPFR version, assuming v%s",
                mpfr_ver)

        # for MPFR v4.x & newer, we need a recent GCC that supports -flto
        if LooseVersion(mpfr_ver) >= LooseVersion('4.0'):

            disable_mpfr_lto = False

            # check GCC version being used
            # GCC 4.5 is required for -flto (cfr. https://gcc.gnu.org/gcc-4.5/changes.html)
            gcc_ver = get_gcc_version()
            min_gcc_ver_lto = '4.5'
            if gcc_ver is None:
                self.log.warning(
                    "Failed to determine GCC version, assuming it's recent enough..."
                )
            elif LooseVersion(gcc_ver) < LooseVersion(min_gcc_ver_lto):
                self.log.info(
                    "Configuring MPFR to build without LTO in stage 1 (GCC %s is too old: < %s)!",
                    gcc_ver, min_gcc_ver_lto)
                disable_mpfr_lto = True
            else:
                self.log.info(
                    "GCC %s (>= %s) is OK for building MPFR in stage 1 with LTO enabled",
                    gcc_ver, min_gcc_ver_lto)

                # check whether GCC actually supports LTO (it may be configured with --disable-lto),
                # by compiling a simple C program using -flto
                out, ec = run_cmd(
                    "echo 'void main() {}' | gcc -x c -flto - -o /dev/null",
                    simple=False,
                    log_ok=False)
                gcc_path = which('gcc')
                if ec:
                    self.log.info(
                        "GCC command %s doesn't seem to support LTO, test compile failed: %s",
                        gcc_path, out)
                    disable_mpfr_lto = True
                else:
                    self.log.info(
                        "GCC command %s provides LTO support, so using it when building MPFR",
                        gcc_path)

            if disable_mpfr_lto:
                # patch GCC's Makefile to inject --disable-lto when building MPFR
                stage1_makefile = os.path.join(objdir, 'Makefile')
                regex_subs = [
                    (r'(--with-gmp-lib=\$\$r/\$\(HOST_SUBDIR\)/gmp/.libs) \\',
                     r'\1 --disable-lto \\')
                ]
                apply_regex_substitutions(stage1_makefile, regex_subs)