Bug 228205

Summary: [PATCH] lang/gcc6: fail to build with -mretpoline
Product: Ports & Packages Reporter: rozhuk.im
Component: Individual Port(s)Assignee: Gerald Pfeifer <gerald>
Status: Closed FIXED    
Severity: Affects Only Me CC: rozhuk.im
Priority: --- Flags: gerald: maintainer-feedback-
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch: strip -mretpoline option none

Description rozhuk.im 2018-05-12 21:12:48 UTC
Created attachment 193342 [details]
patch: strip -mretpoline option

/etc/make.conf:
# Retpoline speculative execution vulnerability mitigation (CVE-2017-5715)
CFLAGS+=-mretpoline
CXXFLAGS+=-mretpoline
COPTFLAGS+=-mretpoline


...
checking for x86_64-portbld-freebsd11.2-gcc... /tmp/ports/usr/ports/lang/gcc6/work/.build/./gcc/xgcc -B/tmp/ports/usr/ports/lang/gcc6/work/.build/./gcc/ -B/usr/local/x86_64-portbld-freebsd11.2/bin/ -B/usr/local/x86_64-portbld-freebsd11.2/lib/ -isystem /usr/local/x86_64-portbld-freebsd11.2/include -isystem /usr/local/x86_64-portbld-freebsd11.2/sys-include   
checking for suffix of object files... configure: error: in `/tmp/ports/usr/ports/lang/gcc6/work/.build/x86_64-portbld-freebsd11.2/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
gmake[4]: *** [Makefile:14944: configure-stage1-target-libgcc] Error 1
gmake[4]: Leaving directory '/tmp/ports/usr/ports/lang/gcc6/work/.build'
gmake[3]: *** [Makefile:21516: stage1-bubble] Error 2
gmake[3]: Leaving directory '/tmp/ports/usr/ports/lang/gcc6/work/.build'
gmake[2]: *** [Makefile:21848: bootstrap-lean] Error 2
gmake[2]: Leaving directory '/tmp/ports/usr/ports/lang/gcc6/work/.build'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/lang/gcc6
Comment 1 Gerald Pfeifer freebsd_committer 2018-05-12 22:11:31 UTC
My first reaction was "Well, then don't build an old port with new
options (designed for clang I assume", but that wouldn't be super
helpful.

Still, I recommend you switch to GCC 7, and you can do so simply
adjusting Mk/bsd.default-versions.mk which should work for nearly
everything.


And thank you for the patch, that was very helpful!

Do you see any drawbacks if I use 

  +CFLAGS:=	${CFLAGS:N-mretpoline}
  +CXXFLAGS:=	${CXXFLAGS:N-mretpoline}

instead (i.e, Npattern instead of S/^pattern$//)?
Comment 2 rozhuk.im 2018-05-12 22:30:27 UTC
gcc6 required as sub dep for numpy, it is for work.
gcc7 requires this patch too.

> CFLAGS:=	${CFLAGS:N-mretpoline}
- ok, I found it some where in sys/ports mk files.
Comment 3 commit-hook freebsd_committer 2018-05-13 12:18:57 UTC
A commit references this bug:

Author: gerald
Date: Sun May 13 12:17:59 UTC 2018
New revision: 469788
URL: https://svnweb.freebsd.org/changeset/ports/469788

Log:
  Filter the -mretpoline command-line option, which is understood by
  recent versions of clang (and used in the context of the Spectre
  security issues), but not GCC (which uses different options for the
  same) from CFLAGS and CXXFLAGS.

  This avoids the build of this port via bootstrap, which is the default
  and leverages both the system compiler (clang in most cases) plus a just
  built version GCC, to fail due to the latter not knowing -mretpoline.

  PR:		228205
  Submitted by:	rozhuk.im@gmail.com

Changes:
  head/lang/gcc6/Makefile
Comment 4 commit-hook freebsd_committer 2018-05-28 09:04:52 UTC
A commit references this bug:

Author: gerald
Date: Mon May 28 09:04:30 UTC 2018
New revision: 471032
URL: https://svnweb.freebsd.org/changeset/ports/471032

Log:
  Forward port r469788 from lang/gcc6:

    Filter the -mretpoline command-line option, which is understood by
    recent versions of clang (and used in the context of the Spectre
    security issues), but not GCC (which uses different options for the
    same) from CFLAGS and CXXFLAGS.

    This avoids the build of this port via bootstrap, which is the default
    and leverages both the system compiler (clang in most cases) plus a just
    built version GCC, to fail due to the latter not knowing -mretpoline.

  PR:		228205
  Submitted by:	rozhuk.im@gmail.com

Changes:
  head/lang/gcc7/Makefile
Comment 5 commit-hook freebsd_committer 2018-07-22 12:29:56 UTC
A commit references this bug:

Author: gerald
Date: Sun Jul 22 12:29:08 UTC 2018
New revision: 475105
URL: https://svnweb.freebsd.org/changeset/ports/475105

Log:
  Forward port r469788 from lang/gcc6:

    Filter the -mretpoline command-line option, which is understood by
    recent versions of clang (and used in the context of the Spectre
    security issues), but not GCC (which uses different options for the
    same) from CFLAGS and CXXFLAGS.

    This avoids the build of this port via bootstrap, which is the default
    and leverages both the system compiler (clang in most cases) plus a just
    built version GCC, to fail due to the latter not knowing -mretpoline.

  PR:		228205
  Submitted by:	rozhuk.im@gmail.com

Changes:
  head/lang/gcc8/Makefile
Comment 6 Gerald Pfeifer freebsd_committer 2018-07-29 10:10:31 UTC
Now that I forward ported this to lang/gcc7 (soon to become the new
default version of GCC in the ports tree) and lang/gcc8 we can close
this.
Comment 7 commit-hook freebsd_committer 2019-01-11 19:27:23 UTC
A commit references this bug:

Author: gerald
Date: Fri Jan 11 19:26:42 UTC 2019
New revision: 489990
URL: https://svnweb.freebsd.org/changeset/ports/489990

Log:
  Update to the 20180104 snapshot of GCC 8.2.1.

  Forward port r469788 from lang/gcc6 = backport r475105 from lang/gcc8:

    Filter the -mretpoline command-line option, which is understood by
    recent versions of clang (and used in the context of the Spectre
    security issues), but not GCC (which uses different options for the
    same) from CFLAGS and CXXFLAGS.

    This avoids the build of this port via bootstrap, which is the default
    and leverages both the system compiler (clang in most cases) plus a just
    built version GCC, to fail due to the latter not knowing -mretpoline.

  PR:		228205
  Submitted by:	rozhuk.im@gmail.com

Changes:
  head/lang/gcc8-devel/Makefile
  head/lang/gcc8-devel/distinfo
Comment 8 commit-hook freebsd_committer 2019-03-11 12:12:42 UTC
A commit references this bug:

Author: gerald
Date: Mon Mar 11 12:11:41 UTC 2019
New revision: 495351
URL: https://svnweb.freebsd.org/changeset/ports/495351

Log:
  Update to the 20180310 snapshot of GCC 9.0.1.

  Forward port r469788 from lang/gcc6 since apparently people are still using
  the -mretpoline option that is specific to clang, and gcc9-devel is going
  to branch into gcc9 in a rew months and that one later the default version
  of GCC in use:

    Filter the -mretpoline command-line option, which is understood by
    recent versions of clang (and used in the context of the Spectre
    security issues), but not GCC (which uses different options for the
    same) from CFLAGS and CXXFLAGS.

    This avoids the build of this port via bootstrap, which is the default
    and leverages both the system compiler (clang in most cases) plus a just
    built version GCC, to fail due to the latter not knowing -mretpoline.

  PR:		228205
  Submitted by:	rozhuk.im@gmail.com

Changes:
  head/lang/gcc9-devel/Makefile
  head/lang/gcc9-devel/distinfo