Coder Social home page Coder Social logo

Comments (3)

wsmoses avatar wsmoses commented on July 3, 2024

Hm that looks like the linker didn't find your main function for some reason. Mind sharing the whole code which fails?

from enzyme.

jpmedinagl avatar jpmedinagl commented on July 3, 2024

We were originally building the test files outside of the Enzyme library. However we're currently trying inside the Enzyme/enzyme/test/test_find_package folder. Trying to build the enzyme_test_2 executable (we removed the enzyme_test_1 executable due to errors with Clang). We just want to test (and compile) the main.c source file to see if __enzyme_autodiff works.

In that folder, we tried building the executable with

cmake -DEnzyme_DIR=/u/jpmedina/Enzyme/enzyme/build .

This was successful

But then when we type make
we get the same error again

[ 50%] Building C object CMakeFiles/enzyme_test_2.dir/main.c.o
[100%] Linking C executable enzyme_test_2
ld.lld: error: undefined symbol: main
>>> referenced by /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o:(_start)
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/enzyme_test_2.dir/build.make:97: enzyme_test_2] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/enzyme_test_2.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

For reference:
The code in /Enzyme/enzyme/test/test_find_package/CMakeLists.txt

cmake_minimum_required(VERSION 3.16)

project(enzyme_consumer LANGUAGES C)

find_package(Enzyme REQUIRED CONFIG NO_DEFAULT_PATH)
message("found dir ${Enzyme_DIR}")
message("found ${Enzyme_FOUND}")
get_property(importTargetsAfter DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
message("imported targets ${importTargetsAfter}")

#add_subdirectory(${Enzyme_DIR} ${PROJECT_SOURCE_DIR}/build/enzyme)

#add_executable(enzyme_test_1 main.c)
#target_link_libraries(enzyme_test_1 PUBLIC ClangEnzymeFlags)

add_executable(enzyme_test_2 main.c)
target_compile_definitions(enzyme_test_2 PUBLIC -DNOVERSION)
target_link_libraries(enzyme_test_2 PUBLIC LLDEnzymeFlags)

The code for /Enzyme/enzyme/test/test_find_package/main.c

int printf(const char*, ...);

extern double __enzyme_autodiff(void*, double);

double square(double x) {
  return x * x;
}

double dsquare(double x) {
  return __enzyme_autodiff((void*) square, x);
}

int main() {
  for(double i=1; i<5; i++) {
    printf("%f %f\n", square(i), dsquare(i));
  }
#ifndef NOVERSION
  printf("Enzyme version %d %d %d\n", ENZYME_VERSION_MAJOR, ENZYME_VERSION_MINOR, ENZYME_VERSION_PATCH);
#endif
}

from enzyme.

jpmedinagl avatar jpmedinagl commented on July 3, 2024

@wsmoses

We realized that we were unintentionally using gcc instead of clang.

Would it be possible to recognize this and throw and error to the user?

from enzyme.

Related Issues (20)

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.