Tarpaulin: note: cc: error: unrecognized command line option ‘-no-pie’

Created on 21 Jul 2017  ·  10Comments  ·  Source: xd009642/tarpaulin

Getting the error note: cc: error: unrecognized command line option ‘-no-pie’ when trying to run tarpaulin on combine.

Googling the error gives one mention of it being -fno-pie https://github.com/iovisor/bcc/commit/9da21f9e4a84eb8006be597ce74389442e9b3c08 but I don't have any other insight into what the cause is.

https://travis-ci.org/Marwes/combine/jobs/255933693

Most helpful comment

Ok, so here's my hunch which has been supported from what I have seen so far. Builds of gcc that don't have the --enable-default-pie flag set at compile time because they are too old or have the --disable-default-pie flag just don't have the -no-pie linker flag (which is just silly, honestly). This happens on Ubuntu systems before they enabled PIE by default and, evidently, Gentoo systems.

So, the nice, simple fix is to query gcc to see if it had the --enable-default-pie flag set at compile time, and if so enable the -no-pie flag. Now, the only problem is if someone passes a custom linker that isn't gcc, because then we would be back where we started just coming at it from another angle. I'll have to look into if we can tell which linker has been passed to rustc.

All 10 comments

What distro are you seeing this on? Also, could you post the output of cc --version?

Lastly, can you post the output of cc -Q -v?

Thank you!

Hello

I see the same problem, so I can probably provide the info too. I'm on gentoo (no version ‒ gentoo has rolling releases).

$ cc --version
gcc (Gentoo 6.3.0 p1.0) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cc -Q -v
gcc (Gentoo 6.3.0 p1.0) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/6.3.0/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/6.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-6.3.0/work/gcc-6.3.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/6.3.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.3.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.3.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.3.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/6.3.0/python --enable-objc-gc --enable-languages=c,c++,objc,obj-c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 6.3.0 p1.0' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libcilkrts --disable-libmpx --enable-vtable-verify --enable-libvtv --enable-lto --with-isl --disable-isl-version-check --enable-libsanitizer --disable-default-pie --enable-default-ssp
Thread model: posix
gcc version 6.3.0 (Gentoo 6.3.0 p1.0)

Running on travis with trusty as the os (since cmake was out of date with the default)
https://travis-ci.org/Marwes/combine/jobs/256316706

cc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

Copyright (C) 2013 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Using built-in specs.

COLLECT_GCC=cc

COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper

Target: x86_64-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

Thread model: posix

gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 

Ok, so here's my hunch which has been supported from what I have seen so far. Builds of gcc that don't have the --enable-default-pie flag set at compile time because they are too old or have the --disable-default-pie flag just don't have the -no-pie linker flag (which is just silly, honestly). This happens on Ubuntu systems before they enabled PIE by default and, evidently, Gentoo systems.

So, the nice, simple fix is to query gcc to see if it had the --enable-default-pie flag set at compile time, and if so enable the -no-pie flag. Now, the only problem is if someone passes a custom linker that isn't gcc, because then we would be back where we started just coming at it from another angle. I'll have to look into if we can tell which linker has been passed to rustc.

It seems the solution that would work on the most systems is if tarpaulin could detect if it was running code which had been built with pie and report an error to the user and some guidance on what to export to their RUSTFLAGS in order to resolve the problem.

I'd prefer a solution that doesn't involve this sort of fiddling around just to keep tarpaulin easy to use out of the box. So probably detecting if the linker is gcc and if it is applying the flag correctly, otherwise warning the user that they may need to set their linker flags. Anyone who's chosen a non-default linker should hopefully know it well enough to resolve any issues.

I've gone for the first approach I mentioned in a189289d5db977ac87fdae52393e013235dbc85b, this is just to get tarpaulin working for the most users now while alternative solutions are considered. Any thoughts are welcome :)

Sounds good.

It is all working now 👍 .

Only nit is that some of the test functions seem to have coverage reporting a bit strangely as the line with the closing brace is marked red, but that may not have anything to do with tarpaulin? https://coveralls.io/builds/12511148/source?filename=src%2Fchar.rs#L280

Yeah I'm aware of that issue already, that effects everyone though I'm not yet sure why or how to fix it.

Was this page helpful?
0 / 5 - 0 ratings