2022-01-13 03:21:41 +08:00
|
|
|
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
|
2018-10-08 04:52:23 +08:00
|
|
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
2016-05-12 12:22:25 +08:00
|
|
|
#
|
2018-10-08 04:52:23 +08:00
|
|
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
2022-02-17 15:45:24 +08:00
|
|
|
import re
|
2018-10-08 04:52:23 +08:00
|
|
|
|
2022-05-29 00:55:44 +08:00
|
|
|
from spack.package import *
|
|
|
|
|
2016-06-13 10:57:03 +08:00
|
|
|
|
2019-12-21 06:32:18 +08:00
|
|
|
class Binutils(AutotoolsPackage, GNUMirrorPackage):
|
2015-03-31 05:23:02 +08:00
|
|
|
"""GNU binutils, which contain the linker, assembler, objdump and others"""
|
|
|
|
|
2021-09-02 14:46:27 +08:00
|
|
|
homepage = "https://www.gnu.org/software/binutils/"
|
2019-12-21 06:32:18 +08:00
|
|
|
gnu_mirror_path = "binutils/binutils-2.28.tar.bz2"
|
2016-03-16 19:57:17 +08:00
|
|
|
|
2021-08-11 17:52:42 +08:00
|
|
|
maintainers = ["alalazo"]
|
2022-07-31 06:19:18 +08:00
|
|
|
|
2022-02-19 02:51:01 +08:00
|
|
|
tags = ["build-tools", "core-packages"]
|
2022-07-31 06:19:18 +08:00
|
|
|
|
2022-02-17 15:45:24 +08:00
|
|
|
executables = ["^nm$", "^readelf$"]
|
2022-07-31 06:19:18 +08:00
|
|
|
|
2022-02-19 21:02:34 +08:00
|
|
|
version("2.38", sha256="070ec71cf077a6a58e0b959f05a09a35015378c2d8a51e90f3aeabfe30590ef8")
|
2021-08-11 17:52:42 +08:00
|
|
|
version("2.37", sha256="67fc1a4030d08ee877a4867d3dcab35828148f87e1fd05da6db585ed5a166bd4")
|
2021-03-02 00:53:55 +08:00
|
|
|
version("2.36.1", sha256="5b4bd2e79e30ce8db0abd76dd2c2eae14a94ce212cfc59d3c37d23e24bc6d7a3")
|
|
|
|
version("2.35.2", sha256="cfa7644dbecf4591e136eb407c1c1da16578bd2b03f0c2e8acdceba194bb9d61")
|
2020-11-14 02:55:58 +08:00
|
|
|
version("2.35.1", sha256="320e7a1d0f46fcd9f413f1046e216cbe23bb2bce6deb6c6a63304425e48b1942")
|
2020-08-27 00:54:33 +08:00
|
|
|
version("2.35", sha256="7d24660f87093670738e58bcc7b7b06f121c0fcb0ca8fc44368d675a5ef9cff7")
|
2020-03-10 17:15:31 +08:00
|
|
|
version("2.34", sha256="89f010078b6cf69c23c27897d686055ab89b198dddf819efb0a4f2c38a0b36e6")
|
2020-01-23 07:24:21 +08:00
|
|
|
version("2.33.1", sha256="0cb4843da15a65a953907c96bad658283f3c4419d6bcc56bf2789db16306adb2")
|
|
|
|
version("2.32", sha256="de38b15c902eb2725eac6af21183a5f34ea4634cb0bcef19612b50e5ed31072d")
|
2019-10-11 13:44:41 +08:00
|
|
|
version("2.31.1", sha256="ffcc382695bf947da6135e7436b8ed52d991cf270db897190f19d6f9838564d0")
|
|
|
|
version("2.29.1", sha256="1509dff41369fb70aed23682351b663b56db894034773e6dbf7d5d6071fc55cc")
|
|
|
|
version("2.28", sha256="6297433ee120b11b4b0a1c8f3512d7d73501753142ab9e2daa13c5a3edd32a72")
|
|
|
|
version("2.27", sha256="369737ce51587f92466041a97ab7d2358c6d9e1b6490b3940eb09fb0a9a6ac88")
|
|
|
|
version("2.26", sha256="c2ace41809542f5237afc7e3b8f32bb92bc7bc53c6232a84463c423b0714ecd9")
|
2018-10-19 04:42:32 +08:00
|
|
|
version("2.25.1", sha256="b5b14added7d78a8d1ca70b5cb75fef57ce2197264f4f5835326b0df22ac9f22")
|
2019-10-11 13:44:41 +08:00
|
|
|
version("2.25", sha256="22defc65cfa3ef2a3395faaea75d6331c6e62ea5dfacfed3e2ec17b08c882923")
|
|
|
|
version("2.24", sha256="e5e8c5be9664e7f7f96e0d09919110ab5ad597794f5b1809871177a0f0f14137")
|
|
|
|
version("2.23.2", sha256="fe914e56fed7a9ec2eb45274b1f2e14b0d8b4f41906a5194eac6883cfe5c1097")
|
|
|
|
version("2.20.1", sha256="71d37c96451333c5c0b84b170169fdcb138bbb27397dc06281905d9717c8ed64")
|
2022-07-31 06:19:18 +08:00
|
|
|
|
2017-02-19 06:02:01 +08:00
|
|
|
variant("plugins", default=True, description="enable plugins, needed for gold linker")
|
2020-02-21 02:00:48 +08:00
|
|
|
variant("gold", default=False, description="build the gold linker")
|
2017-04-20 12:29:27 +08:00
|
|
|
variant("libiberty", default=False, description="Also install libiberty.")
|
2018-08-30 11:32:41 +08:00
|
|
|
variant("nls", default=True, description="Enable Native Language Support")
|
2019-01-24 12:40:58 +08:00
|
|
|
variant("headers", default=False, description="Install extra headers (e.g. ELF)")
|
2020-03-30 12:05:11 +08:00
|
|
|
variant("lto", default=False, description="Enable lto.")
|
|
|
|
variant("ld", default=False, description="Enable ld.")
|
2021-04-19 17:55:39 +08:00
|
|
|
variant("gas", default=False, description="Enable as assembler.")
|
2020-03-30 12:05:11 +08:00
|
|
|
variant("interwork", default=False, description="Enable interwork.")
|
2021-05-12 18:31:02 +08:00
|
|
|
variant(
|
|
|
|
"libs",
|
|
|
|
default="shared,static",
|
|
|
|
values=("shared", "static"),
|
|
|
|
multi=True,
|
|
|
|
description="Build shared libs, static libs or both",
|
|
|
|
)
|
2022-07-31 06:19:18 +08:00
|
|
|
|
2018-08-17 07:10:08 +08:00
|
|
|
patch("cr16.patch", when="@:2.29.1")
|
2016-06-13 10:46:11 +08:00
|
|
|
patch("update_symbol-2.26.patch", when="@2.26")
|
2016-01-17 23:49:13 +08:00
|
|
|
|
2021-10-13 01:01:46 +08:00
|
|
|
# 2.36 is missing some dependencies, this patch allows a parallel build.
|
|
|
|
# https://sourceware.org/bugzilla/show_bug.cgi?id=27482
|
|
|
|
patch("parallel-build-2.36.patch", when="@2.36")
|
|
|
|
|
2017-04-20 12:29:27 +08:00
|
|
|
depends_on("zlib")
|
2020-08-29 02:31:43 +08:00
|
|
|
depends_on("diffutils", type="build")
|
2018-08-30 11:32:41 +08:00
|
|
|
depends_on("gettext", when="+nls")
|
2017-04-20 12:29:27 +08:00
|
|
|
|
2018-08-30 11:32:41 +08:00
|
|
|
# Prior to 2.30, gold did not distribute the generated files and
|
|
|
|
# thus needs bison, even for a one-time build.
|
2021-10-03 21:09:02 +08:00
|
|
|
depends_on("m4", type="build", when="@:2.29 +gold")
|
|
|
|
depends_on("bison", type="build", when="@:2.29 +gold")
|
2015-11-07 03:47:00 +08:00
|
|
|
|
2022-04-27 18:11:48 +08:00
|
|
|
# 2.38 with +gas needs makeinfo due to a bug, see:
|
|
|
|
# https://sourceware.org/bugzilla/show_bug.cgi?id=28909
|
|
|
|
depends_on("texinfo", type="build", when="@2.38 +gas")
|
2020-03-12 08:34:24 +08:00
|
|
|
# 2.34 needs makeinfo due to a bug, see:
|
|
|
|
# https://sourceware.org/bugzilla/show_bug.cgi?id=25491
|
|
|
|
depends_on("texinfo", type="build", when="@2.34")
|
|
|
|
|
2020-02-21 02:00:48 +08:00
|
|
|
conflicts("+gold", when="platform=darwin", msg="Binutils cannot build linkers on macOS")
|
|
|
|
|
2021-04-20 15:27:12 +08:00
|
|
|
# When you build binutils with ~ld and +gas and load it in your PATH, you
|
|
|
|
# may end up with incompatibilities between a potentially older system ld
|
|
|
|
# and a recent assembler. For instance the linker on ubuntu 16.04 from
|
|
|
|
# binutils 2.26 and the assembler from binutils 2.36.1 will result in:
|
|
|
|
# "unable to initialize decompress status for section .debug_info"
|
|
|
|
# when compiling with debug symbols on gcc.
|
|
|
|
conflicts("+gas", "~ld", msg="Assembler not always compatible with system ld")
|
2021-04-19 17:55:39 +08:00
|
|
|
|
2021-05-03 05:27:43 +08:00
|
|
|
# When you build ld.gold you automatically get ld, even when you add the
|
|
|
|
# --disable-ld flag
|
|
|
|
conflicts("~ld", "+gold")
|
|
|
|
|
2022-02-17 15:45:24 +08:00
|
|
|
@classmethod
|
|
|
|
def determine_version(cls, exe):
|
|
|
|
output = Executable(exe)("--version", output=str, error=str)
|
2022-02-25 09:52:45 +08:00
|
|
|
match = re.search(r"GNU (nm|readelf).* (\S+)", output)
|
|
|
|
return Version(match.group(2)).dotted.up_to(3) if match else None
|
2022-02-17 15:45:24 +08:00
|
|
|
|
2021-05-18 00:26:15 +08:00
|
|
|
def setup_build_environment(self, env):
|
|
|
|
|
|
|
|
if self.spec.satisfies("%cce"):
|
|
|
|
env.append_flags("LDFLAGS", "-Wl,-z,muldefs")
|
|
|
|
|
2021-05-18 15:03:08 +08:00
|
|
|
if "+nls" in self.spec:
|
2021-05-18 00:26:15 +08:00
|
|
|
env.append_flags("LDFLAGS", "-lintl")
|
|
|
|
|
2017-03-21 07:07:37 +08:00
|
|
|
def configure_args(self):
|
|
|
|
spec = self.spec
|
|
|
|
|
2021-04-13 22:31:44 +08:00
|
|
|
args = [
|
2015-11-07 03:47:00 +08:00
|
|
|
"--disable-dependency-tracking",
|
2016-05-06 09:11:54 +08:00
|
|
|
"--disable-werror",
|
2015-11-07 03:47:00 +08:00
|
|
|
"--enable-multilib",
|
|
|
|
"--enable-64-bit-bfd",
|
2015-12-08 16:57:07 +08:00
|
|
|
"--enable-targets=all",
|
2018-08-30 11:32:41 +08:00
|
|
|
"--with-system-zlib",
|
2017-04-20 12:29:27 +08:00
|
|
|
"--with-sysroot=/",
|
|
|
|
]
|
2015-07-21 23:15:17 +08:00
|
|
|
|
2021-05-12 18:31:02 +08:00
|
|
|
args += self.enable_or_disable("libs")
|
2021-04-13 22:31:44 +08:00
|
|
|
args += self.enable_or_disable("lto")
|
|
|
|
args += self.enable_or_disable("ld")
|
2021-04-19 17:55:39 +08:00
|
|
|
args += self.enable_or_disable("gas")
|
2021-04-13 22:31:44 +08:00
|
|
|
args += self.enable_or_disable("interwork")
|
|
|
|
args += self.enable_or_disable("gold")
|
|
|
|
args += self.enable_or_disable("plugins")
|
2017-02-19 06:02:01 +08:00
|
|
|
|
2015-11-07 03:47:00 +08:00
|
|
|
if "+libiberty" in spec:
|
2021-04-13 22:31:44 +08:00
|
|
|
args.append("--enable-install-libiberty")
|
|
|
|
else:
|
|
|
|
args.append("--disable-install-libiberty")
|
2015-03-31 05:23:02 +08:00
|
|
|
|
2018-08-30 11:32:41 +08:00
|
|
|
if "+nls" in spec:
|
2021-04-13 22:31:44 +08:00
|
|
|
args.append("--enable-nls")
|
2018-08-30 11:32:41 +08:00
|
|
|
else:
|
2021-04-13 22:31:44 +08:00
|
|
|
args.append("--disable-nls")
|
2018-08-30 11:32:41 +08:00
|
|
|
|
2018-01-28 22:36:24 +08:00
|
|
|
# To avoid namespace collisions with Darwin/BSD system tools,
|
|
|
|
# prefix executables with "g", e.g., gar, gnm; see Homebrew
|
|
|
|
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/binutils.rb
|
|
|
|
if spec.satisfies("platform=darwin"):
|
2021-04-13 22:31:44 +08:00
|
|
|
args.append("--program-prefix=g")
|
2018-01-28 22:36:24 +08:00
|
|
|
|
2021-04-13 22:31:44 +08:00
|
|
|
return args
|
2019-01-24 12:40:58 +08:00
|
|
|
|
|
|
|
@run_after("install")
|
|
|
|
def install_headers(self):
|
|
|
|
# some packages (like TAU) need the ELF headers, so install them
|
|
|
|
# as a subdirectory in include/extras
|
|
|
|
if "+headers" in self.spec:
|
|
|
|
extradir = join_path(self.prefix.include, "extra")
|
|
|
|
mkdirp(extradir)
|
|
|
|
# grab the full binutils set of headers
|
|
|
|
install_tree("include", extradir)
|
|
|
|
# also grab the headers from the bfd directory
|
2020-09-04 01:47:19 +08:00
|
|
|
install(join_path(self.build_directory, "bfd", "*.h"), extradir)
|
2019-07-15 23:50:26 +08:00
|
|
|
|
|
|
|
def flag_handler(self, name, flags):
|
2022-05-02 21:38:07 +08:00
|
|
|
spec = self.spec
|
2021-05-10 16:03:24 +08:00
|
|
|
# Use a separate variable for injecting flags. This way, installing
|
|
|
|
# `binutils cflags='-O2'` will still work as expected.
|
|
|
|
iflags = []
|
2019-07-15 23:50:26 +08:00
|
|
|
# To ignore the errors of narrowing conversions for
|
|
|
|
# the Fujitsu compiler
|
2020-06-26 00:18:48 +08:00
|
|
|
if name == "cxxflags" and (
|
|
|
|
spec.satisfies("@:2.31.1") and self.compiler.name in ("fj", "clang", "apple-clang")
|
|
|
|
):
|
2021-05-10 16:03:24 +08:00
|
|
|
iflags.append("-Wno-narrowing")
|
2020-05-15 19:13:04 +08:00
|
|
|
elif name == "cflags":
|
2022-05-02 21:38:07 +08:00
|
|
|
if spec.satisfies("@:2.34 %gcc@10:"):
|
2021-05-10 16:03:24 +08:00
|
|
|
iflags.append("-fcommon")
|
2022-05-02 21:38:07 +08:00
|
|
|
if spec.satisfies("%cce") or spec.satisfies("@2.38 %gcc"):
|
|
|
|
iflags.extend([self.compiler.cc_pic_flag, "-fcommon"])
|
2022-04-29 15:36:52 +08:00
|
|
|
elif name == "ldflags":
|
2022-05-02 21:38:07 +08:00
|
|
|
if spec.satisfies("%cce") or spec.satisfies("@2.38 %gcc"):
|
2022-04-29 15:36:52 +08:00
|
|
|
iflags.append("-Wl,-z,notext")
|
2021-05-10 16:03:24 +08:00
|
|
|
return (iflags, None, flags)
|
spack test (#15702)
Users can add test() methods to their packages to run smoke tests on
installations with the new `spack test` command (the old `spack test` is
now `spack unit-test`). spack test is environment-aware, so you can
`spack install` an environment and then run `spack test run` to run smoke
tests on all of its packages. Historical test logs can be perused with
`spack test results`. Generic smoke tests for MPI implementations, C,
C++, and Fortran compilers as well as specific smoke tests for 18
packages.
Inside the test method, individual tests can be run separately (and
continue to run best-effort after a test failure) using the `run_test`
method. The `run_test` method encapsulates finding test executables,
running and checking return codes, checking output, and error handling.
This handles the following trickier aspects of testing with direct
support in Spack's package API:
- [x] Caching source or intermediate build files at build time for
use at test time.
- [x] Test dependencies,
- [x] packages that require a compiler for testing (such as library only
packages).
See the packaging guide for more details on using Spack testing support.
Included is support for package.py files for virtual packages. This does
not change the Spack interface, but is a major change in internals.
Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov>
Co-authored-by: wspear <wjspear@gmail.com>
Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
2020-11-18 18:39:02 +08:00
|
|
|
|
|
|
|
def test(self):
|
|
|
|
spec_vers = str(self.spec.version)
|
|
|
|
|
|
|
|
checks = {
|
|
|
|
"ar": spec_vers,
|
|
|
|
"c++filt": spec_vers,
|
|
|
|
"coffdump": spec_vers,
|
|
|
|
"dlltool": spec_vers,
|
|
|
|
"elfedit": spec_vers,
|
|
|
|
"gprof": spec_vers,
|
|
|
|
"ld": spec_vers,
|
|
|
|
"nm": spec_vers,
|
|
|
|
"objdump": spec_vers,
|
|
|
|
"ranlib": spec_vers,
|
|
|
|
"readelf": spec_vers,
|
|
|
|
"size": spec_vers,
|
|
|
|
"strings": spec_vers,
|
|
|
|
}
|
|
|
|
|
|
|
|
for exe in checks:
|
|
|
|
expected = checks[exe]
|
|
|
|
reason = "test: ensuring version of {0} is {1}".format(exe, expected)
|
|
|
|
self.run_test(
|
|
|
|
exe, "--version", expected, installed=True, purpose=reason, skip_missing=True
|
|
|
|
)
|