Summary: | clang++6: fatal error: 'stdlib.h' file not found | ||
---|---|---|---|
Product: | Sisyphus | Reporter: | Vitaly Chikunov <vt> |
Component: | clang6.0 | Assignee: | Konstantin A Lepikhov (L.A. Kostis) <lakostis> |
Status: | CLOSED NOTABUG | QA Contact: | qa-sisyphus |
Severity: | normal | ||
Priority: | P3 | CC: | glebfm, iv, ohotamax |
Version: | unstable | ||
Hardware: | x86_64 | ||
OS: | Linux |
Description
Vitaly Chikunov
2018-06-13 01:15:35 MSK
ИМХО clang работает as designed. Директива #include_next ищет файл *дальше* по списку include directories. Когда компиляция завершается ошибкой, порядок инклюдов такой: #include <...> search starts here: /usr/include /usr/bin/../lib64/gcc/x86_64-alt-linux/7/../../../../include/c++/7 /usr/bin/../lib64/gcc/x86_64-alt-linux/7/../../../../include/c++/7/x86_64-alt-linux /usr/bin/../lib64/gcc/x86_64-alt-linux/7/../../../../include/c++/7/backward /usr/local/include /usr/lib64/clang/6.0.0/include Если удалить из коммандной строкии `-isystem /usr/include`, то порядок такой: #include <...> search starts here: /usr/bin/../lib64/gcc/x86_64-alt-linux/7/../../../../include/c++/7 /usr/bin/../lib64/gcc/x86_64-alt-linux/7/../../../../include/c++/7/x86_64-alt-linux /usr/bin/../lib64/gcc/x86_64-alt-linux/7/../../../../include/c++/7/backward /usr/local/include /usr/lib64/clang/6.0.0/include /usr/include Здесь /usr/include находится после /usr/include/c++/7/, и #include_next проходит. Так что похоже тут неправ cmake, собирающий bcc. Скорее всего "ошибка" в clang связанная с `"ignoring duplicate directory "/usr/include"` - удалился второй, который должен был обработаться после `include/c++/7`, а когда я удалил `-isystem /usr/include` остался только второй стоящий позже в путях. (In reply to comment #2) > Скорее всего "ошибка" в clang связанная с `"ignoring duplicate directory > "/usr/include"` - удалился второй, который должен был обработаться после > `include/c++/7`, а когда я удалил `-isystem /usr/include` остался только второй > стоящий позже в путях. У вас есть простой пример как это воспроизвести? Нет. I've found the root cause of this issue. I'll describe my setup: * libyaml-cpp-dev * package1 * package2 Those three packages are dependent on each other, in other words package1 needs headers of libyaml and package2 needs package1 and therefore libyaml headers as well. libyaml: /usr/lib/x86_64-linux-gnu/cmake/yaml-cpp/yaml-cpp-config-version.cmake : set(PACKAGE_VERSION "0.5.2") Then for, some reason, I used ${YAML_CPP_INCLUDE_DIR} in package1, that is set in yaml-cpp-config.cmake: set(YAML_CPP_INCLUDE_DIR "${YAML_CPP_CMAKE_DIR}/../../../../include") And it was like: target_include_directories(package1_target PUBLIC ${YAML_CPP_INCLUDE_DIR}) In package2 I used target_link_libraries(package2_target package1_target) And now we have the described problem with missing stdlib.h when we try to build package2 From now on I'll be talking about package2. If we take a look at compile_commands.json we can see: "command": "/usr/bin/clang++-6.0 -DBOOST_CB_DISABLE_DEBUG -isystem /usr/lib/x86_64-linux-gnu/cmake/yaml-cpp/../../../../include -std=gnu++14 -o CMakeFiles/main.cpp.o -c /home/user/package1/src/main.cpp" And this is the problem. If we try to run clang++-6.0 with the same parameters, we'll get the same result. Removing this -isystem does the job. So the solution was to replace include of ${YAML_CPP_INCLUDE_DIR} in package1 with just target_link_libraries(package1_target PUBLIC yaml-cpp) Hope it helps. |