Bug 12596

Summary: configure setting --with-libiconv-prefix doesn't get passed to gcc-subdir
Product: gcc Reporter: Pietu Pohjalainen <ppohja>
Component: bootstrapAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: artem, dhazeghi, egallager, gcc-bugs, iains, lindsayd, pinskia
Priority: P2 Keywords: build
Version: 3.4.0   
Target Milestone: ---   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78251
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54304
Host: i386-unknown-freebsd4.8 Target: i386-unknown-freebsd4.8
Build: i386-unknown-freebsd4.8 Known to work:
Known to fail: Last reconfirmed: 2005-12-25 15:33:08

Description Pietu Pohjalainen 2003-10-13 13:14:13 UTC
Telling the configure to use some dir for finding libiconv libraries and 
headers doesn't get passed to the gcc-subdir. This causes the HAVE_ICONV flag 
to be set there, but the compilation doesn't find the needed headers (see the 
attached error message).

Manually adding the wanted directory (/usr/local/include) to the INCLUDES in 
gcc/Makefile allows the compilation to be continued.

The compilation fails as follows:
--- clip ---
gcc   -g  -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-
prototypes -pedantic -Wno-long-long -fno-common   -DHAVE_CONFIG_H    -I. -I. -
I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../intl \
  -DGCC_INCLUDE_DIR=\"/home/ppohja/gcc/lib/gcc/i386-unknown-
freebsd4.8/3.4/include\" -
DGPLUSPLUS_INCLUDE_DIR=\"/home/ppohja/gcc/lib/gcc/i386-unknown-
freebsd4.8/3.4/../../../..`echo /home/ppohja/gcc | sed -
e 's|^/home/ppohja/gcc||' -e 's|/[^/]*|/..|g'`/include/c++/3.4\" -
DGPLUSPLUS_TOOL_INCLUDE_DIR=\"/home/ppohja/gcc/lib/gcc/i386-unknown-
freebsd4.8/3.4/../../../..`echo /home/ppohja/gcc | sed -
e 's|^/home/ppohja/gcc||' -e 's|/[^/]*|/..|g'`/include/c++/3.4/i386-unknown-
freebsd4.8\" -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"/home/ppohja/gcc/lib/gcc/i386-
unknown-freebsd4.8/3.4/../../../..`echo /home/ppohja/gcc | sed -
e 's|^/home/ppohja/gcc||' -e 's|/[^/]*|/..|g'`/include/c++/3.4/backward\" -
DLOCAL_INCLUDE_DIR=\"/usr/local/include\" -
DCROSS_INCLUDE_DIR=\"/home/ppohja/gcc/lib/gcc/i386-unknown-
freebsd4.8/3.4/../../../../i386-unknown-freebsd4.8/sys-include\" -
DTOOL_INCLUDE_DIR=\"/home/ppohja/gcc/lib/gcc/i386-unknown-
freebsd4.8/3.4/../../../../i386-unknown-freebsd4.8/include\"  \
  -c ../../gcc/gcc/cppdefault.c -o cppdefault.o
gcc -c   -g  -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-
prototypes -pedantic -Wno-long-long -fno-common   -DHAVE_CONFIG_H    -I. -I. -
I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -
I../intl ../../gcc/gcc/c-ppoutput.c -o c-ppoutput.o
In file included from ../../gcc/gcc/c-ppoutput.c:25:
../../gcc/gcc/cpphash.h:29: iconv.h: No such file or directory
gmake[2]: *** [c-ppoutput.o] Error 1
gmake[2]: Leaving directory `/usr/home/ppohja/compile/objdir/gcc'
gmake[1]: *** [stage1_build] Error 2
gmake[1]: Leaving directory `/usr/home/ppohja/compile/objdir/gcc'
gmake: *** [bootstrap] Error 2
gmake bootstrap  0.44s user 0.48s system 107% cpu 0.847 total
Comment 1 Dara Hazeghi 2003-11-08 21:12:01 UTC
Just to clarify: using --with-libiconv-prefix=/usr/local doesn't cause
-I/usr/local/include to be appended to the include flags?
Comment 2 Dara Hazeghi 2004-01-17 23:20:23 UTC
Reminder, this bug is still awaiting feedback. Does /usr/local appear in any of your include paths 
(can grep through Makefiles to find out...). Thanks.
Comment 3 Andrew Pinski 2004-02-27 15:54:29 UTC
We know what he wants already, so changing it to NEW.
Comment 4 Andrew Pinski 2004-03-04 16:17:40 UTC
*** Bug 14431 has been marked as a duplicate of this bug. ***
Comment 5 Artem A. Kozarezov 2004-03-04 16:41:35 UTC
Situation in "Bug 14431" is different: configure ignores 
"--with-libiconv-prefix=/usr/local" and HAVE_ICONV is left undefined. 
Compilation passes, but almost all charset conversions are crippled.
Comment 6 Artem A. Kozarezov 2004-03-04 17:52:22 UTC
> Does /usr/local appear in any of your include paths 
> (can grep through Makefiles to find out...). Thanks.

FreeBSD 5.1-RELEASE-p11

gcc-3.4-20040303

