Bug 220313 - Uses/fortran.mk: Support fortran:flang argument to use devel/flang instead of gfortran
Summary: Uses/fortran.mk: Support fortran:flang argument to use devel/flang instead of...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords: feature, needs-qa
Depends on:
Blocks:
 
Reported: 2017-06-27 18:37 UTC by Yuri Victorovich
Modified: 2017-10-24 19:16 UTC (History)
11 users (show)

See Also:


Attachments
patch (937 bytes, patch)
2017-06-27 18:37 UTC, Yuri Victorovich
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2017-06-27 18:37:45 UTC
Created attachment 183857 [details]
patch

This can potentially lift the limitation that fortran programs can't be mixed with clang-compiled C++ due to the libgcc_s.so conflict. Base libgcc_s.so and libgcc_s.so from gcc port are in conflict.

Kept gcc a default.

Tested with math/R. math/R builds and seems to work fine with flang.

I will create the bug report with the patch to math/R soon.
Comment 1 Yuri Victorovich freebsd_committer freebsd_triage 2017-06-29 17:25:48 UTC
This patch made the RStudio (IDE for R) possible: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=220359
Comment 2 Diane Bruce freebsd_committer freebsd_triage 2017-06-29 22:14:28 UTC
It looks fine to me.
Comment 3 Joseph Mingrone freebsd_committer freebsd_triage 2017-07-04 17:10:57 UTC
A member of portmgr opined that it is premature to add flang support here since flang is currently only supported on amd64.
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2017-07-05 11:07:43 UTC
(In reply to Joseph Mingrone from comment #3)

Presumably the feature/support could be limited to be used with/scoped to amd64

@Yuri, if bug 220359 depends on this issue, please add it to the Blocks field here.

Mk/Uses/fortran.mk is maintained by fortran@FreeBSD.org but an account with that email does not exist within Bugzilla, so cannot be made assignee or added to flags for feedback. Bugmeister can take care of this on request. 

Therefore, assign to freebsd-ports-bugs as portmgr has indicated recently (Mk/* except for a few files do not require their approval). portmgr@ remain CC'd.

@Diane, do you know who could provide feedback and/or approve this change 'with hat fortran@' ?

I see a mailing list post [1] from 2013 mentioning:

"3. There are several developers/committers with Fortran "expertise, e.g. bf@, gerald@, maho@,"

CC those users accordingly.
Comment 5 Diane Bruce freebsd_committer freebsd_triage 2017-07-05 12:35:09 UTC
This https://reviews.freebsd.org/D11482 has just been added. I'm looking at this now as well. I'll note that this also only covers amd64.

I see absolutely no harm in adding flang support at this time even if it only covers amd64 since the more testing and bug fixing we can get the better IMO.

But really this is now up to the @fortran @toolchain groups.

I just want my pony.
Comment 6 Tijl Coosemans freebsd_committer freebsd_triage 2017-07-05 14:49:30 UTC
If it's not possible to mix flang and gfortran code the choice of Fortran compiler should be system-wide and controlled by the user, not individual ports.  Users should be able to add fortran=gcc or fortran=flang to DEFAULT_VERSIONS in /etc/make.conf.  USES=fortran should then set the Fortran compiler based on that and support for USES=fortran:gcc can be removed.
Comment 7 Diane Bruce freebsd_committer freebsd_triage 2017-07-05 15:03:33 UTC
(In reply to Tijl Coosemans from comment #6)
I've noted this possibility to emaste as well. As discussed at last Dev Summit in June it also matters muchly if we continue the path of a faux libgcc or rename it.

If the entire toolchain for orts has to be chosen a priori then we might want to rename our base libgcc to something else entirely.
Comment 8 Yuri Victorovich freebsd_committer freebsd_triage 2017-07-05 16:41:59 UTC
Many potential fortran ports aren't even possible with the current gfortran. So the option USES=fortran is generally broken anyways.

fortran:flang can be committed as an experimental option, with a corresponding message. It makes it easier to test flang. Some package combinations can directly benefit. For example, R with fortran:flang makes RStudio possible with flang. R isn't currently linked to by anything else.

Also please see the upstream requests:
* https://github.com/flang-compiler/flang/issues/123
* https://github.com/flang-compiler/flang/issues/122
Comment 9 Ed Maste freebsd_committer freebsd_triage 2017-07-05 16:54:45 UTC
> Presumably the feature/support could be limited to be used with/scoped to amd64

It's conceivable we could make the default flang on amd64 and gfortran on i386, similarly to how we've transitioned base system toolchain components on a per-arch basis as they become usable. That's a decision for portmgr and fortran folks; I just want to point out that there is a precedent for configuration like this.
Comment 10 Gerald Pfeifer freebsd_committer freebsd_triage 2017-09-22 13:26:58 UTC
(In reply to Yuri Victorovich from comment #8)
> Many potential fortran ports aren't even possible with the current
> gfortran. So the option USES=fortran is generally broken anyways.

How that?  Why that?

And does the upgrade of the default to GCC 6 two weeks ago make a
difference?
Comment 11 Yuri Victorovich freebsd_committer freebsd_triage 2017-09-22 14:34:17 UTC
(In reply to Gerald Pfeifer from comment #10)

> How that?  Why that?

Conflicts between libgcc.so versions.

> And does the upgrade of the default to GCC 6 two weeks ago make a
difference?

Very unlikely. All versions of gcc build their own libgcc version.
Comment 12 Joseph Mingrone freebsd_committer freebsd_triage 2017-09-28 13:15:11 UTC
See https://reviews.freebsd.org/D12529  It is essentially the same as the patch attached here, but does an architecture check with the flang argument.
Comment 13 commit-hook freebsd_committer freebsd_triage 2017-10-24 19:13:49 UTC
A commit references this bug:

Author: jrm
Date: Tue Oct 24 19:13:02 UTC 2017
New revision: 452811
URL: https://svnweb.freebsd.org/changeset/ports/452811

Log:
  Mk/Uses/fortran.mk: Add flang as a non-default USES=fortran argument.  Note,
  flang is currently only available for amd64.

  PR:		220313
  Submitted by:	yuri@rawbw.com
  Reviewed by:	db, jmd, mat, swills
  Approved by:	portmgr
  Differential Revision:	https://reviews.freebsd.org/D12529

Changes:
  head/Mk/Uses/fortran.mk
Comment 14 Joseph Mingrone freebsd_committer freebsd_triage 2017-10-24 19:16:12 UTC
Committed. Thanks.