Skip to content

[flang][build] Fixed paths discrovery for the out-of-tree build. #87822

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 1 commit into from
Apr 5, 2024

Conversation

vzakhari
Copy link
Contributor

@vzakhari vzakhari commented Apr 5, 2024

When building flang out-of-tree with relative paths in LLVM_DIR,
CLANG_DIR and MLIR_DIR, we need to compute the absolute paths
based on the CMake build directory (i.e. where the cmake is invoked
from).

When building flang out-of-tree with relative paths in LLVM_DIR,
CLANG_DIR and MLIR_DIR, we need to compute the absolute paths
based on the CMake build directory (i.e. where the cmake is invoked
from).
@llvmbot llvmbot added the flang Flang issues not falling into any other category label Apr 5, 2024
@@ -81,12 +81,13 @@ if (FLANG_STANDALONE_BUILD)
mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
endif()

# We need a pre-built/installed version of LLVM.
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This use of LLVM_CMAKE_DIR does not make much sense to me, because it is set by LLVMConfig.cmake which is not in effect before this find_package command executes.

@@ -97,7 +98,7 @@ if (FLANG_STANDALONE_BUILD)
CLANG_DIR_ABSOLUTE
${CLANG_DIR}
REALPATH
${CMAKE_CURRENT_SOURCE_DIR})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like BASE_DIR was meant to be used here.

Copy link
Contributor

@psteinfeld psteinfeld left a comment

Choose a reason for hiding this comment

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

All builds and tests correctly and looks good.

@vzakhari vzakhari merged commit 9202984 into llvm:main Apr 5, 2024
@ceseo
Copy link
Contributor

ceseo commented Apr 10, 2024

This commit is breaking this buildbot: https://lab.llvm.org/buildbot/#/builders/175

Could you please take a look?

@vzakhari
Copy link
Contributor Author

This commit is breaking this buildbot: https://lab.llvm.org/buildbot/#/builders/175

Could you please take a look?

I do not know how I missed that breakage. Thank you for letting me know, @ceseo! I will look immediately.

@vzakhari
Copy link
Contributor Author

I see what happened. This change actually fixed handling of the relative paths, but this buildbot was using a trick to workaround the issue that was fixed.

The buildbot builds LLVM tree here: /home/tcwg-buildbot/worker/flang-aarch64-out-of-tree/build_llvm. So the projects' config files are present in /home/tcwg-buildbot/worker/flang-aarch64-out-of-tree/build_llvm/lib/cmake. The out-of-tree Flang build is configured like this:

cmake ../llvm-project/flang -DFLANG_ENABLE_WERROR=ON -DCMAKE_BUILD_TYPE=Release -GNinja -DLLVM_DIR:PATH=../../build_llvm/lib/cmake/llvm -DMLIR_DIR:PATH=../../build_llvm/lib/cmake/mlir -DCLANG_DIR:PATH=../../build_llvm/lib/cmake/clang

And it is run from /home/tcwg-buildbot/worker/flang-aarch64-out-of-tree/build_flang, so the path specified by CLANG_DIR does not really point to where the config files are. It points to /home/tcwg-buildbot/worker/build_llvm/lib/cmake/clang.

The buildbot needs to be fixed, since we can now use "real" paths relative to the Flang build directory.

vzakhari added a commit to vzakhari/llvm-zorg that referenced this pull request Apr 10, 2024
After llvm/llvm-project#87822
we can specify real relative paths from the flang build directory
to the directories containing LLVM/CLANG/etc. projects' config
files.
vzakhari added a commit to llvm/llvm-zorg that referenced this pull request Apr 10, 2024
After llvm/llvm-project#87822
we can specify real relative paths from the flang build directory
to the directories containing LLVM/CLANG/etc. projects' config
files.
vzakhari added a commit that referenced this pull request Apr 18, 2024
vzakhari added a commit that referenced this pull request Apr 19, 2024
aniplcc pushed a commit to aniplcc/llvm-project that referenced this pull request Apr 21, 2024
mgorny added a commit to mgorny/llvm-project that referenced this pull request Dec 22, 2024
…uilds

The changes in llvm#87822 introduced a regression where Flang could no
longer be built standalone without explicitly specifying all of
LLVM_DIR, CLANG_DIR and MLIR_DIR.  Restore the earlier logic that used
these paths as hints, and supported finding system-wide LLVM install
via default paths.  Instead, make paths absolute after locating
the packages, using the paths CMake determined.
mgorny added a commit that referenced this pull request Jan 9, 2025
…uilds (#120914)

The changes in #87822 introduced a regression where Flang could no
longer be built standalone without explicitly specifying all of
LLVM_DIR, CLANG_DIR and MLIR_DIR. Restore the earlier logic that used
these paths as hints, and supported finding system-wide LLVM install via
default paths. Instead, make paths absolute after locating the packages,
using the paths CMake determined.

-----

@vzakhari, could you confirm that this doesn't break your use case?
BaiXilin pushed a commit to BaiXilin/llvm-fix-vnni-instr-types that referenced this pull request Jan 12, 2025
…uilds (llvm#120914)

The changes in llvm#87822 introduced a regression where Flang could no
longer be built standalone without explicitly specifying all of
LLVM_DIR, CLANG_DIR and MLIR_DIR. Restore the earlier logic that used
these paths as hints, and supported finding system-wide LLVM install via
default paths. Instead, make paths absolute after locating the packages,
using the paths CMake determined.

-----

@vzakhari, could you confirm that this doesn't break your use case?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants