metacall / core

MetaCall: The ultimate polyglot programming experience.
https://metacall.io
Apache License 2.0
1.55k stars 160 forks source link

[BUG] Cannot find `backward.hpp` on MacOS #477

Closed FirePing32 closed 7 months ago

FirePing32 commented 8 months ago

šŸ› Bug Report

Building with cmake fails (at least for me) on MacOS. The backtrace plugin cannot find backward.hpp in the already passed include directories. https://github.com/metacall/core/blob/34b28423138e607b3b77a984566f941e141ada4b/source/plugins/backtrace_plugin/source/backtrace_plugin.cpp#L23

Expected Behavior

The backtrace plugin should be built successfully.

Current Behavior

Cmake fails when installing the backtrace plugin.

Possible Solution

Pass an argument to Cmake at build time to use additional include directories.

Steps to Reproduce

git clone https://github.com/metacall/core.git
mkdir core/build && cd core/build
cmake ..

sudo HOME="$HOME" cmake --build . --target install

Context (Environment)

Platform: Intel/AMD64 OS: MacOS 13.5

Logs

[ 97%] Linking CXX shared module ../../../libplugin_extension.so
[ 97%] Built target plugin_extension
[ 97%] Built target backtrace_plugin_config
[ 97%] Building CXX object source/plugins/backtrace_plugin/CMakeFiles/backtrace_plugin.dir/source/backtrace_plugin.cpp.o
/Users/prakhargurunani/dev/metacall-distributable-macos/metacall/core/source/plugins/backtrace_plugin/source/backtrace_plugin.cpp:23:10: fatal error: 'backward.hpp' file not found
#include <backward.hpp>
         ^~~~~~~~~~~~~~
1 error generated.
make[2]: *** [source/plugins/backtrace_plugin/CMakeFiles/backtrace_plugin.dir/source/backtrace_plugin.cpp.o] Error 1
make[1]: *** [source/plugins/backtrace_plugin/CMakeFiles/backtrace_plugin.dir/all] Error 2
make: *** [all] Error 2
+ error 'Cmake build target install failed.'
+ echo 'Error: Cmake build target install failed., build stopping, probably dependencies could not be downloaded.'
Error: Cmake build target install failed., build stopping, probably dependencies could not be downloaded.
+ exit 1
viferga commented 7 months ago

@FirePing32 do you have full logs of the cmake and make steps?

FirePing32 commented 7 months ago

@viferga was able to solve it by passing the /usr/local/include dir. First, I changed the cmake config -

diff --git a/source/plugins/backtrace_plugin/CMakeLists.txt b/source/plugins/backtrace_plugin/CMakeLists.txt
index 0789db78..2ed95f31 100644
--- a/source/plugins/backtrace_plugin/CMakeLists.txt
+++ b/source/plugins/backtrace_plugin/CMakeLists.txt
@@ -150,6 +150,11 @@ target_include_directories(${target}
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_CURRENT_BINARY_DIR}/include

+   # Using custom include directory for backward.hpp
+   if( DEFINED ${BACKTRACE_INCLUDE_PATH} )
+       ${BACKTRACE_INCLUDE_PATH}
+   endif()
+
    $<TARGET_PROPERTY:${META_PROJECT_NAME}::metacall,INCLUDE_DIRECTORIES> # MetaCall includes

    PUBLIC

Then build cmake with the -DBACKTRACE_INCLUDE_PATH flag.

viferga commented 7 months ago

I am not sure this workaround is valid. The backward.hpp dependency is downloaded automatically if it's not found, there should be a better way of solving it rather than manually installing it and then passing the include folder.

Probably this is a bug of the embedding of the project through CMake, we should investigate it further.

FirePing32 commented 7 months ago

@viferga The script was able to find backward.hpp on my system, but while compiling the backtrace plugin, it does not include the relevant directory (-I/usr/local/lib).

viferga commented 7 months ago

@FirePing32 let's see if these commits solves the issue: https://github.com/metacall/core/commit/6e2914726c018d708590309d51002a99c20e449f https://github.com/metacall/core/commit/cd3569104830b5f8d2076d2bfad8cf87c7b4a8dd

Can you test it again?

FirePing32 commented 7 months ago

@viferga Yeah sure. Will test it by 21:00 GMT+05:30

viferga commented 7 months ago

Thanks @FirePing32