../configure --prefix=/usr/local/gcc-20040303-2 --disable-nls 
--enable-languages=c,c++,java --disable-java-awt --without-x --enable-threads 
--enable-sjlj-exceptions --with-libiconv-prefix=/usr/local

For me the answer is positive.
(Although it does not relate with iconv detection problem, IMO).

gcc/Makefile:
CPPFLAGS =  -I/usr/local/include

intl/Makefile:
CPPFLAGS = -I/usr/local/include

i386-unknown-freebsd5.1/libjava/libltdl/Makefile:
CPPFLAGS = -O2 -g -O2 -I/usr/local/include

i386-unknown-freebsd5.1/libjava/Makefile:
CPPFLAGS = -O2 -g -O2 -I/usr/local/include

...
Comment 7 Artem A. Kozarezov 2004-03-12 08:27:43 UTC
I recently tried to build GCC on FreeBSD-5.2.1 (and with fresh 
autoconf/automake). GCC is "gcc-3.4-20040303".

I have libiconv-1.9.1 port installed (in /usr/local, that is).

Configured with: ../configure --prefix=/usr/local/gcc-20040303-4 --disable-nls 
--enable-languages=c,c++,java --disable-java-awt --without-x 
--enable-threads=posix --with-libiconv-prefix=/usr/local --with-dwarf2

Here is what I see:

intl/config.h - HAVE_ICONV defined!
i386-unknown-freebsd5.2.1/libstdc++-v3/config.h - HAVE_ICONV is not defined.
i386-unknown-freebsd5.2.1/libjava/include/config.h - HAVE_ICONV is not defined.

8<----------------------->8
...
Configuring in libiberty
...
checking for iconv... yes
checking how to link with libiconv... /usr/local/lib/libiconv.so -rpath 
/usr/local/lib                 
checking for iconv declaration...
         extern size_t iconv (iconv_t cd, const char * *inbuf, size_t 
*inbytesleft, char * *outbuf, size_t *outbytesleft);
...
Configuring in gcc
...
checking for iconv.h... yes
checking for iconv... no, consider installing GNU libiconv
...
Configuring in i386-unknown-freebsd5.2.1/libstdc++-v3
...
checking iconv.h usability... yes
checking iconv.h presence... yes
checking for iconv.h... yes
checking langinfo.h usability... yes   
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking for iconv in -liconv... no
checking for iconv_open... no
checking for iconv_close... no
checking for iconv... no
checking for nl_langinfo... yes
...
Configuring in i386-unknown-freebsd5.2.1/zlib
...
checking for iconv... no, consider installing GNU libiconv
8<----------------------->8

Here is "i386-unknown-freebsd5.2.1/libjava/config.log":
8<----------------------->8
configure:5272: checking for iconv
configure:5290: /usr/home/artem/gcj/t1/gcc-3.4-20040303/o/gcc/xgcc 
-B/usr/home/artem/gcj/t1/gcc-3.4-20040303/o/
/var/tmp//ccG5l3Eo.o: In function `main':
/usr/home/artem/gcj/t1/gcc-3.4-20040303/o/i386-unknown-freebsd5.2.
1/libjava/configure:5284: undefined reference
/usr/home/artem/gcj/t1/gcc-3.4-20040303/o/i386-unknown-freebsd5.2.
1/libjava/configure:5285: undefined reference
/usr/home/artem/gcj/t1/gcc-3.4-20040303/o/i386-unknown-freebsd5.2.
1/libjava/configure:5286: undefined reference
collect2: ld returned 1 exit status
configure: failed program was:
#line 5280 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <iconv.h>
int main() {
iconv_t cd = iconv_open("","");
       iconv(cd,NULL,NULL,NULL,NULL);
       iconv_close(cd);
; return 0; }
configure:5312: /usr/home/artem/gcj/t1/gcc-3.4-20040303/o/gcc/xgcc 
-B/usr/home/artem/gcj/t1/gcc-3.4-20040303/o/
/usr/bin/ld: cannot find -liconv
collect2: ld returned 1 exit status
configure: failed program was:
#line 5302 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <iconv.h>
int main() {
iconv_t cd = iconv_open("","");
         iconv(cd,NULL,NULL,NULL,NULL);
         iconv_close(cd);
; return 0; }
8<----------------------->8

Trying it by hands:
8<----------------------->8
artem@vg:/tmp/$ cat > test.c              
#line 5280 "configure"

#include <stdlib.h>
#include <iconv.h>
int main() {
iconv_t cd = iconv_open("","");
       iconv(cd,NULL,NULL,NULL,NULL);
       iconv_close(cd);
; return 0; }
artem@vg:/tmp/$ gcc test.c -o test -liconv
/usr/bin/ld: cannot find -liconv
collect2: ld returned 1 exit status
artem@vg:/tmp/$ gcc test.c -o test -liconv -L/usr/local/lib
artem@vg:/tmp/$ ldd test
test:
        libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x28073000)
        libc.so.5 => /lib/libc.so.5 (0x28162000)
8<----------------------->8

It seems the real problem is that gcc on FreeBSD does not include /usr/local/lib 
in linker search path by default.
Comment 8 Eric Gallager 2018-07-04 04:31:29 UTC
I think there's another bug open that's a duplicate of this one, but I can't remember which one right now... possibly bug 78251? Related at least.