flang-compiler / flang

Flang is a Fortran language front-end designed for integration with LLVM.
Other
803 stars 137 forks source link

error:expected error #1338

Closed if362005 closed 1 year ago

if362005 commented 1 year ago

When I try to build flang, there is a error expected error which is in runtime/flang/CMakeFiles/flang_static.dir/build.make. More details follow:

/tmp/iso_c_bind-a0d584.ll:10:65: error: expected type %structiso_c_binding_c_funptrtd_ = type < { [8 x i64], [6 x ptr], [28 x i8] } > ^ 1 error generated. make[2]: ** [runtime/flang/CMakeFiles/flang_static.dir/build.make:3517: runtime/flang/CMakeFiles/flang_static.dir/iso_c_bind.F95.o] Error 1 make[2]: Waiting for unfinished jobs.... /tmp/ftnhdr-87fa28.ll:4:25: error: expected type define float @ftncabs(ptr %c) !dbg !16 { ^ 1 error generated. make[2]: [runtime/flang/CMakeFiles/flang_static.dir/build.make:766: runtime/flang/CMakeFiles/flang_static.dir/ftnhdr.F.o] Error 1 /tmp/ieee_features-562ea2.ll:10:75: error: expected type %structieee_features__ieee_features_type__td = type < { [8 x i64], [6 x ptr], [38 x i8] } > ^ 1 error generated. make[2]: [runtime/flang/CMakeFiles/flang_static.dir/build.make:3476: runtime/flang/CMakeFiles/flang_static.dir/ieee_features.F95.o] Error 1 /tmp/omp_lib-58653b.ll:13:28: error: expected type define void @omp_liboss1(ptr %kind, ptr %modifier) !dbg !17 { ^ 1 error generated. make[2]: [runtime/flang/CMakeFiles/flang_static.dir/build.make:1773: runtime/flang/CMakeFiles/flang_static.dir/omp_lib.F95.o] Error 1 make[1]: [CMakeFiles/Makefile2:867: runtime/flang/CMakeFiles/flang_static.dir/all] Error 2 make: * [Makefile:136: all] Error 2

It would be great if someone can check it.

if362005 commented 1 year ago

How can I solve this problem? I do hope I can get your help! @jeffhammond @waldyrious @DavidTruby @junghans

bryanpkc commented 1 year ago

@if362005 Did you use the release_15x branch of https://github.com/flang-compiler/classic-flang-llvm-project, with the master branch of this repository?

if362005 commented 1 year ago

@if362005 Did you use the release_15x branch of https://github.com/flang-compiler/classic-flang-llvm-project, with the master branch of this repository?

Thanks for your reply! Yes,should I use other version?

if362005 commented 1 year ago

@if362005 Did you use the release_15x branch of https://github.com/flang-compiler/classic-flang-llvm-project, with the master branch of this repository?

Should I use release_14x which I find you had recommended?Or the main branch?

I try to use release_14x branch of https://github.com/flang-compiler/classic-flang-llvm-project, and legacy branch of flang , and use the build-llvm-project.sh and build-flang.sh to compile.However , when I change the install_prefix, I can not find flang2. After detecting details, the flang2 has been install to other path. It's so crazy!

if362005 commented 1 year ago

I try again,however, the scripts tries to copy flang2 to /usr/lib instead of install_prefix. It makes me confused! More details fellow: Installing: /usr/lib/llvm-6.0/bin/flang2 CMake Error at tools/flang2/flang2exe/cmake_install.cmake:54 (file): file INSTALL cannot copy file "/home/lxj/flang9.0/flang-legacy/build/flang/bin/flang2" to "/usr/lib/llvm-6.0/bin/flang2": Success. How can I solve this problem?

if362005 commented 1 year ago

I try link flang2, which is in /usr/lib/llvm-6.0/bin/flang2, to my install_prefix. Or copy flang2 to it. However, warning fellows :

warning: overriding the module target triple with x86_64-unknown-linux-gnu [-Woverride-module] 1 warning generated.

And flang , which is in my install_prefix, links to clang-14。More details fellow: flang -> clang-14

kiranchandramohan commented 1 year ago

I think the issues you are facing are due to not specifying an INSTALL_PREFIX where you have permissions. Installing in directories like /usr/lib requires system-level permission or sudo access. So you can either change INSTALL_PREFIX to somewhere like /home/lxj/flang_install or invoke the script with sudo.

And flang , which is in my install_prefix, links to clang-14。More details fellow:
flang -> clang-14

This is expected. flang is a symlink to clang-14, invoking clang-14 as flang causes it to go into FortranMode.

if362005 commented 1 year ago

我认为您面临的问题是由于未指定INSTALL_PREFIX您拥有权限的位置。在类似的目录中安装/usr/lib需要系统级权限或 sudo 访问权限。因此,您可以更改INSTALL_PREFIX为类似的地方/home/lxj/flang_install或使用 调用脚本sudo

And flang , which is in my install_prefix, links to clang-14。More details fellow:
flang -> clang-14

这是意料之中的。flang是一个符号链接clang-14,调用clang-14asflang导致它进入FortranMode

Thanks for your reply!

I have changed the install_prefix which likes /home/lxj/flang9.0/classic-flang-llvm-project-release_14x/build/bin. And flang1 can be installed successfully that is confused me. What is difference between flang1 and flang2.

kiranchandramohan commented 1 year ago

See Slides 9, 10 of the following presentation. https://llvm-hpc4-workshop.github.io/slides/Osmialowski.pdf

if362005 commented 1 year ago

See Slides 9, 10 of the following presentation. https://llvm-hpc4-workshop.github.io/slides/Osmialowski.pdf

I mean, they have different functions, but why would they install to different paths? Their install_prefix is same.

kiranchandramohan commented 1 year ago

They should not be installing to different paths. I don't know why that happens for you. May be there are some stale environment variables. Can you try a fresh install? Also inspect the install_prefix or install_path in the build directory of flang.

if362005 commented 1 year ago

They should not be installing to different paths. I don't know why that happens for you. May be there are some stale environment variables. Can you try a fresh install? Also inspect the install_prefix or install_path in the build directory of flang.

Do you mean to create a new folder and change the install_prefix,.Because I install on the server, I can't change to another device ? I will try. This approach may work. It will take some time. Thanks for your help, I'll comment if I have any question.

if362005 commented 1 year ago

I try link flang2, which is in /usr/lib/llvm-6.0/bin/flang2, to my install_prefix. Or copy flang2 to it. However, warning fellows :

warning: overriding the module target triple with x86_64-unknown-linux-gnu [-Woverride-module] 1 warning generated.

And flang , which is in my install_prefix, links to clang-14。More details fellow: flang -> clang-14

Do you know how to fix the warning ? Thanks again!

if362005 commented 1 year ago

I changed build-llvm-project.sh: TARGET="X86" BUILD_TYPE="Release" INSTALL_PREFIX="/home/lxj/flang/install" NPROC=16 USE_CCACHE="0" DO_INSTALL="0" USE_SUDO="0" C_COMPILER_PATH="/usr/bin/gcc" CXX_COMPILER_PATH="/usr/bin/g++" LLVM_ENABLE_PROJECTS="clang;openmp" EXTRA_CMAKE_OPTS="" VERBOSE="" I hope it will be installed to my install_prefix. However, it is installed to other. Make install again, it's right. But flang is still unsolved.

bryanpkc commented 1 year ago

I changed build-llvm-project.sh:

After changing the script, how did you invoke it? Did you run it at the root of the clone? Can you paste the full command line, and attach build/CMakeCache.txt if possible?

if362005 commented 1 year ago

I changed build-llvm-project.sh:

After changing the script, how did you invoke it? Did you run it at the root of the clone? Can you paste the full command line, and attach build/CMakeCache.txt if possible?

Thanks for your reply! For the script,I use the fellow command: . build-llvm-preject.sh And this is same as build-flang-legacy. I run it at the root of the files. In the build/CMakeCache.txt, I find this: //Install path prefix, prepended onto install directories. CMAKE_INSTALL_PREFIX:PATH=/home/lxj/flang/install

if362005 commented 1 year ago

This is my script:

**#!/bin/bash

Initialize our own variables: TARGET="X86" BUILD_TYPE="Release" INSTALL_PREFIX="/home/lxj/flang/install" NPROC=16 USE_CCACHE="0" DO_INSTALL="0" USE_SUDO="0" C_COMPILER_PATH="/usr/bin/gcc" CXX_COMPILER_PATH="/usr/bin/g++" LLVM_ENABLE_PROJECTS="clang;openmp" EXTRA_CMAKE_OPTS="" VERBOSE=""

set -e # Exit script on first error. **

if362005 commented 1 year ago

When I run build-flang.sh via source build-flang.sh,file INSTALL tries to copy flang2 to another while flang1 is installed correctly. More details fellow: -- Installing: /home/lxj/flang/install/lib/libflangmain.a -- Installing: /home/lxj/flang/install/bin/flang1 -- Installing: /usr/lib/llvm-6.0/bin/flang2 CMake Error at tools/flang2/flang2exe/cmake_install.cmake:54 (file): file INSTALL cannot copy file "/home/lxj/flang/flang-legacy/build/flang/bin/flang2" to "/usr/lib/llvm-6.0/bin/flang2": Success. Call Stack (most recent call first): tools/flang2/cmake_install.cmake:49 (include) tools/cmake_install.cmake:49 (include) cmake_install.cmake:58 (include)

bryanpkc commented 1 year ago

What does line 54 in build/tools/flang2/flang2exe/cmake_install.cmake look like?

Mine looks like this (starting at line 45):

if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
  list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
   "/home/bryanpkc/src/install.release_15x/bin/flang2")
  if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
    message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
  endif()
  if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
    message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
  endif()
file(INSTALL DESTINATION "/home/bryanpkc/src/install.release_15x/bin" TYPE EXECUTABLE FILES "/home/b00375952/src/build.release_15x/flang/bin/flang2")
  if(EXISTS "$ENV{DESTDIR}/home/bryanpkc/src/install.release_15x/bin/flang2" AND
     NOT IS_SYMLINK "$ENV{DESTDIR}/home/bryanpkc/src/install.release_15x/bin/flang2")
    if(CMAKE_INSTALL_DO_STRIP)
      execute_process(COMMAND "/usr/bin/strip" "$ENV{DESTDIR}/home/bryanpkc/src/install.release_15x/bin/flang2")
    endif()
  endif()
endif()

I don't know why your CMake tries to install flang1 and flang2 in two different locations. I have never seen that myself.

bryanpkc commented 1 year ago

Oh I know why. Try this:

cd classic-flang-llvm-project
./build-llvm-project.sh ... -p $INSTALL_DIR
export PATH=$INSTALL_DIR/bin:$PATH
cd ../flang
./build-flang.sh ... -p $INSTALL_DIR

Your problem is that CMake found /usr/bin/llvm-config instead of $INSTALL_DIR/bin/llvm-config, so it tries to write some files to /usr/lib/llvm-6.0 during installation.

if362005 commented 1 year ago

第 54 行是build/tools/flang2/flang2exe/cmake_install.cmake什么样的?

我的看起来像这样(从第 45 行开始):

if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
  list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
   "/home/bryanpkc/src/install.release_15x/bin/flang2")
  if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
    message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
  endif()
  if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
    message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
  endif()
