Skip to content

[Flang] Move builtin .mod generation into runtimes#679

Open
Meinersbur wants to merge 8 commits into
amd-stagingfrom
users/meinersbur/rocm_flang_builtin-mods
Open

[Flang] Move builtin .mod generation into runtimes#679
Meinersbur wants to merge 8 commits into
amd-stagingfrom
users/meinersbur/rocm_flang_builtin-mods

Conversation

@Meinersbur
Copy link
Copy Markdown

@Meinersbur Meinersbur commented Nov 25, 2025

llvm#169638 pre-merged into amd-staging

@github-actions
Copy link
Copy Markdown

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@z1-cciauto
Copy link
Copy Markdown
Collaborator

@z1-cciauto
Copy link
Copy Markdown
Collaborator

@Meinersbur Meinersbur force-pushed the users/meinersbur/rocm_flang_builtin-mods branch from 0f93940 to a41ffe8 Compare November 25, 2025 16:08
@z1-cciauto
Copy link
Copy Markdown
Collaborator

@Meinersbur Meinersbur force-pushed the users/meinersbur/rocm_flang_builtin-mods branch from a41ffe8 to 4a8fef3 Compare December 1, 2025 19:14
@z1-cciauto
Copy link
Copy Markdown
Collaborator

@z1-cciauto
Copy link
Copy Markdown
Collaborator

@Meinersbur Meinersbur marked this pull request as ready for review December 2, 2025 14:42
@z1-cciauto
Copy link
Copy Markdown
Collaborator

@z1-cciauto
Copy link
Copy Markdown
Collaborator

@z1-cciauto
Copy link
Copy Markdown
Collaborator

@Meinersbur
Copy link
Copy Markdown
Author

Meinersbur commented Dec 9, 2025

@ronlieb Merged-in llvm@7675fc7. This includes all the patches since the last merge. Had to resolve two merge conflicts unrelated to the PR:

  • llvm/lib/Transforms/Vectorize/LoopVectorize.cpp: upstream inlined method
  • llvm/runtimes/CMakeLists.txt: ROCm 6.3 handling seems to be gone

The test 'flang/test/Integration/amdgpu/debug-target-var.f90' is failing. I think it is unrelated to llvm#169638

These were automatically resolved by kdiff3:

  • flang/test/Lower/OpenMP/target-enter-data-default-openmp52.f90
  • llvm/test/Transforms/LoopVectorize/AArch64/predicated-costs.ll

Had to add
74f496e

For aomp to build the amgdcn-amd-amdhsa modules, ROCm/aomp#1737 needs to be applied.

@z1-cciauto
Copy link
Copy Markdown
Collaborator

@z1-cciauto
Copy link
Copy Markdown
Collaborator

@Meinersbur Meinersbur force-pushed the users/meinersbur/rocm_flang_builtin-mods branch from 80634ae to 021eaa2 Compare December 10, 2025 14:13
@z1-cciauto
Copy link
Copy Markdown
Collaborator

@Meinersbur
Copy link
Copy Markdown
Author

This PR is intended @ronlieb to resolve a merge conflict of amd-staging with upstream, it is not intended for an additional review, but GitHub seems to have automatically added reviewers. Sorry for the noise.

@Meinersbur Meinersbur requested review from ronlieb and removed request for b-sumner, chinmaydd, david-salinas, fabianmcg, lamb-j and vangthao95 May 29, 2026 15:06
Meinersbur and others added 4 commits June 4, 2026 08:33
Before this PR, omp_lib.h is emitted to `${PREFIX}/include` or
`${PREFIX}/lib/clang/<version>/include` (install prefix) and
`${PREFIX}/runtime/src/omp_lib.h` (builddir prefix). It is never found
there because the driver only adds `${PREFIX}/include/flang/OpenMP` to
the include path.

Fix the `omp_lib.h` include by using the same mechanism as the
omp_lib.mod; that is, move it to
`${PREFIX}/lib/clang/<version>/finclude/flang/<target-triple>`. The
search path is already added by the driver via
`-fintrinsics-modules-path` by the driver. Although omp_lib.h currently
does not contain anything target-specific, it could do so in the future
and I don't think it is worth the effort to add a mechanism without the
target triple. It should also me consistent with omp_lib.mod.

The changes in detail consist of:
1. Move the omp_lib.h output in the builddir to
`${RUNTIMES_OUTPUT_RESOURCE_MOD_DIR}`. This already takes care of
whether it is a bootstrapping build or not.
3. Move the omp_lib.h install dir to
`${RUNTIMES_INSTALL_RESOURCE_MOD_PATH}`.
4. Remove the implicit search path `include/flang/OpenMP` from the
frontend. There is nothing in there anyway.
5. Hardcoding the include search path for testing to the
`LLVM_RUNTIME_TARGETS=default` build becomes unnecessary. This was way
the `include-omp-header.f90` test was still passing, although it would
not work outside the regression tests. Essentially, it tested
lit.site.cfg, not the driver.
6. Replace the old `include-omp-header.f90` test. It created a temporary
`omp_lib.h` that interferes with any other test that use `include
omp_lib.h` (there currently isn't but I originally intended to add the
replacement as an additional omp_lib.h test which resulted in a flaky
test while the original test was there). Due to how the %flang(_fc1)
substitution works, lookup order may also vary.
@Meinersbur Meinersbur force-pushed the users/meinersbur/rocm_flang_builtin-mods branch from 964b66d to 77b8814 Compare June 4, 2026 13:39
@Meinersbur Meinersbur force-pushed the users/meinersbur/rocm_flang_builtin-mods branch from 3873b24 to 64b690d Compare June 4, 2026 13:55
@Meinersbur Meinersbur force-pushed the users/meinersbur/rocm_flang_builtin-mods branch from 5c80b71 to 826eb63 Compare June 5, 2026 12:50
@Meinersbur Meinersbur force-pushed the users/meinersbur/rocm_flang_builtin-mods branch from 826eb63 to ebbfdf3 Compare June 5, 2026 14:46
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.

3 participants