Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configury: patch configure to support nvfortran #12722

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ggouaillardet
Copy link
Contributor

nvfortran needs to be passed -fPIC when building shared libraries, so patch the generated configure script in order to properly handle nvfortran:

  • add nvfortran to the list of known fortran compilers
  • pass -fPIC to the compiler

Refs. #8919

nvfortran needs to be passed -fPIC when building shared libraries,
so patch the generated configure script in order to properly
handle nvfortran:
- add nvfortran to the list of known fortran compilers
- pass -fPIC to the compiler

Refs. open-mpi#8919

Signed-off-by: Gilles Gouaillardet <[email protected]>
@ggouaillardet
Copy link
Contributor Author

@cparrott73 can you please give it a try?

you should now be able to use nvfortran without having to manually pass FCFLAGS=-fPIC to configure.
Once you apply the patch, you will have to run ./autogen.pl (or ./autogen.pl --force if you apply the patch on an official tarball.

@cparrott73
Copy link

@ggouaillardet - I tried the patch with nvfortran here, but ./configure is still not passing -fPIC by default for me here.

Here is what I did:

  • Clone ompi from git via git clone --recursive https://github.com/open-mpi/ompi.git
  • Downloaded the above patch to a raw .diff file
  • cd ompi then patch -p1 < fpic_fix.diff
  • ./autogen.pl --force
  • mkdir build && cd build
  • ../configure CC=nvc FC=nvfortran CXX=nvc++

Did I not do something right here?

The system in question is a Supermicro H11DSU-iN AMD EPYC 7452 system running Rocky Linux 8.10. The following relevant packages are installed:

cparrott@rome5 /scratch/cparrott/ompi_fpic_test/ompi/build $ rpm -qa | grep autoconf
autoconf-2.69-29.el8.noarch
cparrott@rome5 /scratch/cparrott/ompi_fpic_test/ompi/build $ rpm -qa | grep automake
automake-1.16.1-8.el8.noarch

Let me know if I need to tweak something here.

@ggouaillardet
Copy link
Contributor Author

That sounds right, I also use auto tools provided by RHEL8 so the patch should be applied correctly.
Can you please compress and upload configure, config.log and libtool so I can have a look?

@cparrott73
Copy link

@ggouaillardet - I tried this again while ago. I think my previous patch file from above may have gotten corrupted somehow. I pulled a new copy of the source tree from git, and then a new copy of the patch from above, and applied it, then ran ./configure and make. Everything worked as expected this time.

Interestingly, I also tried this on our older CentOS 7 build system (due to be retired soon). The change did not work as expected there. I'm wondering if this could be due to bugs/issues with autoconf and automake on that particular OS?

I also made a version of this patch for openmpi-4.1.5 by stripping out the first hunk, where the patch fails because of substantial changes in the copyright text since that version. This also worked okay for me on our Rocky 8 system.

All in all, I think we're good to go, and this experience has been educational to me - particularly with some of the shortcomings of CentOS 7.

@bosilca
Copy link
Member

bosilca commented Aug 1, 2024

I confirm it works on Rocky 9.4 as well both x86 and aarch64.

@ggouaillardet
Copy link
Contributor Author

@cparrott73 since we try to patch the generated configure and silently fail if the patch does not apply, the libtool.m4 used to generate configure must have the same bits than the one used to generate the patch.
I generated it from a RHEL8 like box. If you want to use CentOS7, I suggest you manually apply the commit, autogen.pl and then make dist on a RHEL8 box, and then build from the tarball on CentOS7.

ggouaillardet referenced this pull request Aug 2, 2024
Refactor SVE functions and incidentally make NVIDIA compilers
a happy panda again.

Signed-off-by: Gilles Gouaillardet <[email protected]>
Copy link
Member

@jsquyres jsquyres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than my (optional) small suggestion, @cparrott73 confirmed that it works and @bosilca also gave a 👍. Let's move this out of draft and get it merged.

Comment on lines +1097 to +1108
$replace_string = "nvfortran*)
# NVIDIA Fortran compiler
lt_prog_compiler_wl${tag}='-Wl,'
lt_prog_compiler_pic${tag}='-fPIC'
lt_prog_compiler_static${tag}='-Bstatic'
;;
tcc*)
# Fabrice Bellard et al's Tiny C Compiler
lt_prog_compiler_wl='-Wl,'
lt_prog_compiler_pic='-fPIC'
lt_prog_compiler_static='-static'
;;";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion for the $replace_string:

$replace_string = "$search_string
    nvfortran*)
	# NVIDIA Fortran compiler
	lt_prog_compiler_wl${tag}='-Wl,'
	lt_prog_compiler_pic${tag}='-fPIC'
	lt_prog_compiler_static${tag}='-Bstatic'
	;;";

That way you don't have to replicate the tcc*) block twice.

@janjust
Copy link
Contributor

janjust commented Aug 15, 2024

@ggouaillardet @jsquyres can we get this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants