Skip to contentSkip to conversation

configure: fix breakage of --extra-{cflags, ldflags}

PATCH In review Nathan Froyd 2 participants 6 messages Jul 23, 2009 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: fix breakage of --extra-{cflags, ldflags}

Commit e3fc14c3a1a77a1cda669a3e16f1f6b82577e4ec broke the use of --extra-{cflags,ldflags} in the case where those flags were necessary for bits of configure to succeed. For instance, if you did:

  configure [...] --extra-cflags=-I/path/to/zlib/headers \
    --extra-ldflags=-L/path/to/zlib/libraries

prior to the above commit, the paths would go into CFLAGS and LDFLAGS for use by the rest of the configure tests. After the above commit, that's no longer true, because the EXTRA_{CFLAGS,LDFLAGS} variables are only used for creating makefiles.

Fixed by making sure that EXTRA_{CFLAGS,LDFLAGS} find their way into {CFLAGS,LDFLAGS}, respectively.

---
 configure |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
configure +2 -2
index 0db885b..dd2b1d9 100755
@@ -520,8 +520,8 @@ CFLAGS="$CFLAGS -g -fno-strict-aliasing"
 if test "$debug" = "no" ; then
   CFLAGS="$CFLAGS -O2"
 fi
-CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
-LDFLAGS="$LDFLAGS -g"
+CFLAGS="$CFLAGS $EXTRA_CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
+LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS -g"
 
 # Consult white-list to determine whether to enable werror
 # by default.  Only enable by default for git builds
Signature · 1 line
1.6.2.4
#1 lore raw
Quoted 11 lines · Nathan Froyd

Commit e3fc14c3a1a77a1cda669a3e16f1f6b82577e4ec broke the use of --extra-{cflags,ldflags} in the case where those flags were necessary for bits of configure to succeed. For instance, if you did:

  configure [...] --extra-cflags=-I/path/to/zlib/headers \
    --extra-ldflags=-L/path/to/zlib/libraries

prior to the above commit, the paths would go into CFLAGS and LDFLAGS for use by the rest of the configure tests. After the above commit, that's no longer true, because the EXTRA_{CFLAGS,LDFLAGS} variables are only used for creating makefiles.

Yep, that's true...

Quoted 14 lines

Fixed by making sure that EXTRA_{CFLAGS,LDFLAGS} find their way into {CFLAGS,LDFLAGS}, respectively.

---
 configure |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
configure +0 -0
index 0db885b..dd2b1d9 100755

configure CFLAGS="$CFLAGS -g -fno-strict-aliasing" · line 524

Quoted 7 lines
configure +2 -2
@@ -520,8 +520,8 @@ CFLAGS="$CFLAGS -g -fno-strict-aliasing"
 if test "$debug" = "no" ; then
   CFLAGS="$CFLAGS -O2"
 fi
-CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
-LDFLAGS="$LDFLAGS -g"
+CFLAGS="$CFLAGS $EXTRA_CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
+LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS -g"

...but now we add the extra flags twice. So please remove the injection into the flags for $config_mak.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#3 lore raw
In reply to a message not in the archive
Quoted 38 lines · Juan Quintela
Quoted 22 lines · Jan Kiszka
Quoted 11 lines · Nathan Froyd

Commit e3fc14c3a1a77a1cda669a3e16f1f6b82577e4ec broke the use of --extra-{cflags,ldflags} in the case where those flags were necessary for bits of configure to succeed. For instance, if you did:

  configure [...] --extra-cflags=-I/path/to/zlib/headers \
    --extra-ldflags=-L/path/to/zlib/libraries

prior to the above commit, the paths would go into CFLAGS and LDFLAGS for use by the rest of the configure tests. After the above commit, that's no longer true, because the EXTRA_{CFLAGS,LDFLAGS} variables are only used for creating makefiles.

Yep, that's true...

Quoted 8 lines

Fixed by making sure that EXTRA_{CFLAGS,LDFLAGS} find their way into {CFLAGS,LDFLAGS}, respectively.

---
 configure |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Quoted 14 lines

configure CFLAGS="$CFLAGS -g -fno-strict-aliasing" · line 524

Quoted 12 lines
configure +2 -2
index 0db885b..dd2b1d9 100755
@@ -520,8 +520,8 @@ CFLAGS="$CFLAGS -g -fno-strict-aliasing"
 if test "$debug" = "no" ; then
   CFLAGS="$CFLAGS -O2"
 fi
-CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
-LDFLAGS="$LDFLAGS -g"
+CFLAGS="$CFLAGS $EXTRA_CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
+LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS -g"

...but now we add the extra flags twice. So please remove the injection into the flags for $config_mak.

