Skip to content

[Flang-RT] Environment introspection for quadmath.h #130411

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

Merged
merged 2 commits into from
Mar 11, 2025

Conversation

Meinersbur
Copy link
Member

@Meinersbur Meinersbur commented Mar 8, 2025

When compiling Flang-RT with Clang, query Clang for the GCC installation it uses. If found, create quadmath_wrapper.h that points to the quadmath.h of that GCC installation.

quadmath.h is only available when compiling with gcc, and Clang has no equivalent even though gcc's version compiles fine with Clang (at least up to and including gcc 13). It is still available in gcc's installation resource dir (in constrast to a system-wide directory such as /usr/include or /usr/local/include) and therefore not available to any compiler other than the gcc of that installation. quadmath may also be a different OS package than gcc itself, so it is not necessarily presesent.

Clang actually already appropriates a GCC installation for its libraries such that libquadmath.a is already found, but it does not do so for the include paths. Because adding that directory to the header search path may have wide-reaching consquences, we create only a wrapper header that points to the real quadmath.h in the same GCC installation that Clang uses.

@Meinersbur Meinersbur requested a review from vzakhari March 8, 2025 12:16
Copy link

github-actions bot commented Mar 8, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@Meinersbur Meinersbur marked this pull request as ready for review March 8, 2025 13:29
Copy link
Contributor

@vzakhari vzakhari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! Thank you!

@Meinersbur Meinersbur merged commit 7341753 into llvm:main Mar 11, 2025
11 checks passed
searlmc1 pushed a commit to ROCm/llvm-project that referenced this pull request Mar 12, 2025
searlmc1 pushed a commit to ROCm/llvm-project that referenced this pull request Mar 12, 2025
When compiling Flang-RT with Clang, query Clang for the GCC installation
it uses. If found, create `quadmath_wrapper.h` that points to the
`quadmath.h` of that GCC installation.

`quadmath.h` is only available when compiling with gcc, and Clang has no
equivalent even though gcc's version compiles fine with Clang (at least
up to and including gcc 13). It is still available into gcc's
installation resource dir (in constrast to a system-wide indirectory
such as `/usr/include` or `/usr/local/include`) and therefore not
available to any compiler other than the gcc of that installation.
quadmath may also be a different OS package than gcc itself, so it is
not necessarily presesent.

Clang actually already appropriates a GCC installation for its libraries
such that `libquadmath.a` is already found, but it does not do so for
the include paths. Because adding that directory to the header search
path may have wide-reaching consquences, we create only a wrapper header
that points to the real `quadmath.h` in the same GCC installation that
Clang uses.
Meinersbur added a commit to llvm/llvm-zorg that referenced this pull request Mar 13, 2025
#407)

The option was removed in #395. After
llvm/llvm-project#130411, the option should now
work even when compiling flang-rt with Clang.
@Meinersbur Meinersbur deleted the flang_runtime_quadmath-introspection branch April 29, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants