Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
901 stars 98 forks source link

1.2.0 build failure with libclang-7 (possible c++17 wrt cmake includes?, possibly fixed on master) #513

Closed sten0 closed 5 years ago

sten0 commented 5 years ago

Hi Guillaume,

This bug report concerns irony-mode_1.2.0. The build appears to fail despite -std=c++11. I thought it might be possible that a cmake config needs to be updated after reading this [SOLVED] Can't Find C++ include file. The Debian bug asking to transition to libclang-7 is #912801. It's possible this is a Debian bug, a llvm-toolchain_7.0.1-rc3 bug, gcc_8.2 bug, a poor interaction between these, or something else.

Any hints would be very much appreciated! It's a bit over my head, and I don't anticipate having the time to get up to speed with new things until January. I haven't tested building master's HEAD yet, and March and April's commits look like they might fix this. So far the Debian package is adding GH-460 and GH-449. Ideally it would be nice to have a new tagged release in January ;-)

When compiling with Debian defaults, or with hardening+all (using gcc and linking against libclang) it fails like this:

Run Build Command:"/usr/bin/make" "cmTC_85b85/fast"
make[1]: Entering directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp'
/usr/bin/make -f CMakeFiles/cmTC_85b85.dir/build.make CMakeFiles/cmTC_85b85.dir/build
make[2]: Entering directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_85b85.dir/src.cxx.o
/usr/bin/c++    -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fno-exceptions -DHAS_CXX11_STDLIB -std=c++11   -o CMakeFiles/cmTC_85b85.dir/src.cxx.o -c /<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp/src.cxx
Linking CXX executable cmTC_85b85
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_85b85.dir/link.txt --verbose=1
/usr/bin/c++  -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fno-exceptions -DHAS_CXX11_STDLIB -std=c++11  -Wl,-z,relro  -rdynamic CMakeFiles/cmTC_85b85.dir/src.cxx.o  -o cmTC_85b85 
make[2]: Leaving directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp'
make[1]: Leaving directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp'

Source file was:
#include <random>

int main() {
    std::random_device rd;
    std::default_random_engine e(rd());
    std::uniform_int_distribution<int> dist(0, 15);

    return dist(e);
}

Full log for /\ available here: https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=912801;filename=irony-mode_1.2.0-7_amd64.build;msg=10

and when explicitly disabling all hardening features with hardening=-all (using gcc and linking against libclang) it fails like this:

Run Build Command:"/usr/bin/make" "cmTC_0a0d2/fast"
make[1]: Entering directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp'
/usr/bin/make -f CMakeFiles/cmTC_0a0d2.dir/build.make CMakeFiles/cmTC_0a0d2.dir/build
make[2]: Entering directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_0a0d2.dir/src.cxx.o
/usr/bin/c++    -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -specs=/usr/share/dpkg/no-pie-compile.specs -Wdate-time -fno-exceptions -DHAS_CXX11_STDLIB -std=c++11   -o CMakeFiles/cmTC_0a0d2.dir/src.cxx.o -c /<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp/src.cxx
Linking CXX executable cmTC_0a0d2
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0a0d2.dir/link.txt --verbose=1
/usr/bin/c++  -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -specs=/usr/share/dpkg/no-pie-compile.specs -Wdate-time -fno-exceptions -DHAS_CXX11_STDLIB -std=c++11  -specs=/usr/share/dpkg/no-pie-link.specs  -rdynamic CMakeFiles/cmTC_0a0d2.dir/src.cxx.o  -o cmTC_0a0d2 
make[2]: Leaving directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp'
make[1]: Leaving directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp'

Source file was:
#include <random>

int main() {
    std::random_device rd;
    std::default_random_engine e(rd());
    std::uniform_int_distribution<int> dist(0, 15);

    return dist(e);
}

        cd obj-x86_64-linux-gnu && tail -v -n \+0 CMakeFiles/CMakeError.log
==> CMakeFiles/CMakeError.log <==
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /usr/bin/cc 
Build flags: -g;-O2;-fdebug-prefix-map=/<<PKGBUILDDIR>>=.;-specs=/usr/share/dpkg/no-pie-compile.specs;-Wdate-time
Id flags:  

The output was:
1
/usr/bin/ld: /tmp/ccVeow3y.o: relocation R_X86_64_32S against symbol `info_version' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: /usr/bin/c++ 
Build flags: -g;-O2;-fdebug-prefix-map=/<<PKGBUILDDIR>>=.;-specs=/usr/share/dpkg/no-pie-compile.specs;-Wdate-time
Id flags:  

The output was:
1
/usr/bin/ld: /tmp/ccwBVoJG.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status

Full log is attached

irony-mode_1.2.0-7_amd64.build_nohardening.txt

Sarcasm commented 5 years ago

Hello,

I made a new release. I think the FindLibclang improvements that landed a while ago should fix the issue.

Let me know if that fixes the issue.

sten0 commented 5 years ago

Thank you for the quick reply and new release! A quick build of 1.3.1 seems to confirm that yes, those FindLibclang improvements did the trick. I still need to find time to run the more strict CI tests and manually test, but I expect them to pass too, so I'm closing this issue :-)