diff options
author | 2018-05-24 16:05:04 -0700 | |
---|---|---|
committer | 2018-05-26 17:32:48 -0400 | |
commit | 1b4a99913beba2fb4edccb58481a92e8ab6a7d9f (patch) | |
tree | 1fc8a84ece671be7571e54e11fd10e7481abc5f6 /eclass/toolchain-funcs.eclass | |
parent | profiles: Drop obsolete Qt4 package.use.mask (diff) | |
download | gentoo-1b4a99913beba2fb4edccb58481a92e8ab6a7d9f.tar.gz gentoo-1b4a99913beba2fb4edccb58481a92e8ab6a7d9f.tar.bz2 gentoo-1b4a99913beba2fb4edccb58481a92e8ab6a7d9f.zip |
toolchain-funcs.eclass: fix tc-ld-disable-gold when using clang
tc-ld-disable-gold checks gcc version to see if we have gcc-4.8+
The version check fails if clang is set as the compiler.
$ clang -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"
4 2 1
i.e. clang returns a gcc version of 4.2.1
This results in incorrectly adding -B ... to LDFLAGS, when clang
supports "-fuse-ld" just fine.
Support for "-fuse-ld" first appeared in clang-3.5, so check clang
version and use the flag if supported.
Diffstat (limited to 'eclass/toolchain-funcs.eclass')
-rw-r--r-- | eclass/toolchain-funcs.eclass | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index 1c8090cf75c7..cea8949b45d7 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -391,11 +391,28 @@ tc-ld-disable-gold() { local path_ld=$(which "${bfd_ld}" 2>/dev/null) [[ -e ${path_ld} ]] && export LD=${bfd_ld} - # Set up LDFLAGS to select gold based on the gcc version. - local major=$(gcc-major-version "$@") - local minor=$(gcc-minor-version "$@") - if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]] ; then - # <=gcc-4.7 requires some coercion. Only works if bfd exists. + # Set up LDFLAGS to select gold based on the gcc / clang version. + local fallback="true" + if tc-is-gcc; then + local major=$(gcc-major-version "$@") + local minor=$(gcc-minor-version "$@") + if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then + # gcc-4.8+ supports -fuse-ld directly. + export LDFLAGS="${LDFLAGS} -fuse-ld=bfd" + fallback="false" + fi + elif tc-is-clang; then + local major=$(clang-major-version "$@") + local minor=$(clang-minor-version "$@") + if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then + # clang-3.5+ supports -fuse-ld directly. + export LDFLAGS="${LDFLAGS} -fuse-ld=bfd" + fallback="false" + fi + fi + if [[ ${fallback} == "true" ]] ; then + # <=gcc-4.7 and <=clang-3.4 require some coercion. + # Only works if bfd exists. if [[ -e ${path_ld} ]] ; then local d="${T}/bfd-linker" mkdir -p "${d}" @@ -404,9 +421,6 @@ tc-ld-disable-gold() { else die "unable to locate a BFD linker to bypass gold" fi - else - # gcc-4.8+ supports -fuse-ld directly. - export LDFLAGS="${LDFLAGS} -fuse-ld=bfd" fi } |