The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15547 ====================================================================== Reported By: Daniel Schepler Assigned To: ====================================================================== Project: CMake Issue ID: 15547 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2015-04-29 16:45 PDT Last Modified: 2015-04-29 16:45 PDT ====================================================================== Summary: Changing CMAKE_AR isn't reflected on regenerating build system Description: In our project, I ran into an issue that switching from non-LTO mode to LTO mode by adding -flto to CMAKE_C_FLAGS_RELEASE, and updating CMAKE_AR and CMAKE_RANLIB to the gcc lto wrappers, isn't successful. On running "make VERBOSE=1", it appears that the Makefiles are still running /usr/bin/ar to generate the intermediate static libraries.
Steps to Reproduce: dschepler@deb-dschepler:~/scalable-dev/cmake-flto$ tail -n +1 * ==> a.c <== int a(int n) { return n*n + 3; } ==> CMakeLists.txt <== cmake_minimum_required(VERSION 3.2) project(flto) add_library(a STATIC a.c) add_executable(main main.c) target_link_libraries(main a) ==> main.c <== #include <stdio.h> int a(int n); int main() { printf("a(5) = %d\n", a(5)); return 0; } dschepler@deb-dschepler:~/scalable-dev/cmake-flto$ mkdir build; cd build dschepler@deb-dschepler:~/scalable-dev/cmake-flto/build$ CC=gcc-5 cmake -DCMAKE_BUILD_TYPE:STRING=Release .. -- The C compiler identification is GNU 5.1.1 -- The CXX compiler identification is GNU 4.9.2 -- Check for working C compiler: /usr/bin/gcc-5 -- Check for working C compiler: /usr/bin/gcc-5 -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /home/dschepler/scalable-dev/cmake-flto/build dschepler@deb-dschepler:~/scalable-dev/cmake-flto/build$ make Scanning dependencies of target a [ 50%] Building C object CMakeFiles/a.dir/a.c.o Linking C static library liba.a [ 50%] Built target a Scanning dependencies of target main [100%] Building C object CMakeFiles/main.dir/main.c.o Linking C executable main [100%] Built target main dschepler@deb-dschepler:~/scalable-dev/cmake-flto/build$ cmake -DCMAKE_AR:PATH=/usr/bin/gcc-ar-5 -DCMAKE_RANLIB:PATH=/usr/bin/gcc-ranlib-5 -DCMAKE_C_FLAGS_RELEASE:STRING="-O3 -DNDEBUG -flto" . -- Configuring done -- Generating done -- Build files have been written to: /home/dschepler/scalable-dev/cmake-flto/build dschepler@deb-dschepler:~/scalable-dev/cmake-flto/build$ make [ 50%] Building C object CMakeFiles/a.dir/a.c.o Linking C static library liba.a BFD: CMakeFiles/a.dir/a.c.o: plugin needed to handle lto object BFD: a.c.o: plugin needed to handle lto object [ 50%] Built target a [100%] Building C object CMakeFiles/main.dir/main.c.o Linking C executable main /tmp/cc9dAt8D.ltrans0.ltrans.o: In function `main': <artificial>:(.text.startup+0xa): undefined reference to `a' collect2: error: ld returned 1 exit status CMakeFiles/main.dir/build.make:86: recipe for target 'main' failed make[2]: *** [main] Error 1 CMakeFiles/Makefile2:95: recipe for target 'CMakeFiles/main.dir/all' failed make[1]: *** [CMakeFiles/main.dir/all] Error 2 Makefile:75: recipe for target 'all' failed make: *** [all] Error 2 Additional Information: If the first configure includes the CMAKE_AR and CMAKE_RANLIB settings, then the build goes through successfully, and "make VERBOSE=1" shows about what I'd expect. It would be somewhat inconvenient to require completely wiping out the build directory to do the switch, though, as that would lose any other cache settings. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2015-04-29 16:45 Daniel ScheplerNew Issue ====================================================================== -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers