Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: clang-13 fatally fails when Fortran flags like -ffree-form are present #50681

Open
jprotze opened this issue Aug 4, 2021 · 4 comments
Labels
bugzilla Issues migrated from bugzilla clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

Comments

@jprotze
Copy link
Collaborator

jprotze commented Aug 4, 2021

Bugzilla Link 51339
Version trunk
OS Linux
Blocks #51489
CC @banach-space,@zygoloid,@tstellar

Extended Description

clang-12 accepted and ignored Fortran flags like -ffree-form. clang-13 and trunk fatally fail, when Fortran flags are applied.

The use case, where I see the current behavior as an issue is linking multiple object files compiled from different languages.
Many build systems will pass CFLAGS as well as FFLAGS to the linker command in such case. To automatically link the necessary language-specific runtime libraries, I see using the compiler driver for linking as common practice:

$(FC) -c fortran-code.F90 $(FFLAGS)
$(CXX) -c cpp-code.cpp $(CFLAGS)
$(CC) -c c-code.c $(CFLAGS)
$(CXX) fortran-code.o cpp-code.o c-code.o $(FFLAGS) $(CFLAGS) -l$(FORTRAN_RUNTIME)

To support such workflow, the compiler should not error out, at least when only used for linking.

This works with CC=gcc, CXX=g++, FC=gfortran, and FORTRAN_RUNTIME=gfortran.
This used to work with CC=clang-12, CXX=clang-12++, FC=gfortran, and FORTRAN_RUNTIME=gfortran.

A possible fix is available in https://reviews.llvm.org/D99353

@banach-space
Copy link
Contributor

Thank you for posting this, Joachim!

Just to clarify, clang-13 and trunk only fail when using Fortran options in non-Flang mode [1] (i.e. when using clang to compile non-Fortran files). Perhaps we need a linker mode to accommodate for situations like this?

Btw, this was also discussed on cfe-dev [2].

-Andrzej

[1] https:/llvm/llvm-project/blob/release/13.x/clang/include/clang/Driver/Driver.h#L69
[2] https://lists.llvm.org/pipermail/cfe-dev/2021-April/067981.html

@jprotze
Copy link
Collaborator Author

jprotze commented Aug 4, 2021

For reference gcc/11 behavior:

$ gcc test.c -ffree-form
cc1: warning: command-line option ‘-ffree-form’ is valid for Fortran but not for C
$ gcc test.c -c -ffree-form
cc1: warning: command-line option ‘-ffree-form’ is valid for Fortran but not for C
$ gcc test.o -ffree-form
$

In linker mode, gcc does not even write a warning. Only when compiling C code, you get a warning.

Getting a warning would be fine. Starting to throw a fatal error is the problem. For typical use cases I'm aware of, fixing the issue in linker mode would be sufficient.

@tstellar
Copy link
Collaborator

mentioned in issue #51489

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@asl asl added this to the LLVM 13.0.1 release milestone Dec 12, 2021
@tstellar
Copy link
Collaborator

The deadline for requesting fixes for the release has passed. This bug is being removed from the LLVM 13.0.1 release milestone. If you have a fix or think this bug is important enough to block the release, please explain why in a comment and add the bug back to the LLVM 13.0.1 release milestone.

@tstellar tstellar removed this from the LLVM 13.0.1 release milestone Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
Projects
None yet
Development

No branches or pull requests

4 participants