Quoted 1 line

It is still broken. Thinking of a solution.

Good that someone is more awake than /me. :)

Quoted 4 lines

People wanted EXTRA_CFLAGS to be added at the end of CFLAGS, not in the middle. Trying to find a way that is consistent for everything.

Could you told in what test do you need extra_cflags?

I think the only consistent solution (besides stopping to re-invent autotools) is explicitly appending EXTRA_CFLAGS to all tests.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#4 lore raw
In reply to a message not in the archive
Quoted 9 lines · Juan Quintela
Quoted 7 lines · Jan Kiszka

configure CFLAGS="$CFLAGS -g -fno-strict-aliasing" · line 524

Quoted 4 lines
configure +2 -2
-CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
-LDFLAGS="$LDFLAGS -g"
+CFLAGS="$CFLAGS $EXTRA_CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
+LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS -g"

...but now we add the extra flags twice. So please remove the injection into the flags for $config_mak.

Quoted 5 lines

It is still broken. Thinking of a solution.
People wanted EXTRA_CFLAGS to be added at the end of CFLAGS, not in the middle. Trying to find a way that is consistent for everything.

Could you told in what test do you need extra_cflags?

The particular instance was for detecting zlib in a cross configuration. But that's not necessarily the only test where --extra-{cflags,ldflags} would be useful: every test that needs external libraries is subject to this bug (zlib, TLS, SASL, SDL, VDE libraries, BrlAPI?, Xen?, bluez?, etc.).

If adding EXTRA_{CFLAGS,LDFLAGS} to all such tests is necessary and people feel that's the best solution, then I can do that.

-Nathan

#6 lore raw
In reply to a message not in the archive
Quoted 40 lines · Juan Quintela
Quoted 13 lines · Nathan Froyd
Quoted 7 lines · Juan Quintela
Quoted 6 lines · Jan Kiszka

configure CFLAGS="$CFLAGS -g -fno-strict-aliasing" · line 524

Quoted 4 lines
configure +2 -2
-CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
-LDFLAGS="$LDFLAGS -g"
+CFLAGS="$CFLAGS $EXTRA_CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
+LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS -g"

...but now we add the extra flags twice. So please remove the injection into the flags for $config_mak.

Quoted 5 lines

It is still broken. Thinking of a solution.
People wanted EXTRA_CFLAGS to be added at the end of CFLAGS, not in the middle. Trying to find a way that is consistent for everything.

Could you told in what test do you need extra_cflags?

Quoted 8 lines

The particular instance was for detecting zlib in a cross configuration. But that's not necessarily the only test where --extra-{cflags,ldflags} would be useful: every test that needs external libraries is subject to this bug (zlib, TLS, SASL, SDL, VDE libraries, BrlAPI?, Xen?, bluez?, etc.).

If adding EXTRA_{CFLAGS,LDFLAGS} to all such tests is necessary and people feel that's the best solution, then I can do that.

I think that the solution is the other way around :)

call configure with:

CFLAGS="foo bar" ./configure

and use CFLAGS for all configure script

That was what I had in mind.

If we do always in configure:

CFLAGS="baz goo $CFLAGS"

We also maintain the propierte that whatever you pass to CFLAGS is the last option in CFLAG (i.e. can overwrote whatever found by configure.

Quoted 6 lines

Then we can:
- kill extra cflags,
- win your feature,
- and have user wrote at the end of CFLAGS variable

What do you think?

No concerns. My only additional requirement is that configure should not forget about the provided CFLAGS when going through automatic reconfig, just like it's currently the case with --extra-* - and like autoconf behaves, too.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#7 lore raw
In reply to Nathan Froyd
Quoted 9 lines · Nathan Froyd

Commit e3fc14c3a1a77a1cda669a3e16f1f6b82577e4ec broke the use of --extra-{cflags,ldflags} in the case where those flags were necessary for bits of configure to succeed. For instance, if you did:

  configure [...] --extra-cflags=-I/path/to/zlib/headers \
    --extra-ldflags=-L/path/to/zlib/libraries

prior to the above commit, the paths would go into CFLAGS and LDFLAGS for use by the rest of the configure tests.

I spoke too soon; it turns out that the use of CFLAGS in the zlib configure test is a local patch we have to QEMU. So this is not an issue for upstream QEMU at the moment.

It does raise the question of how configure is supposed to find things in non-standard locations, but since none of the other configure tests seem to care about non-standard compilation scenarios (e.g. using --extra-* to specify the location of the SASL libraries won't work)...this is probably not worth addressing unless people feel it's worthwhile for the sake of Truth and Beauty.

Sorry about the noise.

-Nathan