Bug 222925 - clang --coverage doesn't work with arm:armv6 and arm:armv7; lib/libclang_rt/Makefile.inc always assumes CRTARCH should be arm (soft-float arm)
Summary: clang --coverage doesn't work with arm:armv6 and arm:armv7; lib/libclang_rt/M...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-11 05:22 UTC by Enji Cooper
Modified: 2017-11-05 20:39 UTC (History)
3 users (show)

See Also:
ngie: mfc-stable10-
ngie: mfc-stable9-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer 2017-10-11 05:22:00 UTC
Saw this error with both arm:armv6 and arm:armv7:

9224 /scratch/tmp/ngie/obj/arm.armv6/scratch/tmp/ngie/svn/tmp/usr/bin/ld: /scratch/tmp/ngie/obj/arm.armv6/scratch/tmp/ngie/svn/tmp/usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.profile-armhf.a: No such file: No such file or directory
9225 cc: error: linker command failed with exit code 1 (use -v to see invocation)
9226 --- libc.so.7.full ---
9227 *** [libc.so.7.full] Error code 1

Both architectures are being treated like hard float architectures, based on a quick peek at contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp :

303   if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb)
304     return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows)
305                ? "armhf"
306                : "arm";
Comment 1 Ed Maste freebsd_committer 2017-10-11 13:40:59 UTC
How did you build (e.g. src.conf options)?
Comment 2 commit-hook freebsd_committer 2017-10-22 21:35:43 UTC
A commit references this bug:

Author: ngie
Date: Sun Oct 22 21:34:37 UTC 2017
New revision: 324873
URL: https://svnweb.freebsd.org/changeset/base/324873

Log:
  Define TARGET_CPUARCH and use in libclang_rt as the basis for CRTARCH

  When cross-compiling, the wrong architecture was being embedded in the
  libclang_rt binary filenames. It should be based on TARGET_ARCH (target), not
  MACHINE_ARCH (host).

  This is a draft commit against my project branch. Will fix on ^/head soon.

  PR:	222925

Changes:
  projects/runtime-coverage/lib/libclang_rt/Makefile.inc
  projects/runtime-coverage/share/mk/sys.mk
