This is an archive of the discontinued LLVM Phabricator instance.

[Flang] Adjust preprocessing to build modules correctly
AbandonedPublic

Authored by PeteSteinfeld on Oct 10 2022, 10:26 AM.

Details

Summary

We were not correctly generating the KIND=10 variants of the REAL
intrinsic modules. These modules contained macros that were intended to
generate those variants, but the macros were not defined. Furthermore,
predefined macros were not being added if the "-nocpp" option was
enabled, which was the default.

I made two changes --

  • Turned on preprocessing by default. This required adjusting the tests run by "check-flang".
  • Added macros for "x86_64" and "aarch64" for compilers hosted on X86 and ARM machines.

Diff Detail

Event Timeline

PeteSteinfeld created this revision.Oct 10 2022, 10:26 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
PeteSteinfeld requested review of this revision.Oct 10 2022, 10:26 AM

Attempt to fix the Microsoft build.

Another attempt to get information about how to build on Windows.

Yet another attempt to figure out the Windows builds.

Bold changes Pete!

Do these predefined architecture flags match other Fortran compilers? Are they consistent with what is predefined in clang?

Enabling the preprocessor by default means that people will get symbols defined in their compilation that they may not expect. Did you find any discussion in past threads about where preprocessing should be enabled or disabled by default? (Dim memory of switch the default to off.)

Is it an option to just enable the preprocessing of the module files instead of modifying the default?

Still another attempt to get things to build correctly on Windows.

PeteSteinfeld abandoned this revision.Oct 10 2022, 6:05 PM

@sscalpone , you're correct that these changes are, at the very least, too hasty. I'll look at another way of fixing the underlying problem.

vzakhari added inline comments.
flang/lib/Frontend/CompilerInvocation.cpp
767

In general, the macros should be set based on the compilation target, not the host. Though, I am not sure if other parts of Flang are done in a way that supports cross-compilation.

clang defines target-specific macros based on the compilation target in clang/lib/Basic/Targets/*, e.g. __x86_64__ is defined in clang/lib/Basic/Targets/X86.cpp.

PeteSteinfeld added inline comments.Oct 11 2022, 9:14 AM
flang/lib/Frontend/CompilerInvocation.cpp
767

Thanks, @vzakhari . I need to rethink how to make the right thing happen. That's why I abandoned this patch.