Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Fri, 23 Oct 2015 00:31:09 +0200
From: Denys Vlasenko <vda.linux@...glemail.com>
To: musl <musl@...ts.openwall.com>, Rich Felker <dalias@...c.org>
Subject: Having hard time adding to CFLAGS

Let's say I need to add a gcc option to my musl build.

configure says:
...
Some influential environment variables:
  CC                      C compiler command [detected]
  CFLAGS                  C compiler flags [-Os -pipe ...]
  CROSS_COMPILE           prefix for cross compiler and tools [none]
  LIBCC                   compiler runtime library [detected

So I try this, combining all possible ways of passing CFLAGS
(past experience is that different projects do it differently).

CFLAGS is in environment, and on both configure and make
command lines:

export CFLAGS="-falign-functions=1"    # for example
./configure CFLAGS="$CFLAGS"
make CFLAGS="$CFLAGS"

It does work, but resulting libc.so is twice as big:
   text       data        bss        dec        hex    filename
 564099       1944      11768     577811      8d113    musl.1/lib/libc.so
 917805       2130      11736     931671      e3757    musl.2/lib/libc.so

The cause is that gcc invocation for each .c file in both cases start normally:

gcc -std=c99 -nostdinc -ffreestanding -fexcess-precision=standard
-frounding-math -D_XOPEN_SOURCE=700 -I./arch/x86_64 -I./src/internal
-I./include...

but then, build without explicit CFLAGS use this:

... -Os -pipe -fomit-frame-pointer -fno-unwind-tables
-fno-asynchronous-unwind-tables -Wa,--noexecstack
-Werror=implicit-function-declaration -Werror=implicit-int
-Werror=pointer-sign -Werror=pointer-arith -include vis.h  -fPIC
-DSHARED -c -o src/aio/aio.lo src/aio/aio.c

and one with CFLAGS loses these flags, in particular, it has no -Os
and no -fPIC:

... -falign-functions=1 -c -o src/aio/aio.o src/aio/aio.c

Evidently, my CFLAGS replaced needed flags instead of being added at the end.

Can this be fixed? If user needs to use e.g. EXTRA_CFLAGS instead,
please fix configure --help.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.