<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57670>57670</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang-new] library path must be manually specified
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ggouaillardet
      </td>
    </tr>
</table>

<pre>
    I downloaded the `llvm-project-15.0.0.src.tar.xz` tarball, and built it (on aarch64 - RHEL 8.5) with
```
cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_ENABLE_PROJECTS='clang;flang;lld;openmp' -DLLVM_ENABLE_RUNTIMES='libunwind;libcxx;libcxxabi' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/llvm-15.0.0 ../llvm
```

linking a trivial Fortran program fails because `flang-new` does not look for the Fortran runtime into the `<prefix>/lib` directory:

```
$ cat foo.f90 
program foo
end
$ flang-new foo.f90
/opt/binutils-2.38/bin/ld: cannot find -lFortran_main: No such file or directory
/opt/binutils-2.38/bin/ld: cannot find -lFortranRuntime: No such file or directory
/opt/binutils-2.38/bin/ld: cannot find -lFortranDecimal: No such file or directory
flang-new: error: linker command failed with exit code 1 (use -v to see invocation)
```

A workaround is to manually pass `-L<prefix>/lib` to `flang-new`:
```
$ flang-new foo.f90 -L/opt/llvm-15.0.0/lib
$
```
(or to add `/opt/llvm-15.0.0/lib` to the `LIBRARY_PATH` environment variable)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VNtu2zgQ_Rr5ZWBBl0iyH_Qg2wrqVkkD112kTwYl0TIbijRIyk7263coyfE2TYsFFoUJmeTczsycYSnrl3QNtTwLLklNazAHCk7scX5qp0clv9PKTP3I9fCnVeUaotznv1EBcFcSzp1gCUTUUHaMG2AGnGAmBRCiqkN8A1PY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