Comment 3 Dimitry Andric freebsd_committer 2017-10-22 22:04:51 UTC
(In reply to commit-hook from comment #2)
> A commit references this bug:
> 
> Author: ngie
> Date: Sun Oct 22 21:34:37 UTC 2017
> New revision: 324873
> URL: https://svnweb.freebsd.org/changeset/base/324873
> 
> Log:
>   Define TARGET_CPUARCH and use in libclang_rt as the basis for CRTARCH
> 
>   When cross-compiling, the wrong architecture was being embedded in the
>   libclang_rt binary filenames. It should be based on TARGET_ARCH (target),
> not
>   MACHINE_ARCH (host).

Yes, this looks like a fine approach.  Please commit this to head.
Comment 4 commit-hook freebsd_committer 2017-10-23 04:20:57 UTC
A commit references this bug:

Author: ngie
Date: Mon Oct 23 04:20:11 UTC 2017
New revision: 324893
URL: https://svnweb.freebsd.org/changeset/base/324893

Log:
  Handle host builds

  If TARGET_ARCH isn't defined, fallback to MACHINE_ARCH.

  This is a followup to r324873.

  PR:		222925

Changes:
  projects/runtime-coverage/share/mk/sys.mk
Comment 5 commit-hook freebsd_committer 2017-11-05 07:36:37 UTC
A commit references this bug:

Author: ngie
Date: Sun Nov  5 07:36:12 UTC 2017
New revision: 325427
URL: https://svnweb.freebsd.org/changeset/base/325427

Log:
  Define CRTARCH to armhf when TARGET/TARGET_ARCH are set to arm/armv[67]

  TARGET_ABI/TARGET_CPU in Makefile.inc1 sets the ABI to gnueabihf, which affects
  the clang lookup path per getArchNameForCompilerRTLib(..) in
  contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp .

  This is a follow up to r324873.

  PR:		222925

Changes:
  projects/runtime-coverage/lib/libclang_rt/Makefile.inc
Comment 6 commit-hook freebsd_committer 2017-11-05 07:48:49 UTC
A commit references this bug:

Author: ngie
Date: Sun Nov  5 07:48:41 UTC 2017
New revision: 325428
URL: https://svnweb.freebsd.org/changeset/base/325428

Log:
  Simplify r325427

  CROSSENV (in Makefile.inc1) sets CPUTYPE/MACHINE(_ARCH)? to the
  TARGET*-relevant values when building the `libraries` target.

  PR:	222925

Changes:
  projects/runtime-coverage/lib/libclang_rt/Makefile.inc
Comment 7 commit-hook freebsd_committer 2017-11-05 19:39:21 UTC
A commit references this bug:

Author: ngie
Date: Sun Nov  5 19:38:51 UTC 2017
New revision: 325443
URL: https://svnweb.freebsd.org/changeset/base/325443

Log:
  Fix paths for cross-built versions of lib/libclang_rt and hardfloat arm variants

  - Define TARGET_CPUARCH and use in libclang_rt as the basis for CRTARCH

    When cross-compiling, the wrong architecture was being embedded in the
    libclang_rt binary filenames. It should be based on TARGET_ARCH (target), not
    MACHINE_ARCH (host).

    If TARGET_ARCH isn't defined (host-builds), fallback to MACHINE_ARCH.

  - Define CRTARCH to armhf when TARGET/TARGET_ARCH are set to arm/armv[67]

    TARGET_ABI/TARGET_CPU in Makefile.inc1 sets the ABI to gnueabihf, which
    affects the clang lookup path per `getArchNameForCompilerRTLib(..)` in
    contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp, so chase clang and
    Linux's assumed naming convention for hard-float arm architectures.

    CROSSENV (in Makefile.inc1) sets CPUTYPE/MACHINE(_ARCH)? to the
    TARGET*-relevant values when building the `libraries` target, so test
    those variables instead.

  - Add OLD_FILES/OLD_LIBS entries for TARGET/TARGET_ARCH == arm/armv[67]. This
    impacts only arm/armv6 and arm/armv7.

  PR:	222925

Changes:
_U  head/
  head/ObsoleteFiles.inc
  head/lib/libclang_rt/Makefile.inc
  head/share/mk/sys.mk
Comment 8 commit-hook freebsd_committer 2017-11-05 20:01:41 UTC
A commit references this bug:

Author: ngie
Date: Sun Nov  5 20:01:00 UTC 2017
New revision: 325446
URL: https://svnweb.freebsd.org/changeset/base/325446

Log:
  Revert r325443

  Despite the fact that it's a working solution, it doesn't follow the design
  philosophy of only doing TARGET_* in Makefile.inc1 and special locations in
  the source tree.

  PR:		222925
  Requested by:	imp

Changes:
_U  head/
  head/ObsoleteFiles.inc
  head/lib/libclang_rt/Makefile.inc
  head/share/mk/sys.mk
Comment 9 Enji Cooper freebsd_committer 2017-11-05 20:02:32 UTC
Giving bug to dim. I don't want to work on this project anymore.
Comment 10 commit-hook freebsd_committer 2017-11-05 20:39:13 UTC
A commit references this bug:

Author: ngie
Date: Sun Nov  5 20:38:40 UTC 2017
New revision: 325449
URL: https://svnweb.freebsd.org/changeset/base/325449

Log:
  Choose a simpler, more philosophically correct version for CRTARCH with armv[67]

  This is a rework of r325443.

  PR:		222925
  Tested with:	make buildenv with appropriate TARGET/TARGET_ARCH pairs

Changes:
  head/ObsoleteFiles.inc
  head/lib/libclang_rt/Makefile.inc