file(INSTALL DESTINATION "/home/bryanpkc/src/install.release_15x/bin" TYPE EXECUTABLE FILES "/home/b00375952/src/build.release_15x/flang/bin/flang2")
  if(EXISTS "$ENV{DESTDIR}/home/bryanpkc/src/install.release_15x/bin/flang2" AND
     NOT IS_SYMLINK "$ENV{DESTDIR}/home/bryanpkc/src/install.release_15x/bin/flang2")
    if(CMAKE_INSTALL_DO_STRIP)
      execute_process(COMMAND "/usr/bin/strip" "$ENV{DESTDIR}/home/bryanpkc/src/install.release_15x/bin/flang2")
    endif()
  endif()
endif()

我不知道为什么您的 CMake 会尝试在两个不同的位置安装flang1flang2。我自己从未见过。

Unbelievable, it is different, Mine looks like this:

if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT) list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES "/usr/lib/llvm-6.0/bin/flang2") if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION) message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}") endif() if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION) message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}") endif() file(INSTALL DESTINATION "/usr/lib/llvm-6.0/bin" TYPE EXECUTABLE FILES "/home/lxj/flang/flang-legacy/build/flang/bin/flang2") if(EXISTS "$ENV{DESTDIR}/usr/lib/llvm-6.0/bin/flang2" AND NOT IS_SYMLINK "$ENV{DESTDIR}/usr/lib/llvm-6.0/bin/flang2") if(CMAKE_INSTALL_DO_STRIP) execute_process(COMMAND "/home/lxj/flang/install/bin/llvm-strip" "$ENV{DESTDIR}/usr/lib/llvm-6.0/bin/flang2") endif() endif() endif()

