$cache[$key] = empty($arr) ? NULL : $arr; return $cache[$key]; } // 门户 获取需要在频道显示的栏目主题数据 function portal_channel_thread($fid) { global $forumlist; if (empty($fid)) return NULL; $orderby = array('tid' => 1); $page = 1; // 遍历所有在频道显示内容的栏目 $category_forumlist = channel_category($fid); $arrlist = array(); $forum_tids = array(); $tidlist = array(); if ($category_forumlist) { foreach ($category_forumlist as &$_forum) { // 频道显示数据 $arrlist['list'][$_forum['fid']] = array( 'fid' => $_forum['fid'], 'name' => $_forum['name'], 'rank' => $_forum['rank'], 'type' => $_forum['type'], 'url' => $_forum['url'], 'channel_new' => $_forum['channel_new'], ); $forum_thread = thread_tid__find(array('fid' => $_forum['fid']), $orderby, $page, $_forum['channel_new'], 'tid', array('tid')); // 最新信息按栏目分组 foreach ($forum_thread as $key => $_thread) { $forum_tids[$key] = $_thread; } unset($forum_thread); } $tidlist += $forum_tids; } unset($category_forumlist); // 获取属性对应的tid集合 list($flaglist, $flagtids) = flag_thread_by_fid($fid); empty($flagtids) || $tidlist += $flagtids; unset($flagtids); // 频道置顶 $stickylist = sticky_list_thread($fid); empty($stickylist) || $tidlist += $stickylist; // 在这之前合并所有二维数组 tid值为键/array('tid值' => tid值) $tidarr = arrlist_values($tidlist, 'tid'); // 在这之前使用$tidarr = array_merge($tidarr, $arr)前合并所有一维数组 tid/array(1,2,3) if (empty($tidarr)) { $arrlist['list'] = isset($arrlist['list']) ? array_multisort_key($arrlist['list'], 'rank', FALSE, 'fid') : array(); return $arrlist; } $tidarr = array_unique($tidarr); $pagesize = count($tidarr); // 遍历获取的所有tid主题 $threadlist = well_thread_find_asc($tidarr, $pagesize); // 遍历时为升序,翻转为降序 $threadlist = array_reverse($threadlist); foreach ($threadlist as &$_thread) { // 各栏目最新内容 isset($forum_tids[$_thread['tid']]) AND $arrlist['list'][$_thread['fid']]['news'][$_thread['tid']] = $_thread; // 全站置顶内容 isset($stickylist[$_thread['tid']]) AND $arrlist['sticky'][$_thread['tid']] = $_thread; // 首页属性主题 if (!empty($flaglist)) { foreach ($flaglist as $key => $val) { if (isset($val['tids']) && in_array($_thread['tid'], $val['tids'])) { $arrlist['flaglist'][$key][array_search($_thread['tid'], $val['tids'])] = $_thread; ksort($arrlist['flaglist'][$key]); $arrlist['flag'][$_thread['tid']] = $_thread; } } } } unset($threadlist); if (isset($arrlist['sticky'])) { $i = 0; foreach ($arrlist['sticky'] as &$val) { ++$i; $val['i'] = $i; } } if (isset($arrlist['flag'])) { $i = 0; foreach ($arrlist['flag'] as &$val) { ++$i; $val['i'] = $i; } } if (isset($arrlist['flaglist'])) { foreach ($arrlist['flaglist'] as &$val) { $i = 0; foreach ($val as &$v) { ++$i; $v['i'] = $i; } } } isset($arrlist['list']) AND $arrlist['list'] = array_multisort_key($arrlist['list'], 'rank', FALSE, 'fid'); return $arrlist; } ?>LLVM `llvmSupportHost.h` on C++ MacOS ARM64 does not exist (CMake) - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

LLVM `llvmSupportHost.h` on C++ MacOS ARM64 does not exist (CMake) - Stack Overflow

programmeradmin0浏览0评论

I can't include the llvm/Support/Host.h header in C++ even after specifying:

find_package(LLVM REQUIRED CONFIG)

include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib -Wl,-rpath,/opt/homebrew/opt/llvm/lib -lLLVM")

target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})

include_directories(/opt/homebrew/opt/llvm/include)

Every other header file works just fine, it's just Host.h that is not budging.

Due to that, or maybe something else, trying to do

llvm::sys::getDefaultTargetTriple())

Gives an error, with it complaining that it cannot resolve the symbol getDefaultTargetTriple

To avoid that I also tried:

llvm::Triple triple(Module->getTargetTriple());

llvm::outs() << "Target triple: " << triple.str() << "\n";

Which, gave nothing, it just prints:

Target triple: 

Is there something I'm missing?

The full CMakeLists.txt:

cmake_minimum_required(VERSION 3.29)
project(Vast)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#find_package(LLVM REQUIRED CONFIG)
#include_directories(${LLVM_INCLUDE_DIRS})
#add_definitions(${LLVM_DEFINITIONS})

add_executable(Vast
    cvast/main.cpp
)

find_package(LLVM REQUIRED CONFIG)

include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib -Wl,-rpath,/opt/homebrew/opt/llvm/lib -lLLVM")

target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})

#target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})

include_directories(/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/include/python3.13)

