Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Oct 2012 07:38:11 -0700
From:      Garrett Cooper <yanegomi@gmail.com>
To:        Dimitry Andric <dim@freebsd.org>
Cc:        Xin Li <delphij@delphij.net>, d@delphij.net, peter@freebsd.org, freebsd-arch@freebsd.org
Subject:   Re: Building environment using system headers instead of the in-tree headers
Message-ID:  <CAGH67wT2guttRKsk3gKOAOAGfR=ePzLdrwOsXutB%2BZN86h25RA@mail.gmail.com>
In-Reply-To: <5073F29D.6060505@FreeBSD.org>
References:  <50736C5A.1000604@delphij.net> <5073F29D.6060505@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Oct 9, 2012 at 2:47 AM, Dimitry Andric <dim@freebsd.org> wrote:
> On 2012-10-09 02:14, Xin Li wrote:
>>
>> Josh Paetzel recently discovered an interesting build issue with the
>> current FreeBSD 'buildworld', where 'make buildworld' over a FreeBSD
>> 9.0 tree on a FreeBSD 9.1 system will fail.

FWIW I remember when I used to "meister" builds on build.ix there was
something off about the machine's setup dealing with the headers. I
didn't narrow down what exactly it was, but I had a hunch it was build
environment (machine) related (and I think my explanation might make
sense) as I never ran into the same issue with streetfighter.ix (which
ran CURRENT) or bayonetta, my personal workstation (which has run
8-CURRENT and 9-CURRENT and 9/stable since then).

Full logs with build errors along with repro steps would help too if
they exist...

>> As it turns out, this was caused by addition of xlocale functionality
>> on FreeBSD 9.1, which uses macros and expects some new functions found
>> in more recent FreeBSD releases.  On the other hand, we do not pass
>> e.g. -I${.CURDIR}/../../include so the header is preferred than system
>> header.
>
>
> During which stage does this fail?  In the '4.2 building libraries' one?

...

Doing a quick grep and given past experience in Linux embedded
projects, isn't the real problem that we're not using gcc properly and
it's picking up the wrong system root path (for the system directory
#includes)?

stable/6 (just for fun and to verify whether or not there was
something lost in the gcc 4.2.1 merge):

