Bug 246540

Summary: /usr/bin/as deprecation warning from BZ233611 & r350518 breaks GNU assembler detection in cmake
Product: Base System Reporter: Dave Cottlehuber <dch>
Component: gnuAssignee: Ed Maste <emaste>
Status: Closed FIXED    
Severity: Affects Some People CC: kde
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Dave Cottlehuber freebsd_committer freebsd_triage 2020-05-18 15:23:36 UTC
https://reviews.freebsd.org/D24664 contains an update to databases/foundationdb-devel which now breaks with following cmake warning, at least on 13.0-CURRENT > r3661107. I expect the next pkg.freebsd.org build will fail on this as well.

Checking whether the ASM compiler is GNU using "--version" did not match "(GNU assembler)|(GCC)|(Free Software Foundation)":
FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b)
Target: x86_64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin

presumably after running this:

$ as --version
warning: as 2.17.50 is deprecated in FreeBSD and will be removed
GNU assembler 2.17.50 [FreeBSD] 2007-07-03
Copyright 2007 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-unknown-freebsd'.

devel/cmake (v3.17.2) includes:

cmake-3.17.2/Modules/CMakeDetermineASMCompiler.cmake
59:  set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_GNU "(GNU assembler)|(GCC)|(Free Software Foundation)")

I'm not clear what the right fix here is, as this is probably not the only port that will break on this.

I've learned about:

- `cmake -D_CMAKE_TOOLCHAIN_PREFIX=llvm-` via https://stackoverflow.com/questions/7031126/switching-between-gcc-and-clang-llvm-using-cmake

which would be fine if this port had an explicit llvm dependency (which it doesn't)

- if /usr/bin/as *appended* its warning to the version, on the same first line, CMakeDetermineASMCompiler.cmake could simply detect that, and we'd have an additional local patch.

as --version
GNU assembler 2.17.50 [FreeBSD] 2007-07-03 warning: as 2.17.50 is deprecated in FreeBSD and will be removed

committed here:

Author: emaste <emaste@FreeBSD.org>
Date:   Thu Aug 1 19:01:27 2019 +0000

    as: add deprecation notice to the man page
    
    In the future FreeBSD will ship without GNU binutils 2.17.50.  Add a
    note advising users who require GNU as to install the binutils port
    or package.
    
    Note that on armv7, arm64, amd64, i386 we currently ship only two
    binutils tools (as and objdump).  A deprecation notice was added to
    objdump's man page some time ago.
    
    PR:             233611
    Discussed with: jhb
    MFC after:      1 week
    Relnotes:       Yes
    Sponsored by:   The FreeBSD Foundation

Notes:
    svn path=/head/; revision=350518
Comment 1 commit-hook freebsd_committer freebsd_triage 2020-05-18 16:07:40 UTC
A commit references this bug:

Author: emaste
Date: Mon May 18 16:07:14 UTC 2020
New revision: 361218
URL: https://svnweb.freebsd.org/changeset/base/361218

Log:
  GNU as: move deprecation message after option parsing

  Some cmake test parses the output of the first line of as --version, and
  emits an error if it does not contain some expected strings:

  Checking whether the ASM compiler is GNU using "--version" did not match
  "(GNU assembler)|(GCC)|(Free Software Foundation)"

  Emit the deprecation message later, after parsing argv and thus --version.

  PR:		246540
  Reported by:	dch
  Sponsored by:	The FreeBSD Foundation

Changes:
  head/contrib/binutils/gas/as.c
Comment 2 Ed Maste freebsd_committer freebsd_triage 2020-05-18 16:24:57 UTC
Note that GNU as will be removed, probably at the end of May (depending on the exp-run in PR 205250) so we'll need to add a binutils dependency to this port, if it actually needs GNU as. Most likely:

BUILD_DEPENDS+= as:devel/binutils
Comment 3 Ed Maste freebsd_committer freebsd_triage 2020-05-19 00:11:58 UTC
dch confirms this addresses the immediate issue