[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CFLAGS containing quoted arguments to compiler does not work
From: |
(GalaxyMaster) |
Subject: |
CFLAGS containing quoted arguments to compiler does not work |
Date: |
Sat, 21 Jan 2023 03:35:23 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hello,
[I am not subscribed to the list, so if you need me to respond, please CC me on
your replies -- the following is a bug report]
I just stumbled upon this and decided to report it. There is a test on whether
C compiler works (actually, the test is in lang.m4 and is generic) and when
this test is running it fails on a perfectly acceptable command line for the C
compiler:
===
galaxy@apollo:~/autoconf-test $ ls -l
total 8
-rw-r--r-- 1 galaxy galaxy 19 Jan 21 02:41 configure.ac
-rw-r--r-- 1 galaxy galaxy 25 Jan 21 02:43 main.c
galaxy@apollo:~/autoconf-test $ cat configure.ac
AC_INIT
AC_PROG_CC
galaxy@apollo:~/autoconf-test $ cat main.c
int main() { return 0; }
galaxy@apollo:~/autoconf-test $ autoconf -f
/usr/share/autoconf/autoconf/trailer.m4:4: warning: AC_OUTPUT was never used
galaxy@apollo:~/autoconf-test $ export CFLAGS="-Dsomething='one two'"
galaxy@apollo:~/autoconf-test $ ./configure
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/galaxy/autoconf-test':
configure: error: C compiler cannot create executables
See `config.log' for more details
galaxy@apollo:~/autoconf-test $ gcc "$CFLAGS" -c main.c
galaxy@apollo:~/autoconf-test $ ls -l main.*
-rw-r--r-- 1 galaxy galaxy 25 Jan 21 02:43 main.c
-rw------- 1 galaxy galaxy 1080 Jan 21 02:51 main.o
galaxy@apollo:~/autoconf-test $
===
I believe it is due to not handling the CFLAGS variable with proper quotation,
since if we look into "config.log" we see:
===
configure:2586: gcc -Dsomething='one two' conftest.c >&5
<command-line>: warning: missing terminating ' character
/bin/ld: cannot find two': No such file or directory
collect2: error: ld returned 1 exit status
===
which can be easily replicated with bare gcc as:
===
galaxy@apollo:~/autoconf-test $ gcc $CFLAGS -c main.c
<command-line>: warning: missing terminating ' character
gcc: warning: two': linker input file unused because linking not done
gcc: error: two': linker input file not found: No such file or directory
galaxy@apollo:~/autoconf-test $
===
Interestingly enough, the "configure:2586: gcc -Dsomething='one two'
conftest.c >&5" line is misleading, since if that was the line executed it
would have succeeded:
===
galaxy@apollo:~/autoconf-test $ gcc -Dsomething='one two' main.c
galaxy@apollo:~/autoconf-test $
===
Unfortunately, my autoconf-fu is not that great to quickly identify the
culprit.
--
(GM)
- CFLAGS containing quoted arguments to compiler does not work,
(GalaxyMaster) <=