$ egrep --include Makefile\* --include \*.mk -r
'(iwithprefix|iwithprefixbefore|isystem|isysroot|nostdinc)' .; egrep
--include \*.h -r
'(iwithprefix|iwithprefixbefore|isystem|isysroot|nostdinc)' contrib/
./share/mk/bsd.dep.mk:MKDEP_CFLAGS=     ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*}
./share/mk/bsd.dep.mk:MKDEP_CXXFLAGS=   ${CXXFLAGS:M-nostdinc*}
${CXXFLAGS:M-[BID]*}
./share/mk/bsd.dep.mk:MKDEP_OBJCFLAGS=${OBJCFLAGS:M-nostdinc*}
${OBJCFLAGS:M-[BID]*} ${OBJCFLAGS:M-Wno-import*}
./sys/conf/kmod.mk:NOSTDINC=    -nostdinc
./sys/conf/kern.pre.mk:NOSTDINC= -nostdinc
contrib/binutils/libiberty/cp-demangle.h:   Written by Ian Lance
Taylor <ian@wasabisystems.com>.
contrib/gcc/cp-demangle.h:   Written by Ian Lance Taylor
<ian@wasabisystems.com>.
contrib/gcc/config/sol2.h:%{compat-bsd:-iwithprefixbefore ucbinclude
-I/usr/ucbinclude} \
contrib/gcc/config/i386/sco5.h:   header files. Hence the -isystem
/usr/gnu/include in the CPP_SPEC.
contrib/gcc/config/i386/sco5.h:  -isystem /usr/gnu/include \
contrib/gcc/config/i386/sco5.h:  %{ansi:-isystem include/ansi%s
-isystem /usr/include/ansi} \
contrib/gcc/config/i386/sco5.h:   %{posix:-isystem include/posix%s
-isystem /usr/include/posix \
contrib/gcc/config/i386/sco5.h:    %{!posix:%{Xpg4:-isystem
include/xpg4%s -isystem /usr/include/xpg4 \
contrib/gcc/config/i386/sco5.h:             %{Xods30:-isystem
include/ods_30_compat%s \
contrib/gcc/config/i386/sco5.h:                      -isystem
/usr/include/ods_30_compat \
contrib/gcc/config/i386/cygwin.h:
%{!nostdinc:%{!mno-win32|mno-cygwin:-idirafter ../include/w32api%s
-idirafter ../../include/w32api%s}}\
contrib/gcc/config/i386/i386-interix.h:-isystem %$INTERIX_ROOT/usr/include"
contrib/gcc/gcc.h:  || !strcmp (STR, "iwithprefix") || !strcmp (STR,
"iwithprefixbefore") \
contrib/gcc/gcc.h:  || !strcmp (STR, "isystem") || !strcmp (STR, "-param") \

stable/9:

$ egrep --include Makefile\* --include \*.mk -r
'(iwithprefix|iwithprefixbefore|isystem|isysroot|nostdinc)' .; egrep
--include \*.h -r
'(iwithprefix|iwithprefixbefore|isystem|isysroot|nostdinc)' contrib/
./sys/conf/kmod.mk:NOSTDINC=    -nostdinc
./sys/conf/kern.pre.mk:NOSTDINC= -nostdinc
./share/mk/bsd.dep.mk:MKDEP_CFLAGS=     ${CFLAGS:M-nostdinc*}
${CFLAGS:M-[BIDU]*} ${CFLAGS:M-std=*} \
./share/mk/bsd.dep.mk:MKDEP_CXXFLAGS=   ${CXXFLAGS:M-nostdinc*}
${CXXFLAGS:M-[BIDU]*} \
contrib/gcclibs/libiberty/cp-demangle.h:   Written by Ian Lance Taylor
<ian@wasabisystems.com>.
contrib/llvm/tools/clang/include/clang/Serialization/ASTReader.h:
std::string isysroot;
contrib/llvm/tools/clang/include/clang/Serialization/ASTReader.h:  ///
\param isysroot If non-NULL, the system include path specified by the
contrib/llvm/tools/clang/include/clang/Serialization/ASTReader.h:
ASTReader(Preprocessor &PP, ASTContext &Context, StringRef isysroot =
"",
contrib/llvm/tools/clang/include/clang/Serialization/ASTWriter.h:
void WriteMetadata(ASTContext &Context, StringRef isysroot,
contrib/llvm/tools/clang/include/clang/Serialization/ASTWriter.h:
                         StringRef isysroot);
contrib/llvm/tools/clang/include/clang/Serialization/ASTWriter.h:
void WriteHeaderSearch(const HeaderSearch &HS, StringRef isysroot);
contrib/llvm/tools/clang/include/clang/Serialization/ASTWriter.h:
              StringRef isysroot, const std::string &OutputFile,
contrib/llvm/tools/clang/include/clang/Serialization/ASTWriter.h:  ///
\param isysroot if non-empty, write a relocatable file whose headers
contrib/llvm/tools/clang/include/clang/Serialization/ASTWriter.h:
          Module *WritingModule, StringRef isysroot,
contrib/llvm/tools/clang/include/clang/Serialization/ASTWriter.h:
std::string isysroot;
contrib/llvm/tools/clang/include/clang/Serialization/ASTWriter.h:
         StringRef isysroot, raw_ostream *Out);
contrib/llvm/tools/clang/include/clang/Frontend/HeaderSearchOptions.h:
   /// it should be) because that is false for user provided
'-iwithprefix'
contrib/binutils/libiberty/cp-demangle.h:   Written by Ian Lance
Taylor <ian@wasabisystems.com>.
contrib/gcc/config/i386/i386-interix.h:-isystem %$INTERIX_ROOT/usr/include"
contrib/gcc/config/i386/sco5.h:   header files. Hence the -isystem
/usr/gnu/include in the CPP_SPEC.
contrib/gcc/config/i386/sco5.h:  -isystem /usr/gnu/include \
contrib/gcc/config/i386/sco5.h:  %{ansi:-isystem include/ansi%s
-isystem /usr/include/ansi} \
contrib/gcc/config/i386/sco5.h:   %{posix:-isystem include/posix%s
-isystem /usr/include/posix \
contrib/gcc/config/i386/sco5.h:    %{!posix:%{Xpg4:-isystem
include/xpg4%s -isystem /usr/include/xpg4 \
contrib/gcc/config/i386/sco5.h:             %{Xods30:-isystem
include/ods_30_compat%s \
contrib/gcc/config/i386/sco5.h:                      -isystem
/usr/include/ods_30_compat \
contrib/gcc/config/i386/cygwin.h:
%{!nostdinc:%{!mno-win32|mno-cygwin:-idirafter ../include/w32api%s
-idirafter ../../include/w32api%s}}\
contrib/gcc/config/vxworksae.h: %{!nostdinc:%{isystem*}}
                                 \
contrib/gcc/config/vxworksae.h:  %{!nostdinc:-isystem "
VXWORKSAE_TARGET_DIR "/vThreads/h}}     \
contrib/gcc/config/vxworksae.h:  %{!nostdinc:-isystem "
VXWORKSAE_TARGET_DIR "/h}}              \
contrib/gcc/config/vxworksae.h: %{!nostdinc:-isystem "
VXWORKSAE_TARGET_DIR "/val/h}"
contrib/gcc/config/sol2.h:%{compat-bsd:-iwithprefixbefore ucbinclude
-I/usr/ucbinclude} \
contrib/gcc/config/darwin.h:  "%{isysroot*:-syslibroot %*;:-syslibroot
" TARGET_SYSTEM_ROOT "}"
contrib/gcc/config/darwin.h:#define LINK_SYSROOT_SPEC
"%{isysroot*:-syslibroot %*}"
contrib/gcc/config/vxworks.h:/* Since we provide a default -isystem,
expand -isystem on the command
contrib/gcc/config/vxworks.h: %{!nostdinc:%{isystem*}}
                         \
contrib/gcc/config/vxworks.h:    %{!nostdinc:-isystem "
VXWORKS_TARGET_DIR "/usr/h}}            \
contrib/gcc/config/vxworks.h:    %{!nostdinc:-isystem "
VXWORKS_TARGET_DIR "/h}}"
contrib/gcc/config/sol2-6.h:%{compat-bsd:-iwithprefixbefore ucbinclude
-I/usr/ucbinclude} \
contrib/gcc/gcc.h:  || !strcmp (STR, "iwithprefix") || !strcmp (STR,
"iwithprefixbefore") \
contrib/gcc/gcc.h:  || !strcmp (STR, "iquote") || !strcmp (STR, "isystem") \
contrib/gcc/gcc.h:  || !strcmp (STR, "isysroot") \
contrib/gcc/c-incpath.h:  /* Do extra includes processing.  STDINC is
false iff -nostdinc was given.  */
$

If so, Makefile.inc1 needs to do the right thing by passing through a
combination of those CFLAGS/CXXFLAGS to clang/gcc/etc. As Dimitry
said, building from the subdirectory without going through the build
system should not necessarily work if the headers are not "API"
(function declaration, #include pollution, macro declaration, etc)
compatible unless you install the headers to the system directory
(/usr/include) first.

Thanks!
-Garrett



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGH67wT2guttRKsk3gKOAOAGfR=ePzLdrwOsXutB%2BZN86h25RA>