Issue 117780 - vcl: header file collision between inc/stl and /usr/include
Summary: vcl: header file collision between inc/stl and /usr/include
Status: CLOSED FIXED
Alias: None
Product: gsl
Classification: Code
Component: code (show other issues)
Version: DEV300m106
Hardware: PC Solaris
: P3 Normal (vote)
Target Milestone: 3.4.0
Assignee: gsldev
QA Contact: issues@gsl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-09 11:22 UTC by tora3
Modified: 2017-05-20 10:31 UTC (History)
1 user (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
a patch for workaround (2.68 KB, patch)
2011-04-09 11:32 UTC, tora3
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description tora3 2011-04-09 11:22:38 UTC
Phenomenon:
=============
Building module vcl
=============

Entering /wb/ooo/build/local/DEV300/DEV300_m106/vcl/prj

cd .. && /usr/gnu/bin/make -s -r -j1 

.....

[ build CXX ] vcl/unx/generic/printer/ppdparser
[ build CXX ] vcl/unx/generic/printer/printerinfomanager
[ build C   ] vcl/source/fontsubset/list
"/wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl/config/stl_mycomp.h", line 33: #error: "Your compiler version is not recognized by STLport. Please edit <config/stl_mycomp.h>"
cc: acomp failed for /wb/ooo/build/local/DEV300/DEV300_m106/vcl/source/fontsubset/list.c
make: *** [/wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/workdir/CObject/vcl/source/fontsubset/list.o] Error 2
dmake:  Error code 2, while making 'all'

Environment:
$ /opt/SUNWspro/bin/cc -V
cc: Sun C 5.9 SunOS_i386 Patch 124868-08 2008/11/25

$ cat /etc/release 
                  Solaris Express Community Edition snv_107 X86
           Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                            Assembled 26 January 2009
Comment 1 tora3 2011-04-09 11:25:51 UTC
Quick Investigation:

=== make -r shows command line options such as a series of -I
$ make -r
...
R=/wb/ooo/build/local/DEV300 && S=$R/DEV300_m106 && O=$S/solver/300/unxsoli4 && W=$O/workdir &&  mkdir -p $W/CObject/vcl/source/fontsubset/ && rm -f $W/Dep/CObject/vcl/source/fontsubset/list.d && mkdir -p $W/Dep/CObject/vcl/source/fontsubset/ && /opt/SUNWspro/bin/cc -c $S/vcl/source/fontsubset/list.c -o $W/CObject/vcl/source/fontsubset/list.o -xMMD -xMF $W/Dep/CObject/vcl/source/fontsubset/list.d -DC52 -DCPPU_ENV=sunpro5 -DCUI -DDBG_UTIL -DENABLE_GTK -DENABLE_LAYOUT=0 -DENABLE_LAYOUT_EXPERIMENTAL=0 -DINTEL -DNDEBUG -DOPTIMIZE -DOSL_DEBUG_LEVEL=1 -DSOLARIS -DSOLAR_JAVA -DSTLPORT_VERSION=400 -DSUN -DSUN4 -DSUPD=300 -DSYSV -DUNIX -DUNX -DVCL -D_DEBUG -D_POSIX_PTHREAD_SEMANTICS -D_PTHREADS -D_REENTRANT -D_STLP_DEBUG   -DVCL_DLLIMPLEMENTATION -DCUI_DLL_NAME=\"libcuisi.so\" -DDLLPOSTFIX=si  -DSAL_DLLPREFIX=\"lib\" -DSAL_DLLPOSTFIX=\"si.so\" -D_XSALSET_LIBNAME=\"libspasi.so\"  -DENABLE_FONTCONFIG  -temp=/tmp -KPIC -mt -xldscope=hidden -xCC -xc99=none  -errwarn=%all -xarch=generic -xO3  -I$S/vcl/source/fontsubset/ -I$O/inc/external -I$O/inc -I$S/solenv/unxsoli4/inc -I$S/solenv/inc -I$S/res -I/opt/SUNWspro/include -I$S/solenv/inc/Xp31 -I/usr/jdk/jdk1.5.0_17/include -I/usr/jdk/jdk1.5.0_17/include/solaris -I/usr/jdk/jdk1.5.0_17/include/native_threads/include -I$S/vcl/inc -I$S/vcl/inc/pch -I$S/solenv/inc -I$O/inc/offuh -I$O/inc/stl -I$O/inc 
"/wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl/config/stl_mycomp.h", line 33: #error: "Your compiler version is not recognized by STLport. Please edit <config/stl_mycomp.h>"
cc: acomp failed for /wb/ooo/build/local/DEV300/DEV300_m106/vcl/source/fontsubset/list.c

=== DEV300_m106/vcl/source/fontsubset/list.c has the following line
...
#include <stdlib.h>
...

=== DEV300_m106/stlport/unxsoli4/misc/build/STLport-4.0 produces header files 
whose file name collides with the ones in /usr/include 

$ f=`ls /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl`
$ (cd /usr/include; ls -1 $f) 2>/dev/null
ctype.h
locale.h
math.h
setjmp.h
signal.h
stdarg.h
stddef.h
stdio.h
stdlib.h
string.h
time.h
wchar.h
wctype.h

=== Conclusion
The line #include <stdlib.h> in list.c seems to mistakenly includes 
$OUTDIR/inc/stl/stdlib.h, instead of /usr/include/stdlib.h

A header file of STLport-4.0 tries to obtain a type of complier by looking 
for a macro "__SUNPRO_CC" predefined by Sun C++ compiler, but fails 
because the Sun C compiler does not predefine it, but "__SUNPRO_C."
Consequently, #error "Your compiler version is not recognized by STLport. 
Please edit <config/stl_mycomp.h>" occurs.
Comment 2 tora3 2011-04-09 11:27:30 UTC
Workaround (it seems okay with compilation):

diff -r f986fab28646 vcl/Library_vcl.mk
--- a/vcl/Library_vcl.mk	Sat Apr 09 19:23:21 2011 +0900
+++ b/vcl/Library_vcl.mk	Sat Apr 09 19:25:13 2011 +0900
@@ -43,7 +43,6 @@
 	-I$(SRCDIR)/vcl/inc/pch \
 	-I$(SRCDIR)/solenv/inc \
 	-I$(OUTDIR)/inc/offuh \
-	-I$(OUTDIR)/inc/stl \
 	-I$(OUTDIR)/inc \
 ))

