<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello Damian,<br>
<br>
If you intend to use the fir-dev branch. You may find the following instructions helpful. <br>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<p style="color:rgb(32, 31, 30);background-color:rgb(255, 255, 255);font-size:11pt;font-family:Calibri, sans-serif;margin:0px">
<span style="margin:0px;font-size:12pt;color:black">1) You can build Flang on the fir-dev branch by enabling the flang project along with clang, mlir and openmp.<br>
<span style="background-color:rgb(255, 255, 255);display:inline !important">Note: Please change TARGETS_TO_BUILD to your platform (X86, PowerPC). <br>
</span><br>
git clone<span> </span><a href="https://github.com/flang-compiler/f18-llvm-project.git" target="_blank" rel="noopener noreferrer" data-auth="NotApplicable" data-linkindex="0" style="margin:0px">https://github.com/flang-compiler/f18-llvm-project.git</a><br>
cd f18-llvm-project</span></p>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">git checkout fir-dev</span></p>
</div>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">mkdir build</span></p>
</div>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">cd build</span></p>
</div>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS="flang;clang;mlir;openmp" -DLLVM_TARGETS_TO_BUILD=AArch64 -DCMAKE_BUILD_TYPE=Release</span></p>
</div>
<p style="color:rgb(32, 31, 30);background-color:rgb(255, 255, 255);font-size:11pt;font-family:Calibri, sans-serif;margin:0px">
<span style="margin:0px;font-size:12pt;color:black">nice -n 10 ninja<br>
<br>
<br>
2) Currently there is no driver support for end-to-end codegen. You must use two developer tools (bbc and tco) to generate llvm IR and then use clang or gcc to link and generate the executable. Two sample example invocations are given below. A few tests are
 also end-to-end and you may also use those as a reference. (<a href="https://github.com/flang-compiler/f18-llvm-project/blob/fir-dev/flang/test/Lower/end-to-end-always-exec-loopbody.f90" target="_blank" rel="noopener noreferrer" data-auth="NotApplicable" data-linkindex="1" style="margin:0px">https://github.com/flang-compiler/f18-llvm-project/blob/fir-dev/flang/test/Lower/end-to-end-always-exec-loopbody.f90</a>).<br>
<span style="background-color:rgb(255, 255, 255);display:inline !important">Note: Ryuta Suzuki created a script that might help here. (</span><a href="https://flang-compiler.slack.com/archives/C5C58TT32/p1625041964086400?thread_ts=1624955427.084800&cid=C5C58TT32" style="margin:0px;background-color:rgb(255, 255, 255)">https://flang-compiler.slack.com/archives/C5C58TT32/p1625041964086400?thread_ts=1624955427.084800&cid=C5C58TT32</a><span style="background-color:rgb(255, 255, 255);display:inline !important">)</span><br>
<br>
input="fraction.f90"</span></p>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">bbc $input -o - | tco | llc --relocation-model=pic --filetype=obj -o $input.o</span></p>
</div>
<p style="color:rgb(32, 31, 30);background-color:rgb(255, 255, 255);font-size:11pt;font-family:Calibri, sans-serif;margin:0px">
<span style="margin:0px;font-size:12pt;color:black">gcc $input.o -L/…/f18-llvm-project/install/lib -lFortran_main -lFortranRuntime -lFortranDecimal -lm -o $input.out<br>
<br>
./bin/bbc -emit-fir array.f90 -o - | ./bin/tco &> array.ll<br>
./bin/clang++ array.ll -lFortran_main -lFortranRuntime -lFortranDecimal</span></p>
<p style="color:rgb(32, 31, 30);background-color:rgb(255, 255, 255);font-size:11pt;font-family:Calibri, sans-serif;margin:0px">
<span style="margin:0px;font-size:12pt;color:black">LD_LIBRARY_PATH=$HOME/f18-llvm-project/build/lib ./a.out<br>
<br>
<br>
3) It is possible that the linking process might complain about some math symbols. If so, you must download classic flang and place the library libpgmath.so somewhere and point to it in the link step.<br>
<br>
git clone<span> </span><a href="https://github.com/flang-compiler/flang.git" target="_blank" rel="noopener noreferrer" data-auth="NotApplicable" data-linkindex="2" style="margin:0px">https://github.com/flang-compiler/flang.git</a></span></p>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">cd flang/runtime/libpgmath</span></p>
</div>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">mkdir build</span></p>
</div>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">cd build</span></p>
</div>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">cmake ../</span></p>
</div>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">make</span></p>
</div>
<div style="margin:0px;font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif;color:rgb(32, 31, 30);background-color:rgb(255, 255, 255)">
<p style="font-size:11pt;font-family:Calibri, sans-serif;margin:0px"><span style="margin:0px;font-size:12pt;color:black">And then you can find lipgmath.* in the lib directory in build.</span></p>
</div>
<p style="color:rgb(32, 31, 30);background-color:rgb(255, 255, 255);font-size:11pt;font-family:Calibri, sans-serif;margin:0px">
<span style="margin:0px;font-size:12pt;color:black">(There might be an option to build pgmath automatically if you set an environment variable. There might also be an option to use mlir/libm math functions instead of pgmath. But I have not explored these options.)</span></p>
<br>
Thanks,<br>
Kiran</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> flang-dev <flang-dev-bounces@lists.llvm.org> on behalf of Andrzej Warzynski via flang-dev <flang-dev@lists.llvm.org><br>
<b>Sent:</b> 13 July 2021 21:55<br>
<b>To:</b> flang-dev@lists.llvm.org <flang-dev@lists.llvm.org><br>
<b>Subject:</b> Re: [flang-dev] flang test questions</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hi Damian,<br>
<br>
On 13/07/2021 20:06, Damian Rouson via flang-dev wrote:<br>
> Second, I was informed in April that the f18-llvm-project fork's fir-dev <br>
> branch is able to produce executable files from Fortran 77 source.<br>
> Could someone explain how to use this capability and whether this <br>
> capability has been merged upstream to the llvm-project repository?<br>
<br>
Merging this upstream is an ongoing process. I am not active in this <br>
area so can't comment on timescales, but it is one of our main <br>
challenges right now.<br>
<br>
As for compiling with the fir-dev branch on f18-llvm-project, we have <br>
been recently discussing this on flang-compiler.slack.com. Are you <br>
active there? I can send you an invite.<br>
<br>
> Do I need to pass a flag <br>
> to tell flang to produce an executable program without invoking gfortran?<br>
<br>
`flang` that you are referring to is just a bash wrapper script [1] that <br>
was added for experimenting. It will only use LLVM Flang to <br>
parse-unparse the input source, and then will call e.g. `gfortran` for <br>
code-generation. You can replace `gfortran` with some other Fortran <br>
compiler. The name is rather confusing. We should rename it as <br>
`flang-to-gnu` or something similar.<br>
<br>
Welcome aboard! :)<br>
<br>
-Andrzej<br>
<br>
[1] <a href="https://github.com/llvm/llvm-project/blob/main/flang/tools/f18/flang.in">
https://github.com/llvm/llvm-project/blob/main/flang/tools/f18/flang.in</a><br>
_______________________________________________<br>
flang-dev mailing list<br>
flang-dev@lists.llvm.org<br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev</a><br>
</div>
</span></font></div>
</body>
</html>