Skip to content

Flang fails to build when a non-host LLVM_DEFAULT_TARGET_TRIPLE is provided #102667

Open
@jonathonpenix

Description

@jonathonpenix

After 2f8b64d / #95388 builds including flang seem to fail if a non-host LLVM_DEFAULT_TARGET_TRIPLE triple is provided.

For example, building llvm at cb5ec37 using the following cmake invocation (on an x64 Linux machine) fails with errors for me:

$ cmake -G Ninja -DLLVM_ENABLE_PROJECTS="clang;lld;mlir;flang;openmp" -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabi -DCMAKE_INSTALL_PREFIX=$PWD/../install -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=0n ../llvm-project/llvm

The errors I see are as follows:

[7829/7904] Generating ../../../../include/flang/iso_fortran_env_impl.mod, iso_fortran_env_impl.o
FAILED: cd /path/to/build/tools/flang/tools/f18 && /path/to/cmake/3.23.1/bin/cmake -E make_directory /path/to/build/include/flang && /path/to/build/bin/flang-new -cpp -c -o /path/to/build/tools/flang/tools/f18/iso_fortran_env_impl.o -module-dir /path/to/build/include/flang /path/to/llvm-project/flang/module/iso_fortran_env_impl.f90
error: /path/to/llvm-project/flang/lib/Optimizer/CodeGen/Target.cpp:1114: not yet implemented: target not implemented
LLVM ERROR: aborting

The specific error is presumably due to 32bit arm not being a supported target in Flang, but it seems like the larger issue is inconsistent targets being used--even supported targets (expectedly, I think) have problems. Ex: on an arm64 MacOS machine with the default target triple set to riscv64, libFortranRuntime.a fails to link with the below error:

error: /Library/Developer/CommandLineTools/usr/bin/libtool: file: tools/flang/tools/f18/iso_fortran_env_impl.o is not an object file (not allowed in a library)

file shows tools/flang/tools/f18/iso_fortran_env_impl.o is a ELF 64bit RISC-V object file versus the rest which are Mach-O arm64 objects.

Presumably a consistent --target (or equivalent) should be enforced when building iso_fortran_env_impl.o (and the runtime more generally) but I'm not sure if this is an expected/supported use case at the moment or how best to handle this offhand given that the current runtime build setup seems to be intended as a temporary measure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    build-problemflangFlang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions