llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[flang]How to cross compile with Flang-new

Open ChunyuLiao opened this issue 2 years ago • 4 comments

cat hello.f90

program hello
  ! This is a comment line; it is ignored by the compiler
  print *, 'Hello, World!'
end program hello

I try to cross compile hello-world with Flang-new:

flang-new  --target=riscv64-unknown-linux-gnu -march=rv64gc --sysroot=/riscv/sysroot --gcc-toolchain=/riscv/ -O3 hello.f90

error: flang-new: error: unknown argument: '--gcc-toolchain=riscv'

as we know cross compile hello-world with clang: eg: clang --target=riscv64-unknown-linux-gnu -march=rv64gc --sysroot=/riscv/sysroot --gcc-toolchain=/riscv/ -O3 hello.c -o a.out

how to config --gcc-toolchain for Flang-new

lllvm commit id:

commit 5a45d32b5b42dc4ed4852b0045391a1c2be41b48 (HEAD -> main, origin/main, origin/HEAD)
Author: Greg Clayton <[email protected]>
Date:   Tue Feb 20 18:17:01 2024 -0800

ChunyuLiao avatar Feb 21 '24 14:02 ChunyuLiao

@llvm/issue-subscribers-flang-driver

Author: Liao Chunyu (ChunyuLiao)

cat hello.f90 ``` program hello ! This is a comment line; it is ignored by the compiler print *, 'Hello, World!' end program hello ``` I try to cross compile hello-world with Flang-new: ``` flang-new --target=riscv64-unknown-linux-gnu -march=rv64gc --sysroot=/riscv/sysroot --gcc-toolchain=/riscv/ -O3 hello.f90 ```

error: flang-new: error: unknown argument: '--gcc-toolchain=riscv'

as we know cross compile hello-world with clang: eg: clang --target=riscv64-unknown-linux-gnu -march=rv64gc --sysroot=/home/chunyu/flang/riscv/sysroot --gcc-toolchain=/home/chunyu/flang/riscv/ -O3 hello.c -o a.out

how to config --gcc-toolchain for Flang-new

lllvm commit id:

commit 5a45d32b5b42dc4ed4852b0045391a1c2be41b48 (HEAD -&gt; main, origin/main, origin/HEAD)
Author: Greg Clayton &lt;gclayton@<!-- -->fb.com&gt;
Date:   Tue Feb 20 18:17:01 2024 -0800

llvmbot avatar Feb 21 '24 14:02 llvmbot

Thanks for reporting this!

Many options supported by Clang are not yet available in Flang. That’s what this error means:

error: flang-new: error: unknown argument: '--gcc-toolchain=riscv'

It should be quite straightforward to enable this, but sometimes the finer details are tricky.

banach-space avatar Feb 21 '24 23:02 banach-space

Thanks for reporting this!

Many options supported by Clang are not yet available in Flang. That’s what this error means:

error: flang-new: error: unknown argument: '--gcc-toolchain=riscv'

It should be quite straightforward to enable this, but sometimes the finer details are tricky.

thanks, I will try to use a native compile.

ChunyuLiao avatar Feb 22 '24 00:02 ChunyuLiao

--gcc-toolchain (& --gcc-install-dir) now supported with https://github.com/llvm/llvm-project/pull/87360

dpalermo avatar Apr 07 '24 03:04 dpalermo