On 08/20/2016 11:22 AM, ayush goel wrote:

> So your concern seems valid, however the build process seems to pick
> the correct headers.

I tried it now and it does _not_ pick the correct headers.  My concern
is definitely valid.  More below.

> I did try to raise an error from the gnulib generated header unitstd.h
> and it gives me a compile time error:
> 
> --------------------------------------------------------------
> gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
>     -g -O2 -MT exitfail.o -MD -MP -MF .deps/exitfail.Tpo -c -o
> exitfail.o /Users/ayushgoel/gsoc/src/gnulib/import/exitfail.c
> gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
>     -g -O2 -MT unistd.o -MD -MP -MF .deps/unistd.Tpo -c -o unistd.o
> /Users/ayushgoel/gsoc/src/gnulib/import/unistd.c
> gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
>     -g -O2 -MT obstack.o -MD -MP -MF .deps/obstack.Tpo -c -o obstack.o
> /Users/ayushgoel/gsoc/src/gnulib/import/obstack.c
> In file included from /Users/ayushgoel/gsoc/src/gnulib/import/unistd.c:3:
> ./unistd.h:18:2: error: “Unistd header file being invoked"
> #error “unistd from gnulib being invoked"
>  ^

This is building _gnulib_ itself, which has its own configure/Makefile.

We're talking about gcc/Makefile.in, and the need to confirm that
we're picking the gnulib replacement headers when building _gcc/_ sources.

I just tried it myself now.  And as I was saying, the '-I../gnulib/import'
really _is_ necessary.  With the corrected:

  INCGNU = -I../gnulib/import -I$(srcdir)/../gnulib/import 

... hacking the generated gnulib/import/unistd.h and then
compiling any gcc/ file (simply cd gcc; make) errors out with:

 $ make
 g++ -fno-PIE -c  -DIN_GCC_FRONTEND -DIN_GCC_FRONTEND -g3  -DIN_GCC     
-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing 
-Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual 
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings 
-fno-common  -DHAVE_CONFIG_H -I. -Ic-family -I/home/pedro/src/gcc/src/gcc 
-I/home/pedro/src/gcc/src/gcc/c-family -I/home/pedro/src/gcc/src/gcc/../include 
-I/home/pedro/src/gcc/src/gcc/../libcpp/include 
-I/home/pedro/brno/pedro/src/gcc/build/./gmp -I/home/pedro/src/gcc/src/gmp 
-I/home/pedro/brno/pedro/src/gcc/build/./mpfr/src 
-I/home/pedro/src/gcc/src/mpfr/src -I/home/pedro/src/gcc/src/mpc/src  
-I/home/pedro/src/gcc/src/gcc/../libdecnumber 
-I/home/pedro/src/gcc/src/gcc/../libdecnumber/bid -I../libdecnumber 
-I/home/pedro/src/gcc/src/gcc/../libbacktrace  -I../gnulib/import 
-I/home/pedro/src/gcc/src/gcc/../gnulib/import   -o c-family/c-omp.o -MT 
c-family/c-omp.o -MMD -MP -MF c-family/.deps/c-omp.TPo 
/home/pedro/src/gcc/src/gcc/c-family/c-omp.c
 In file included from /home/pedro/src/gcc/src/gcc/system.h:294:0,
                  from /home/pedro/src/gcc/src/gcc/c-family/c-omp.c:25:
 ../gnulib/import/unistd.h:1:2: error: #error gnulib header included
  #error gnulib header included
   ^
 Makefile:1104: recipe for target 'c-family/c-omp.o' failed
 make: *** [c-family/c-omp.o] Error 1

... which is good.

However, with the original (incorrect):

  INCGNU = -I$(srcdir)/../gnulib/import

(i.e., only point at the srcdir, and not at the generated headers)

... the #error doesn't trigger, and the gcc/ build finishes,
meaning the system unistd.h was included directly, which is incorrect.

BTW, a branch somewhere with the configure etc. regenerated plus gnulib/import
already imported would have made it _so_ much easier for me to try this.
Can you do that?  As I explained before, that should make it easier
for other people to try on others hosts as well.

> config.status: creating config.h
> 1 error generated.
> make[5]: *** [unistd.o] Error 1
> 
> Also, I’m sure of the fact that gnulib headers are being used because
> all the functions that I’ve replaced from libiberty, I locally removed
> both the .c and .h files from libiberty to confirm that the gnulib’s
> version is indeed being used, and it compiled just fine.

That's most probably because you're replacing libiberty's obstack.h
with gnulib's, and that gnulib header is found in gnulib's _source_
directory, not in the gnulib build directory.

With your current patch, these are the files that are being
generated, and that weren't picked up in the include path (but must be):

 $ find build/gnulib/import/ -name "*.h"
 build/gnulib/import/sys/types.h
 build/gnulib/import/stdlib.h
 build/gnulib/import/arg-nonnull.h
 build/gnulib/import/warn-on-use.h
 build/gnulib/import/c++defs.h
 build/gnulib/import/unistd.h

as more gnulib modules get imported, more headers will appear
here.

> So my understanding of this is that the gnulib.h is also required to
> be included inside bconfig.h?
> 

Yes.

Thanks,
Pedro Alves

Reply via email to