include_directories(/opt/homebrew/opt/llvm/include)

target_link_libraries(${PROJECT_NAME}
        /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/lib/libpython3.13.dylib
)

target_include_directories(Vast PRIVATE /opt/homebrew/include)

Error from C++:

[1/2] Building CXX object CMakeFiles/Vast.dir/cvast/main.cpp.o
FAILED: CMakeFiles/Vast.dir/cvast/main.cpp.o 
/Library/Developer/CommandLineTools/usr/bin/c++  -I/opt/homebrew/opt/llvm/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/include/python3.13 -isystem /opt/homebrew/include -g -std=gnu++20 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk -fcolor-diagnostics   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/Vast.dir/cvast/main.cpp.o -MF CMakeFiles/Vast.dir/cvast/main.cpp.o.d -o CMakeFiles/Vast.dir/cvast/main.cpp.o -c /Users/silicon/PycharmProjects/Vast/cvast/main.cpp
In file included from /Users/silicon/PycharmProjects/Vast/cvast/main.cpp:19:
In file included from /Users/silicon/PycharmProjects/Vast/cvast/headers/runner.h:14:
/Users/silicon/PycharmProjects/Vast/cvast/headers/irgen.h:27:10: fatal error: 'llvm/Support/Host.h' file not found
   27 | #include "llvm/Support/Host.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.

I can't include the llvm/Support/Host.h header in C++ even after specifying:

find_package(LLVM REQUIRED CONFIG)

include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib -Wl,-rpath,/opt/homebrew/opt/llvm/lib -lLLVM")

target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})

include_directories(/opt/homebrew/opt/llvm/include)

Every other header file works just fine, it's just Host.h that is not budging.

Due to that, or maybe something else, trying to do

llvm::sys::getDefaultTargetTriple())

Gives an error, with it complaining that it cannot resolve the symbol getDefaultTargetTriple

To avoid that I also tried:

llvm::Triple triple(Module->getTargetTriple());

llvm::outs() << "Target triple: " << triple.str() << "\n";

Which, gave nothing, it just prints:

Target triple: 

Is there something I'm missing?

The full CMakeLists.txt:

cmake_minimum_required(VERSION 3.29)
project(Vast)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#find_package(LLVM REQUIRED CONFIG)
#include_directories(${LLVM_INCLUDE_DIRS})
#add_definitions(${LLVM_DEFINITIONS})

add_executable(Vast
    cvast/main.cpp
)

find_package(LLVM REQUIRED CONFIG)

include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib -Wl,-rpath,/opt/homebrew/opt/llvm/lib -lLLVM")

target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})

#target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})

include_directories(/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/include/python3.13)

include_directories(/opt/homebrew/opt/llvm/include)

target_link_libraries(${PROJECT_NAME}
        /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/lib/libpython3.13.dylib
)

target_include_directories(Vast PRIVATE /opt/homebrew/include)

Error from C++:

[1/2] Building CXX object CMakeFiles/Vast.dir/cvast/main.cpp.o
FAILED: CMakeFiles/Vast.dir/cvast/main.cpp.o 
/Library/Developer/CommandLineTools/usr/bin/c++  -I/opt/homebrew/opt/llvm/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/include/python3.13 -isystem /opt/homebrew/include -g -std=gnu++20 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk -fcolor-diagnostics   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/Vast.dir/cvast/main.cpp.o -MF CMakeFiles/Vast.dir/cvast/main.cpp.o.d -o CMakeFiles/Vast.dir/cvast/main.cpp.o -c /Users/silicon/PycharmProjects/Vast/cvast/main.cpp
In file included from /Users/silicon/PycharmProjects/Vast/cvast/main.cpp:19:
In file included from /Users/silicon/PycharmProjects/Vast/cvast/headers/runner.h:14:
/Users/silicon/PycharmProjects/Vast/cvast/headers/irgen.h:27:10: fatal error: 'llvm/Support/Host.h' file not found
   27 | #include "llvm/Support/Host.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
Share Improve this question edited Feb 6 at 16:13 Silicon asked Feb 6 at 14:29 SiliconSilicon 296 bronze badges 4
  • Could you post the C++ code that tries to include the header? like #include <llvm/Support/Host.h> – GandhiGandhi Commented Feb 6 at 15:49
  • Also FYi if its "the linker complaining that it cannot resolve the symbol", that means the library containing that symbol isn't linked against the binary. llvm is split into a few libraries, and that symbols is included in the "support" library. I'd be suspicious of what LLVM_LIBRARIES contains; I don't see it set. – GandhiGandhi Commented Feb 6 at 15:59
  • @GandhiGandhi Complete mishap on my part. the #include is just that, #include "llvm/Support/Host.h" and the error has been added to the question – Silicon Commented Feb 6 at 16:11
  • Next time that could be relevant info. Including with quotes " has slightly different file lookup rules than including with angle bracket <> – GandhiGandhi Commented Feb 7 at 16:21
Add a comment  | 

1 Answer 1

Reset to default 0

Back, 5 hours later that is. Turns out the answer is that Host.h is not located within llvm/Support, but instead llvm/TargetParser/Host.h, and with that, you can use the llvm::sys::getDefaultTargetTriple().

发布评论

评论列表(0)

  1. 暂无评论