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

[mlir] Prepend include directories before LLVM includes #121223

Merged
merged 1 commit into from
Jan 1, 2025

Conversation

mgorny
Copy link
Member

@mgorny mgorny commented Dec 27, 2024

Prepend mlir's include directories before system LLVM include directories. This is particularly important for standalone builds, where system include directory may contain the previous version of mlir, and therefore various mlir targets (particularly tablegen) end up using the headers from the previous version over the fresh ones. The new logic is copied from clang.

Prepend mlir's include directories before system LLVM include
directories.  This is particularly important for standalone builds,
where system include directory may contain the previous version of mlir,
and therefore various mlir targets (particularly tablegen) end up using
the headers from the previous version over the fresh ones.  The new
logic is copied from clang.
@mgorny mgorny added cmake Build system in general and CMake in particular mlir labels Dec 27, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 27, 2024

@llvm/pr-subscribers-mlir

Author: Michał Górny (mgorny)

Changes

Prepend mlir's include directories before system LLVM include directories. This is particularly important for standalone builds, where system include directory may contain the previous version of mlir, and therefore various mlir targets (particularly tablegen) end up using the headers from the previous version over the fresh ones. The new logic is copied from clang.


Full diff: https://github.com/llvm/llvm-project/pull/121223.diff

1 Files Affected:

  • (modified) mlir/CMakeLists.txt (+4-2)
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 5ea49c0dbfa7e3..7416e522083b7b 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -196,8 +196,10 @@ endif()
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
-include_directories( "include")
-include_directories( ${MLIR_INCLUDE_DIR})
+include_directories(BEFORE
+  "include"
+  ${MLIR_INCLUDE_DIR}
+  )
 
 # Adding tools/mlir-tblgen here as calling add_tablegen sets some variables like
 # MLIR_TABLEGEN_EXE in PARENT_SCOPE which gets lost if that folder is included

Copy link
Member

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

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

LGTM. clang/CMakeLists.txt has been using this since 73963b6 (2011)

@mgorny mgorny merged commit fac6be6 into llvm:main Jan 1, 2025
11 checks passed
@mgorny mgorny deleted the mlir-include-dirs branch January 1, 2025 15:31
meltq pushed a commit to meltq/llvm-project that referenced this pull request Jan 2, 2025
Prepend mlir's include directories before system LLVM include
directories. This is particularly important for standalone builds, where
system include directory may contain the previous version of mlir, and
therefore various mlir targets (particularly tablegen) end up using the
headers from the previous version over the fresh ones. The new logic is
copied from clang.
vortex73 pushed a commit to vortex73/llvm-project that referenced this pull request Jan 29, 2025
Prepend mlir's include directories before system LLVM include
directories. This is particularly important for standalone builds, where
system include directory may contain the previous version of mlir, and
therefore various mlir targets (particularly tablegen) end up using the
headers from the previous version over the fresh ones. The new logic is
copied from clang.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants