Fix issue #61260
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks!
Hm, this is a clangDriver change rather than anything Flang specific 🤔 . Btw, how does https://github.com/llvm/llvm-project/issues/61260 manifest to you? I'm trying to figure out how to best test it (I couldn't find any other tests for this specifically).
Before
$ /home/sunshaoce/dev/llvm-project/build/bin/flang-new /home/sunshaoce/dev/llvm-project/build/temp.f03 -flang-experimental-exec -o temp.out -### flang-new version 17.0.0 (https://github.com/llvm/llvm-project.git 890e6c871d31dca9e461c01118cf25fb303b9cad) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/sunshaoce/dev/llvm-project/build/bin "/usr/bin/ld" "-pie" "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "temp.out" "/lib/x86_64-linux-gnu/Scrt1.o" "/lib/x86_64-linux-gnu/crti.o" "/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o" "-L/usr/lib/gcc/x86_64-linux-gnu/9" "-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib64" "-L/lib/x86_64-linux-gnu" "-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/usr/lib/../lib64" "-L/lib" "-L/usr/lib" "/home/sunshaoce/dev/llvm-project/build/temp.f03" "-L/home/sunshaoce/dev/llvm-project/build/lib" "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o" "/lib/x86_64-linux-gnu/crtn.o"
after
$ /home/sunshaoce/dev/llvm-project/build/bin/flang-new /home/sunshaoce/dev/llvm-project/build/temp.f03 -flang-experimental-exec -o temp.out -### flang-new version 17.0.0 (https://github.com/llvm/llvm-project.git 890e6c871d31dca9e461c01118cf25fb303b9cad) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/sunshaoce/dev/llvm-project/build/bin "/home/sunshaoce/dev/llvm-project/build/bin/flang-new" "-fc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "x86-64" "-o" "/tmp/temp-72c5c0.o" "-x" "f95-cpp-input" "/home/sunshaoce/dev/llvm-project/build/temp.f03" "/usr/bin/ld" "-pie" "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "temp.out" "/lib/x86_64-linux-gnu/Scrt1.o" "/lib/x86_64-linux-gnu/crti.o" "/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o" "-L/usr/lib/gcc/x86_64-linux-gnu/9" "-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib64" "-L/lib/x86_64-linux-gnu" "-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/usr/lib/../lib64" "-L/lib" "-L/usr/lib" "/tmp/temp-72c5c0.o" "-L/home/sunshaoce/dev/llvm-project/build/lib" "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o" "/lib/x86_64-linux-gnu/crtn.o"
So, I tested it by checking whether flang was called.
We don't really build executable for testing the Driver. Also, building an executable involves many steps:
- The driver (flang-new) identifies the file as a valid Fortran file. Delegates to "Flang" for the next step.
- "Flang" parses the input, runs semantic checks and lowers to LLVM IR. This is driven by the frontend driver, flang-new -fc1.
- LLVM IR is compiled into machine code (via LLVM) (also driven by flang-new -fc1).
- Machine code generated in 3 is then linked by the driver to generate an executable (this step is driven by flang-new).
It would be good to understand what exactly this change unblocks and then test that specifically. To me it sounds like this change is only really needed for 1. and hence we should only be testing 1 and avoid doing extra work that's not needed.
I suspect that without this change, .*.f03 files are recognized as object rather than Fortran files and hence step 1. is followed by step 4. rather than step 2. So, try flang-new -### file.f03 with and without your change. You should see that with this change you do see the frontend driver invocation (flang-new -fc1 <some args>) that would run steps 2 and 3.. IMO that's the only thing that requires verifying here.
Does this make sense?
EDIT
Ah, I've missed your reply, sorry! My suspicion was correct, cool :) Now we know what kind of test is needed here.
I'd move these tests to flang/test/Driver/supported-suffices. That would help documenting what these tests actual check for. Also, one could be tempted to test for other suffices and then it would be nice to keep them in one place. Ta!
flang/test/Driver/f03-suffix.f03 | ||
---|---|---|
1 ↗ | (On Diff #504359) | You can safely drop -flang-experimental-exec here. |
4 ↗ | (On Diff #504359) | The linker invocation is unrelated to this change. Also, it will very likely look differently on other operating systems. Best to skip it. |
flang/test/Driver/supported-suffices/f08-suffix.f08 | ||
---|---|---|
5 | This line will not appear without -flang-experimental-exec - you need to delete it. Same for the other test. |
Sorry! My previous tests were not comprehensive enough, which resulted in failures in the MSVC environment.
This line will not appear without -flang-experimental-exec - you need to delete it. Same for the other test.