Discussion:
"C compiler cannot create executables" with CFLAGS="-Wl, -z, noexecstack"
Jeffrey Walton
2013-09-18 02:57:49 UTC
Permalink
I'm working with a project that uses auto tools. The project's posture
is a tad bit weak, so I want to add some additional flags and options
to harden it. The folks at the project told me to add my flags and
options to CFLAGS and CXXFLAGS.

It looks like autoconf is failing as shown below. When I look at the
log and then the line number, I see the following:

{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "C compiler cannot create executables
See \`config.log' for more details" "$LINENO" 5; }

It appears a linker flag passed through the compiler driver was
consumed by the assembler.

What is the recommended way to work around this issue?

Jeff

$ export CFLAGS="-Wall -Wextra -Wconversion -Wstrict-overflow
-Wtrampoline -Wl,-z,noexecstack -Wl,-z,noexecheap -Wl,-z,relro
-Wl,-z,now -fPIE -pie -fstack-protector-all -DFORTIFY_SOURCES=2"
$ export CXXFLAGS="$CFLAGS"
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... cfgaux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/jwalton/squid-3.3.9':
configure: error: C compiler cannot create executables
See `config.log' for more details
Paul Eggert
2013-09-18 03:37:15 UTC
Permalink
Post by Jeffrey Walton
What is the recommended way to work around this issue?
I'd look at config.log. Possibly it's telling
you that you shouldn't have spaces after those commas.
Jeffrey Walton
2013-09-18 03:51:23 UTC
Permalink
Post by Paul Eggert
Post by Jeffrey Walton
What is the recommended way to work around this issue?
I'd look at config.log. Possibly it's telling
you that you shouldn't have spaces after those commas.
Thanks Paul.

There was not much there:

< test program used >
...
configure:4816: error: in `/home/jeffrey/squid-3.3.9':
configure:4818: error: C compiler cannot create executables
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_env_CCC_set=
ac_cv_env_CCC_value=
...
Eric Blake
2013-09-18 14:08:01 UTC
Permalink
Post by Jeffrey Walton
Post by Paul Eggert
Post by Jeffrey Walton
What is the recommended way to work around this issue?
I'd look at config.log. Possibly it's telling
you that you shouldn't have spaces after those commas.
Thanks Paul.
< test program used >
...
configure:4818: error: C compiler cannot create executables
See `config.log' for more details
You snipped too much - generally, config.log lists what command line it
tried, and what stderr reported, prior to listing the <test program
used> that failed.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Loading...