Skip to content

DOC: pure Fortran fpm build method? #231

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

Closed
scivision opened this issue Nov 7, 2020 · 11 comments
Closed

DOC: pure Fortran fpm build method? #231

scivision opened this issue Nov 7, 2020 · 11 comments

Comments

@scivision
Copy link
Member

scivision commented Nov 7, 2020

Is there / will there be a way to build the pure Fortran + curl fpm itself without needing to install Haskell first? Would this be doable at least via a Makefile or is there generated source for fpm itself?

(I would like to start using fpm across my Fortran projects as it seems Fortran submodules are/will be soon supported. I couldn't use fpm until Fortran submodules are supported.)

@certik
Copy link
Member

certik commented Nov 8, 2020 via email

@awvwgk
Copy link
Member

awvwgk commented Nov 8, 2020

Bootstrapping fpm once with the Haskell version is currently required, but the Fortran fpm implementation should be able to bootstrap itself afterwards. We are working towards a first release and a way to provide binaries as a rolling release (#218).

@certik
Copy link
Member

certik commented Nov 8, 2020

Yes, if you are ok with using an fpm binary as a starting point, then fpm will be able built itself eventually. The issue #123 is for bootstrapping from source from scratch.

@scivision
Copy link
Member Author

If I understand correctly the end goal is to have the capability to build fpm from scratch with a Fortran compiler + CMake (among other methods). This would be great.

@certik
Copy link
Member

certik commented Nov 8, 2020 via email

@urbanjost
Copy link
Contributor

urbanjost commented Nov 9, 2020

Well, since the Fortran version does not have any C dependencies at this point it will actually build as a single Fortran file.
Long story short I wanted a version of #229 on a machine that just had a Fortran compiler and that I could build with the
debugger so I used an old "make" trick:

cd $(basename $0)
cat >gfortran <<\EOF
#!/bin/bash
(
exec 2>&1
/usr/bin/gfortran "$@" 2>&1
) >/dev/null
NAME=$(echo $*|xargs -n 1|grep '\.f90$')
echo ============================================================
echo COMMAND "$@"
echo NAME $NAME
case "$NAME" in
'');;
test/*);;
*)
echo cat $NAME >> catthem
;;
esac
EOF

echo '#!/bin/bash' >catthem
export PATH=`pwd`:$PATH
chmod u+xr gfortran
rm -rfv build
fpm build
mkdir -p _scratch
bash catthem >_scratch/ffpm.f90
(
cd _scratch
gfortran ffpm.f90 -o ../ffpm
)
rm gfortran
rm catthem
mv _scratch/ffpm.f90 .
rm -rf _scratch
exit

If you run that with the bootstrap fpm it makes a file called ffpm.f90 that compiles just fine with a simple gfortran compile.'.
It lets you try other compilers anduse a debugger on the code and other nice things for now. Would not commit to that being a long-term solution but it has been pretty handy lately. Maybe we could place the file out there as a simple way for some people to test the Alpha version without having to commit to much effort. Compile one file. Try it.

@urbanjost
Copy link
Contributor

i changed the use statements to all use the module that defines toml_table as the quickest way to get rid of that Intel compiler message and updated M_CLI2 to use standard-conforming use of : and * in that one line. Wondering if anyone can try the single-file bootstrap version with anything other than gfortran 8.3.1-5 on a Red Hat 8.2
system. Particularly interested in gfortran 10 and non-gfortran compiles.

 wget http://www.urbanjost.altervista.org/REMOVE/ffpm.f90 

and just compile the single file and if it builds the theory is it should be able to bootstrap a pull of the fpm/fpm Fortran directory without having to install anything on a machine except gfortran and git.

@awvwgk
Copy link
Member

awvwgk commented Nov 21, 2020

@urbanjost I did a bit of testing with all my available compiler toolchains on three different machines (Manjaro, RedHat, OpenSuse).

GCC works nicely for me, tested 7.5, 8.4, 9.2, 10.1 and 10.2 so far. Intel is the same, compiles with 18.0, 19.0 and 19.1, but the resulting binary might be non-functional.

PGI doesn't work since toml-f cannot be compiled due to a bug in 20.7 and 20.9 of the NVHPC compilers (see toml-f/toml-f#25). Also M_CLI2 triggers some PGI bugs, see urbanjost/M_CLI2#2.

NAG fails on a logical formatter in M_CLI2 (see urbanjost/M_CLI2#1), but toml-f seems to be fine.

@scivision
Copy link
Member Author

I took a try at this. To make fpm build purely from CMake, I would need to add FetchContent (CMake feature) to retrieve and build toml-f and M_CLI2. The goal of this is to partially address #123 by making fpm build from nothing more than CMake and Fortran compiler, without needing bootstrap fpm. Would this be useful?

@awvwgk
Copy link
Member

awvwgk commented Nov 22, 2020

@scivision I'm sometimes building fpm with meson myself. So I'm certainly not against adding another build system (cmake/meson/...) to this repository as it makes some tasks way easier.

From #123 I suspect that a fpm dist --cmake command was intended for this purpose to generate a source distribution with additional CMake files. Until we are actually able to do this, another build system might be a suitable choice as well.

FetchContent seems to be the easiest way to get the dependencies with CMake, I'm using something similar right now for toml-f.

@LKedward
Copy link
Member

Regarding the original query of building fpm without Haskell, this is now possible using a generated single-source for bootstrapping (see the bootstrapping instructions here) and so I will close this issue. For discussion of standalone tarballs etc. see #123.

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

No branches or pull requests

5 participants