Git Product home page Git Product logo

cmake-template's People

Contributors

dependabot[bot] avatar tgymnich avatar zusez4 avatar

Watchers

 avatar  avatar  avatar

Forkers

zusez4

cmake-template's Issues

undefined symbol: _ZN5clang17ASTFrontendAction13ExecuteActionEv

I tried to run this template example using clang 16.0.6 (build from source) and the latest Enzyme.
The only modification to this template was removing the legacy-pm-flag.

โžœ  build git:(main) โœ— cmake .. -G Ninja -DEigen3_INCLUDE_DIR=/home/drehwald/.local/include/eigen3  -DCMAKE_BUILD_TYPE=Release -DEIGEN_USE_BLAS=1 -DCMAKE_INSTALL_PREFIX=/home/drehwald/.local  -DCMAKE_EXPORT_COMPILE_COMMANDS=YES
CMake Warning (dev) at /home/drehwald/prog/Enzyme/enzyme/buildDbg16/EnzymeTargets.cmake:49 (add_library):
  ADD_LIBRARY called with MODULE option but the target platform does not
  support dynamic linking.  Building a STATIC library instead.  This may lead
  to problems.
Call Stack (most recent call first):
  /home/drehwald/prog/Enzyme/enzyme/buildDbg16/EnzymeConfig.cmake:15 (include)
  CMakeLists.txt:3 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /home/drehwald/prog/Enzyme/enzyme/buildDbg16/EnzymeTargets.cmake:52 (add_library):
  ADD_LIBRARY called with MODULE option but the target platform does not
  support dynamic linking.  Building a STATIC library instead.  This may lead
  to problems.
Call Stack (most recent call first):
  /home/drehwald/prog/Enzyme/enzyme/buildDbg16/EnzymeConfig.cmake:15 (include)
  CMakeLists.txt:3 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /home/drehwald/prog/Enzyme/enzyme/buildDbg16/EnzymeTargets.cmake:66 (add_library):
  ADD_LIBRARY called with MODULE option but the target platform does not
  support dynamic linking.  Building a STATIC library instead.  This may lead
  to problems.
Call Stack (most recent call first):
  /home/drehwald/prog/Enzyme/enzyme/buildDbg16/EnzymeConfig.cmake:15 (include)
  CMakeLists.txt:3 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

LLVM Version: 16
Found LLVM at: /home/drehwald/prog/llvm-16/build
Found Enzyme at: /home/drehwald/prog/Enzyme/enzyme/buildDbg16/Enzyme/ClangEnzyme-16.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/drehwald/prog/CMake-Template/build
โžœ  build git:(main) โœ— ninja
[1/3] Building C object CMakeFiles/example.dir/myblas.c.o
clang-16: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
[2/3] Building C object CMakeFiles/example.dir/multisource.c.o
clang-16: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
[3/3] Linking C executable example
FAILED: example 
: && /home/drehwald/prog/llvm-16/build/bin/clang -fuse-ld=lld -flto -O3 -DNDEBUG -fuse-ld=lld -flto -Wl,-mllvm=-load=/home/drehwald/prog/Enzyme/enzyme/buildDbg16/Enzyme/ClangEnzyme-16.so CMakeFiles/example.dir/multisource.c.o CMakeFiles/example.dir/myblas.c.o -o example   && :
Error opening '/home/drehwald/prog/Enzyme/enzyme/buildDbg16/Enzyme/ClangEnzyme-16.so': /home/drehwald/prog/Enzyme/enzyme/buildDbg16/Enzyme/ClangEnzyme-16.so: undefined symbol: _ZN5clang17ASTFrontendAction13ExecuteActionEv
  -load request ignored.
ld.lld: error: undefined symbol: __enzyme_autodiff
>>> referenced by ld-temp.o
>>>               lto.tmp:(main)
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

@tgymnich I remember I was able to use this template in the past succesfully, but it's not working under clang-16 / the latest Enzyme anymore. I suspect it might be due to @wsmoses latests experiments to improve the c frontend and use the clang ast a bit more?

For context, I try to get the following repo to compile, with these small cmake adjustments: https://github.com/mherb/kalman

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b78acb9..2891400 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,14 @@
 cmake_minimum_required(VERSION 2.8)
+
+find_package(Enzyme REQUIRED)
+
+message("LLVM Version: " ${Enzyme_LLVM_VERSION_MAJOR})
+message("Found LLVM at: " ${Enzyme_LLVM_BINARY_DIR})
+
+# C and C++ Compilers can only be configured before project(...)
+set(CMAKE_C_COMPILER "${Enzyme_LLVM_BINARY_DIR}/bin/clang")
+set(CMAKE_CXX_COMPILER "${Enzyme_LLVM_BINARY_DIR}/bin/clang")
+
 project(Kalman CXX)
 
 # TODO: Use VERSION argument to project command after raising the minimum
@@ -16,8 +26,20 @@ option(KALMAN_BUILD_EXAMPLES "Build the Kalman examples" ON)
 
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")
 
+find_package(Enzyme REQUIRED COMPONENTS ClangEnzyme)
+
+get_target_property(ClangEnzyme ClangEnzyme-${Enzyme_LLVM_VERSION_MAJOR} LOCATION)
+
+message("Found Enzyme at: " ${ClangEnzyme})
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fuse-ld=lld -flto")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=lld -flto")
+set(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld -flto -Wl,-mllvm=-load=${ClangEnzyme}")
+set(CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld -flto -Wl,-mllvm=-load=${ClangEnzyme}")
+

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.