and apply the same deletion to other *.mk files in the top of vcl directory.
Comment 3 tora3 2011-04-09 11:32:31 UTC
Created attachment 76327 [details]
a patch for workaround
Comment 4 philipp.lohmann 2011-04-13 15:11:47 UTC
I favor not using stdlib.h instead, replacing malloc/free by sal's allocator instead (rtl_allocateMemorym/rtl_freeMemory). Removing the include path to or stl could potentially produce other problems depending on whether there are stl headers on the system or not; we could end up with using mixed headers then.

Fixed in CWS ooo340fixes
Comment 5 philipp.lohmann 2011-04-13 15:16:44 UTC
since I don't have a system around to check that properly (on my solaris box this compiled without any patch), could you please check whether that solves your problem ? patch is here:

http://hg.services.openoffice.org/hg/cws/ooo340fixes/rev/8215d8f7705d
Comment 6 tora3 2011-04-13 18:46:15 UTC
pl: thank you for your fix.

Here is a result. 
In sum, vcl/source/fontsubset/list.c becomes innocent.
solver/300/unxsoli4/inc/sal/config.h has #include <stdlib.h>

$ cd vcl

$ make -sr

[ build DEP ] LNK:Library/libvclsi.so
[ build C   ] vcl/source/fontsubset/list
"/wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl/config/stl_mycomp.h", line 33: #error: "Your compiler version is not recognized by STLport. Please edit <config/stl_mycomp.h>"
cc: acomp failed for /wb/ooo/build/local/DEV300/DEV300_m106/vcl/source/fontsubset/list.c
make: *** [/wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/workdir/CObject/vcl/source/fontsubset/list.o] Error 2

$ make -r
/wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/workdir/Dep/LinkTarget/Library/libvclsi.so.d:2: *** multiple target patterns.  Stop.

$ head -14 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/workdir/Dep/LinkTarget/Library/libvclsi.so.d

list.o: /wb/ooo/build/local/DEV300/DEV300_m106/vcl/source/fontsubset/list.c \
	 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/rtl/alloc.h \
	 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/sal/types.h \
	 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/sal/config.h \
	 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl/stdlib.h \
	 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl/stl/_prolog.h \
	 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl/stl/_config.h \
	 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl/stl_user_config.h \
	 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl/stl/_site_config.h \
	 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl/config/stlcomp.h \
	 /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/stl/config/stl_mycomp.h/wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/workdir/CxxObject/vcl/source/glyphs/gcach_ftyp.o : /wb/ooo/build/local/DEV300/DEV300_m106/vcl/source/glyphs/gcach_ftyp.cxx
/wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/workdir/CxxObject/vcl/source/glyphs/gcach_ftyp.o : /wb/ooo/build/local/DEV300/DEV300_m106/vcl/inc/pch/precompiled_vcl.hxx
/wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/workdir/CxxObject/vcl/source/glyphs/gcach_ftyp.o : /wb/ooo/build/local/DEV300/DEV300_m106/vcl/source/glyphs/gcach_ftyp.hxx

=====
list.o: vcl/source/fontsubset/list.c \
	solver/300/unxsoli4/inc/rtl/alloc.h \
	solver/300/unxsoli4/inc/sal/types.h \
	solver/300/unxsoli4/inc/sal/config.h \
	solver/300/unxsoli4/inc/stl/stdlib.h \
	...
