From 07e74b7f5147d5da67b46067df5d26090a3bb96b Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 7 Feb 2021 23:58:41 -0800
Subject: [PATCH] llvm: Do not use find_library for ncurses

This ensures that it lets OE to decide which lib to link
otherwise it adds absolute paths to linker cmdline and confuses it
horribly with native and target libs when build clang for target

TOPDIR/build/tmp/work/cortexa57-yoe-linux-musl/clang/12.0.0-r0/recipe-sysroot-native/usr/lib/libtinfo.so: error adding symbols: file in wrong format
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 compiler-rt/cmake/config-ix.cmake     | 2 +-
 llvm/cmake/modules/FindTerminfo.cmake | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 2ca18ebb4ad4..51c56f1e0b8b 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -188,7 +188,7 @@ else()
   set(MAYBE_REQUIRED)
 endif()
 if(LLVM_ENABLE_TERMINFO)
-  find_library(COMPILER_RT_TERMINFO_LIB NAMES terminfo tinfo curses ncurses ncursesw ${MAYBE_REQUIRED})
+  find_library(COMPILER_RT_TERMINFO_LIB NAMES terminfo tinfo curses ncurses ncursesw ${MAYBE_REQUIRED} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
 endif()
 if(COMPILER_RT_TERMINFO_LIB)
   set(LLVM_ENABLE_TERMINFO 1)
diff --git a/llvm/cmake/modules/FindTerminfo.cmake b/llvm/cmake/modules/FindTerminfo.cmake
index 163af6697067..bf2e760bed8a 100644
--- a/llvm/cmake/modules/FindTerminfo.cmake
+++ b/llvm/cmake/modules/FindTerminfo.cmake
@@ -11,7 +11,7 @@
 # Additionally, the following import target will be defined:
 # Terminfo::terminfo
 
-find_library(Terminfo_LIBRARIES NAMES terminfo tinfo curses ncurses ncursesw)
+find_library(Terminfo_LIBRARIES NAMES terminfo tinfo curses ncurses ncursesw NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
 
 if(Terminfo_LIBRARIES)
   include(CMakePushCheckState)
