Linking Example fails with LLD error:
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 26
Description
I have the following code copied from the c++ examples
```c++
int enzyme_out;
struct double2{ double x, y; };
double f(double x, double y) { return x * y + 1.0 / y; }
TEST(EnzymeTest, test_variables) {
double x = 3.0;
double y = 2.0;
auto [mu_x, mu_y] = __enzyme_autodiff((void*)f, enzyme_out, x, enzyme_out, y);
}
```
```
FAILED: /home/user/uni/inf_ma_sem5/lab/src/bin/khaki-test test/khaki-test[1]_tests.cmake /home/user/uni/inf_ma_sem5/lab/src/cmake-build-debug/test/khaki-test[1]_tests.cmake
: && /usr/bin/clang++ -g -fuse-ld=lld -Wl,-mllvm -Wl,-load=/home/user/uni/inf_ma_sem5/lab/src/cmake-build-debug/external/Enzyme/enzyme/Enzyme/LLDEnzyme-19.so -Wl,--load-pass-plugin=/home/user/uni/inf_ma_sem5/lab/src/cmake-build-debug/external/Enzyme/enzyme/Enzyme/LLDEnzyme-19.so -Xlinker --dependency-file=test/CMakeFiles/khaki-test.dir/link.d test/CMakeFiles/khaki-test.dir/enzymeTest.cpp.o test/CMakeFiles/khaki-test.dir/main.cpp.o test/CMakeFiles/khaki-test.dir/membrane.cpp.o test/CMakeFiles/khaki-test.dir/repulsive.cpp.o test/CMakeFiles/khaki-test.dir/splineTest.cpp.o -o /home/user/uni/inf_ma_sem5/lab/src/bin/khaki-test -Wl,-rpath,/home/user/uni/inf_ma_sem5/lab/src/cmake-build-debug/Build/lib libatcg_lib.a lib/libgtest.a external/glfw/src/libglfw3.a /usr/lib/librt.a -lm -ldl libimgui.a libimplot.a libglad.a /usr/lib/libGLX.so /usr/lib/libOpenGL.so Build/lib/libOpenMeshToolsd.so.11.0 Build/lib/libOpenMeshCored.so.11.0 -lginac && cd /home/user/uni/inf_ma_sem5/lab/src/cmake-build-debug/test && /usr/bin/cmake -D TEST_TARGET=khaki-test -D TEST_EXECUTABLE=/home/user/uni/inf_ma_sem5/lab/src/bin/khaki-test -D TEST_EXECUTOR= -D TEST_WORKING_DIR=/home/user/uni/inf_ma_sem5/lab/src/cmake-build-debug/test -D TEST_EXTRA_ARGS= -D TEST_PROPERTIES= -D TEST_PREFIX= -D TEST_SUFFIX= -D TEST_FILTER= -D NO_PRETTY_TYPES=FALSE -D NO_PRETTY_VALUES=FALSE -D TEST_LIST=khaki-test_TESTS -D CTEST_FILE=/home/user/uni/inf_ma_sem5/lab/src/cmake-build-debug/test/khaki-test[1]_tests.cmake -D TEST_DISCOVERY_TIMEOUT=5 -D TEST_DISCOVERY_EXTRA_ARGS= -D TEST_XML_OUTPUT_DIR= -P /usr/share/cmake/Modules/GoogleTestAddTests.cmake
```
This works if i let enzyme autodetect x, y to be Output arguments. If I explicitly add the enzyme_out parameter however, I get the following error:
```
ld.lld: error: test/enzymeTest.cpp:111:25: in function _ZN30EnzymeTest_test_variables_Test8TestBodyEv void (ptr): Enzyme: Cannot cast __enzyme_autodiff primal argument 1, found i32 0, type i32 (simplified to i32 0 ) - to arg 0, double
```
I have enzyme installed as a git submodule and add it to my project as follows:
```cmake
set(ENZYME_STATIC_LIB "true")
add_subdirectory(external/Enzyme/enzyme)
target_link_library(khaki PUBLIC LLDEnzymeFlags)
```
It seems to me that enzyme cannot detect and substitute the special names.
Contributor guide
Assessment
This issue has not been assessed yet.