libtoml
libtoml copied to clipboard
Configure: error: C preprocessor "/lib/cpp" fails sanity check
Meta:
Edit: (Arch) Linux 3.15.8
Edit: glibc: 2.19
ragel 6.8
gcc 4.9.1
clang 3.4.2
autoconf 2.69
Issue:
Trying to build with ./configure --prefix=/usr
but this error is returned:
Configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "toml"
| #define PACKAGE_TARNAME "toml"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "toml 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
| Syntax error
configure:2798: error: in `/home/earnest/build/lab/libtoml/src/libtoml':
configure:2800: error: C preprocessor "/lib/cpp" fails sanity check
Since /lib/cpp
is not the correct path on my machine I tried adding CPP=/usr/bin/cpp ./configure --prefix=/usr
but the same error occured:
Configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "toml"
| #define PACKAGE_TARNAME "toml"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "toml 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
| Syntax error
configure:2798: error: in `/home/earnest/build/lab/libtoml/src/libtoml':
configure:2800: error: C preprocessor "/usr/bin/cpp" fails sanity check
What system are you building for? I don't see that problem on OSX or Fedora Linux. Looks to be an autotools problem.
This is Arch Linux, sorry. I forgot to add that to the meta information. Edit: Updated
Since the build system modifiers the environment here are some of them:
CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4
CHOST=x86_64-unknown-linux-gnu
MAKEFLAGS=-j4
CPPFLAGS=-D_FORTIFY_SOURCE=2
CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro
Edit: None of these seem to be the cause, each one unset doesn't. There is one more line of attack I can try but it's not something I'll enjoy doing. And that is removing a lot of hardening flags
I found that setting export CPP=/usr/bin/cpp
and unsetting CPPFLAGS
causes the check to pass but it is shortly followed by:
checking for clang... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking for ragel... yes
checking how to run the C preprocessor... /usr/bin/cpp
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
configure: creating ./config.status
config.status: creating Makefile
clang -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -O0 -I. -m64 -fPIC -c -o toml.o toml.c
ragel -G2 toml_parse.rl
clang -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -O0 -I. -m64 -fPIC -c -o main.o main.c
clang -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -O0 -I. -m64 -fPIC -c -o toml_parse.o toml_parse.c
ld -Bdynamic -shared toml.o toml_parse.o -o libtoml.so -Wl,-O1,--sort-common,--as-needed,-z,relro -L. -licuuc
/usr/bin/ld: unrecognized option '-Wl,-O1,--sort-common,--as-needed,-z,relro'
/usr/bin/ld: use the --help option for usage information
Makefile:30: recipe for target 'libtoml.so' failed
make: *** [libtoml.so] Error 1
it looks like your build system is setting those extra ldflags also.
Yes it is, as listed above: LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro
I've managed to "fix" this by unsetting CPPFLAGS
and LDFLAGS
along with fixing CPP
to point at /usr/bin/cpp/
but this honestly shouldn't be necessary. Will dig a little more
I'll just chime in and say that it seems to work for me manually, but not when running it through makepkg when it set CPPFLAGS=-D_FORTIFY_SOURCE=2
, unsetting CPPFLAGS makes it work tho.
The ld error has something to do with some part of the build process passing LDFLAGS to ld
directly, which is wrong. LDFLAGS is supposed to be passed to gcc/clang which should then pass it to the linker properly.
The trouble is those look like CFLAGS, not LDFLAGS. That's how you pass linker options to gcc, but here we're invoking ld directly.
They aren't linker options that are expected to be passed to ld directly tho. For one you can look at this Chromium issue. I can't really think of anything that expects LDFLAGS to be passable to ld directly anymore.
You can define CXXCPP OR CPP path. eg. ./configure CXXCPP=/usr/bin/cpp OR ./configure CPP=/usr/bin/cpp