This is an archive of the discontinued LLVM Phabricator instance.

[flang] Get rid of code duplication in wrapper. Fix checking of undefined variables.
ClosedPublic

Authored by ygribov on Jan 20 2022, 2:50 AM.

Diff Detail

Event Timeline

ygribov created this revision.Jan 20 2022, 2:50 AM
Herald added a project: Restricted Project. · View Herald Transcript
ygribov requested review of this revision.Jan 20 2022, 2:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2022, 2:50 AM

I realize that the wrapper may be removed in few months so let me know if this is irrelevant.

Hi @ygribov, thank you for this fix!

I realize that the wrapper may be removed in few months so let me know if this is irrelevant.

While this is "in-tree", all fixes are relevant :) Also, the main goal is to rename flang-new (Flang's compiler driver) as flang and this script as e.g. flang-to-gfortran. I hope that this will happen sooner rather than later - flang is a rather misleading name in this case. This does not mean that this script will be deleted - if people find it useful, then it may remain available as an option (albeit under a different name). Time will tell. I will definitely be in favor of removing it :)

As for your patch, I think that it would make a lot of sense to extract the following into a separate function (e.g. get_external_fc_name or something similar):

local ext_fc=""
if [[ -v FLANG_FC ]]; then
  ext_fc="${FLANG_FC}"
elif [[ -v F18_FC ]]; then
  # We support F18_FC for backwards compatibility.
  ext_fc="${F18_FC}"
else
  ext_fc=gfortran
fi

This way you will reduce code duplication.

ygribov updated this revision to Diff 402893.Jan 25 2022, 6:48 AM
ygribov retitled this revision from [flang] Fix checking of undefined variables in wrapper. to [flang] Get rid of code duplication in wrapper. Fix checking of undefined variables..

Resolve review comments.

As for your patch, I think that it would make a lot of sense to extract the following into a separate function (e.g. get_external_fc_name or something similar):

Thanks, done.

awarzynski accepted this revision.Jan 25 2022, 11:12 AM

LGTM, thank you!

This revision is now accepted and ready to land.Jan 25 2022, 11:12 AM
This revision was landed with ongoing or failed builds.Jan 26 2022, 12:42 AM
This revision was automatically updated to reflect the committed changes.