if362005 commented 1 year ago
PATH=$INSTALL_DIR/bin:$PATH

I have tried this, but it does not work. Error is same.

bryanpkc commented 1 year ago

You exported the PATH environment variable, instead of just setting it locally, right?

if362005 commented 1 year ago

Yes, when I catch PATH, like this cat: '/home/lxj/flang/install/bin:/home/lxj/flang/install/bin:

bryanpkc commented 1 year ago

Try uninstalling the llvm-6.0 package from your system. All your build problems seem to stem from the fact that build-flang.sh is somehow picking up the system installation of LLVM.

if362005 commented 1 year ago

Try uninstalling the llvm-6.0 package from your system. All your build problems seem to stem from the fact that build-flang.sh is somehow picking up the system installation of LLVM. Can I change the CMAKE_OPTIONS ? I have not the permission。

bryanpkc commented 1 year ago

Can I change the CMAKE_OPTIONS ? I have not the permission。

You can try this patch:

diff --git a/tools/flang2/flang2exe/CMakeLists.txt b/tools/flang2/flang2exe/CMakeLists.txt
index a9649e99..5aeeb048 100644
--- a/tools/flang2/flang2exe/CMakeLists.txt
+++ b/tools/flang2/flang2exe/CMakeLists.txt
@@ -160,7 +160,7 @@ target_include_directories(flang2

 # Install flang2 executable
 install(TARGETS flang2
-        RUNTIME DESTINATION ${LLVM_TOOLS_BINARY_DIR})
+        RUNTIME DESTINATION bin)

 # Local Variables:
 # mode: cmake