=====

$ ggrep -B5 -A5 stdlib /wb/ooo/build/local/DEV300/DEV300_m106/solver/300/unxsoli4/inc/sal/config.h
#ifdef __cplusplus
}
#endif

#ifndef INCLUDED_STDLIB_H
#include <stdlib.h>
#define INCLUDED_STDLIB_H
#endif

#ifdef WIN32
#define SAL_W32
Comment 7 tora3 2011-04-14 02:02:11 UTC
in DEV300_m106 on OpenSolaris x86

$ find $WORKDIR/Dep -type f | xargs grep stl/stdio.h | grep -v stdio.h.SUNWCCh | perl -pe "s{$OUTDIR/}{}g" | perl -pe 's{(.+?):(.+)}{$1\n\t$2\n};'
workdir/Dep/LinkTarget/Library/libvclplug_svpsi.so.d
	workdir/CxxObject/vcl/unx/headless/svpvd.o : inc/stl/stdio.h

workdir/Dep/LinkTarget/Library/libsvtsi.so.d
	workdir/CxxObject/svtools/source/filter/jpeg/jpeg.o : inc/stl/stdio.h

workdir/Dep/CxxObject/vcl/unx/headless/svpvd.d
	workdir/CxxObject/vcl/unx/headless/svpvd.o : inc/stl/stdio.h

workdir/Dep/CxxObject/svtools/source/filter/jpeg/jpeg.d
	workdir/CxxObject/svtools/source/filter/jpeg/jpeg.o : inc/stl/stdio.h

$ ggrep -B2 -A2 stdio.h vcl/unx/headless/svpvd.cxx 
#include <basebmp/scanlineformats.hxx>

#include "stdio.h"

using namespace basegfx;

$ ggrep -B2 -A2 stdio.h svtools/source/filter/jpeg/jpeg.cxx 
extern "C"
{
	#include "stdio.h"
	#include "jpeg.h"
	#include "jpeglib.h"

It seems that those stdio.h are treated as $OUTDIR/inc/stl/stdio.h, 
instead of /usr/include/stdio.h

I don't know how it affects. Is it harmful? 
Maybe no, but somewhat against what a programmer expects.

It seems that $OUTDIR/inc/stl/stdio.h does some settings for itself first, 
then internally includes /usr/include/stdio.h
Comment 8 tora3 2011-04-14 02:22:31 UTC
DEV300_m106

stlport/unxsoli4/misc/build/STLport-4.0/stlport/config/stl_sunpro.h
...
# if (__SUNPRO_CC < 0x530)
...
# if (__SUNPRO_CC < 0x600 || ((__SUNPRO_CC | 0x0FFF) > 0x0FFF && __SUNPRO_CC < 0x6000))
...
#      if ( __SUNPRO_CC < 0x401 )
        __GIVE_UP_WITH_STL(SUNPRO_401)
#      endif
...

There is a patch for the file. 
It is stlport/STLport-4.0-sunstudio12u1.patch

vcl/source/fontsubset/list.c is in C, so C compiler is invoked.
The C compiler of SunStudio defines __SUNPRO_C, instead of __SUNPRO_CC.
Thus, stl_sunpro.h fails detection of compiler version.
Consequently, the macro __GIVE_UP_WITH_STL is called, which leads #error.

How and what shall we do?
Comment 9 philipp.lohmann 2011-04-14 09:15:43 UTC
Oops. Thanks for testing that.

The stl replacements for the std c headers are AFAIK purely to pl tricks with the namespace, the functionality is not changed. The reason I want to keep the $(OUTDIR)/inc/stl include is for the real stl headers like hash_map and so on; I think we should not mix these with possible system installed ones.

So this leaves list.c, which breaks because of the compiler define; we could either define the "missing" __SUNPRO_CC or convert the .c file to .cxx which would cause it to be compiled with the proper c++ compiler. I tried the latter and it can be done easily by replacing the use of "this" (which is a valid c variable) by "pThis" which then compiles as c++.

What's your opinion ?
Comment 10 philipp.lohmann 2011-04-15 11:20:24 UTC
done so in CWS ooo340fixes; list.c is now list.cxx which should solve the problem.

changeset at http://hg.services.openoffice.org/hg/cws/ooo340fixes/rev/4bb22962a758
Comment 11 tora3 2011-04-18 01:19:53 UTC
pl: cws/ooo340fixes/rev/4bb22962a758 works well with SunStudio on OpenSolaris x86.
Thank you for your efforts.
Comment 12 Oliver-Rainer Wittmann 2012-06-13 12:26:39 UTC
getting rid of value "enhancement" for field "severity".
For enhancement the field "issue type" shall be used.