It may work around the installation issue, but it won't help with the Fortran code compilation failures (expected type errors) you reported in this issue, since I think those are also caused by using an incompatible version of LLVM to compile Flang IR.

Have you read this wiki page? It tells you how to run CMake and make/ninja from first principles, without relying on the shell scripts.

if362005 commented 1 year ago

It finds llvm_config in INSTALL_PREFIX. However, the error still occur ** Install the project... -- Install configuration: "Release" -- Up-to-date: /home/lxj/flang/install/lib/libpgmath.so -- Up-to-date: /home/lxj/flang/install/lib/libpgmath.a -- Found LLVM_CONFIG as /home/lxj/flang/install/bin/llvm-config -- Linker detection: GNU ld -- Building with -fPIC -- Flang version: 6.0.1 -- Failed to locate sphinx-build executable (missing: SPHINX_EXECUTABLE) -- Configuring done -- Generating done -- Build files have been written to: /home/lxj/flang/flang-legacy/build/flang

Error file INSTALL cannot copy file "/home/lxj/flang/flang-legacy/build/flang/bin/flang2" to "/usr/lib/llvm-6.0/bin/flang2": Success.

**

bryanpkc commented 1 year ago

@if362005 Try building the latest master branch and see if it solves your problem.

mine-blog commented 1 year ago

hello, I miss the same problem with release_14x and master. Please help me solve the problem.

tmp/ieee_features-abde6b.ll:10:75: warning: ptr type is only supported in -opaque-pointers mode
%structieee_features__ieee_features_type___td_ = type < { [8 x i64], [6 x ptr], [38 x i8] } >
                                                                          ^
/tmp/ieee_features-abde6b.ll:10:75: error: expected type
%structieee_features__ieee_features_type___td_ = type < { [8 x i64], [6 x ptr], [38 x i8] } >
                                                                          ^
1 error generated.
make[2]: *** [runtime/flang/CMakeFiles/flang_static.dir/build.make:3228: runtime/flang/CMakeFiles/flang_static.dir/ieee_features.F95.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/tmp/iso_c_bind-98de1e.ll:10:65: warning: ptr type is only supported in -opaque-pointers mode
%structiso_c_binding___c_funptr__td_ = type < { [8 x i64], [6 x ptr], [28 x i8] } >
                                                                ^
/tmp/iso_c_bind-98de1e.ll:10:65: error: expected type
%structiso_c_binding___c_funptr__td_ = type < { [8 x i64], [6 x ptr], [28 x i8] } >
                                                                ^
1 error generated.
make[2]: *** [runtime/flang/CMakeFiles/flang_static.dir/build.make:3267: runtime/flang/CMakeFiles/flang_static.dir/iso_c_bind.F95.o] Error 1
/tmp/omp_lib-66180e.ll:13:28: warning: ptr type is only supported in -opaque-pointers mode
define void @omp_lib_oss1_(ptr %kind, ptr %modifier) !dbg !17 {
                           ^
/tmp/omp_lib-66180e.ll:13:28: error: expected type
define void @omp_lib_oss1_(ptr %kind, ptr %modifier) !dbg !17 {
                           ^
1 error generated.
make[2]: *** [runtime/flang/CMakeFiles/flang_static.dir/build.make:1642: runtime/flang/CMakeFiles/flang_static.dir/omp_lib.F95.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1441: runtime/flang/CMakeFiles/flang_static.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
[  0%] Built target flangADT
[  0%] Built target flangArgParser
[  0%] Built target scutil
[  0%] Built target ompstub_shared
[  1%] Built target ompstub_static
[  3%] Built target flangrti_shared
[  5%] Built target flangrti_static
[  6%] Built target upperl
[  6%] Built target gen_backend_upper
[  6%] Built target errmsggen
[  6%] Built target gen_backend_error_headers
[  6%] Built target ilitp
[  6%] Built target gen_backend_ili
[  6%] Built target ilmtp
[  6%] Built target gen_backend_ilm
[  6%] Built target fsymutil
[  6%] Built target gen_backend_symtab
[  6%] Built target fsymini
[  8%] Built target gen_backend_symini
[  9%] Built target fmachar
[  9%] Built target gen_backend_machar
[ 16%] Built target flang2
[ 17%] Built target lr
[ 17%] Built target gen_frontend_error_headers
[ 17%] Built target prodstr
[ 17%] Built target gen_frontend_parsetable
[ 17%] Built target fesymutil
[ 17%] Built target gen_frontend_symtab
[ 17%] Built target fesymini
[ 17%] Built target gen_frontend_symini
[ 17%] Built target astutil
[ 17%] Built target gen_frontend_ast
[ 17%] Built target machar
[ 17%] Built target gen_frontend_machar
[ 25%] Built target flang1
[ 25%] Building Fortran object runtime/flang/CMakeFiles/flang_static.dir/iso_c_bind.F95.o
/tmp/iso_c_bind-430db5.ll:10:65: warning: ptr type is only supported in -opaque-pointers mode
%structiso_c_binding___c_funptr__td_ = type < { [8 x i64], [6 x ptr], [28 x i8] } >
                                                                ^
/tmp/iso_c_bind-430db5.ll:10:65: error: expected type
%structiso_c_binding___c_funptr__td_ = type < { [8 x i64], [6 x ptr], [28 x i8] } >
                                                                ^
1 error generated.
make[2]: *** [runtime/flang/CMakeFiles/flang_static.dir/build.make:3267: runtime/flang/CMakeFiles/flang_static.dir/iso_c_bind.F95.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1441: runtime/flang/CMakeFiles/flang_static.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
dmikushin commented 1 year ago

@bryanpkc , the error in the first message of this issue indicates a mismatch of the expected and actual versions of LLVM:

/tmp/iso_c_bind-a0d584.ll:10:65: error: expected type
%structiso_c_binding___c_funptr__td_ = type < { [8 x i64], [6 x ptr], [28 x i8] } >
^

The build guide contains this statement, which is very misleading:

The latest supported LLVM version is 10.0.

Clearly, the version of LLVM required for building Flang is not 10. If you agree, please kindly remove this line from the guide.

bryanpkc commented 1 year ago

@dmikushin Thanks for catching that. If you use release_14x of classic-flang-llvm-project, you have to use the legacy branch of flang. The master branch of flang will only work with release_15x and newer.

bryanpkc commented 1 year ago

I have updated the wiki page. Thanks @dmikushin.

dmikushin commented 1 year ago

@bryanpkc ,

The master branch of flang will only work with release_15x and newer.

I have already tested release_100, release_14x and release_16x, and always receive the same error:

> /tmp/iso_c_bind-a0d584.ll:10:65: error: expected type
%structiso_c_binding___c_funptr__td_ = type < { [8 x i64], [6 x ptr], [28 x i8] } >
^

release_15x is currently building, but I'm pretty sure it will fail in the same way.

I know this error: it is due to the breaking change in LLVM IR spec, which now requires element type in the array specification. AFAIK, this change was introduced long before, in LLVM 7 if I'm not mistaking. Therefore:

  1. Switching between LLVM 14-15-16 will not fix this error
  2. The real reason of this issue is: in-tree flang is unable to comply with the IR spec, when it prints LLVM IR.

I'm very confused by my own conclusion. If it is correct, LLVM in-tree flang would have to be broken for a very long time. Instructions is this project also cannot work with any LLVM newer than version 7. Everything ends up being very very misleading.

bryanpkc commented 1 year ago

@dmikushin What do you mean by "in-tree flang"? Classic Flang isn't part of llvm-project or even classic-flang-llvm-project. It is never "in-tree". You need to build classic-flang-llvm-project first, then use the Clang compiler from that build to build Classic Flang. It is possible that the instructions in the wiki page are out of date, but if you use the scripts provided in the repositories to build these components, they should work.

bryanpkc commented 1 year ago

An example of how the scripts are used (by our CI workflows) can be seen here:

https://github.com/flang-compiler/classic-flang-llvm-project/blob/release_15x/.github/workflows/flang-tests.yml

dmikushin commented 1 year ago

What do you mean by "in-tree flang"?

In wiki page (or in the build script - is the same) there is:

-DCMAKE_C_COMPILER=$INSTALL_PREFIX/bin/clang \
    -DCMAKE_Fortran_COMPILER=$INSTALL_PREFIX/bin/flang 
    -DCMAKE_Fortran_COMPILER_ID=Flang \

Clearly, this means flang and clang belong to the same $INSTALL_PREFIX. Therefore, flang belongs to the installation of classic-flang-llvm-project. So it's not our flang-classic, but the one which comes together with LLVM - in-tree flang. We need to use it to compile the Fortran sources.

So this in-tree flang fails our build, regardless of the version of LLVM being used, because this flang is broken. I can't think of how it could ever work. The only chance to make instructions in this project to work is to use the previous build of flang-classic as flang, instead of in-tree flang.

PS: I apologize for this difficult reading, it might require multiple reads to understand.

DavidTruby commented 1 year ago

LLVM flang ("in-tree flang") works perfectly well if you build it with upstream LLVM with no modifications. It might not work with the classic-flang-llvm-project modifications but I also don't see why it should; classic-flang and LLVM flang are completely separate projects. If you're wanting to use classic flang you should ignore the existence of LLVM Flang and vice versa.

Clearly, this means flang and clang belong to the same $INSTALL_PREFIX. Therefore, flang belongs to the installation of classic-flang-llvm-project.

It does not follow that things in the same install prefix belong to the installation of the same project. I have both clang and gcc in /usr on my system, but that does not mean clang and gcc were built from the same project!

dmikushin commented 1 year ago

but that does not mean clang and gcc were built from the same project!

That's why I'm saying instructions presented here are misleading multiple times (recursively).

bryanpkc commented 1 year ago

Clearly, this means flang and clang belong to the same $INSTALL_PREFIX. Therefore, flang belongs to the installation of classic-flang-llvm-project. So it's not our flang-classic, but the one which comes together with LLVM - in-tree flang. We need to use it to compile the Fortran sources.

Yes, when you build classic-flang-llvm-project using our instructions, you get both flang and clang in the same location, but flang is just a symbolic link to clang (which is how Classic Flang works); it is not the driver for the new, in-tree, LLVM Flang. You must not enable LLVM Flang when building classic-flang-llvm-project; it is not compatible with Classic Flang support.

bryanpkc commented 1 year ago

The only chance to make instructions in this project to work is to use the previous build of flang-classic as flang, instead of in-tree flang.

This is almost how it is supposed to work. The Fortran sources in the Classic Flang runtime are compiled with the current builds of classic-flang-llvm-project and Classic Flang frontend. There is no need for a previous build.