Bug 5596 - compiling 3.2.0 on freebsd 7.0 release fails
compiling 3.2.0 on freebsd 7.0 release fails
Status: NEW
Product: Samba 3.0
Classification: Unclassified
Component: Build environment
3.0.9
x86 FreeBSD
: P3 normal
: none
Assigned To: Tim Potter
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-07-08 06:46 UTC by Robert Joosten
Modified: 2009-01-25 21:20 UTC (History)
2 users (show)

See Also:


Attachments
Patch to hopefully solve the problem. (354 bytes, patch)
2009-01-03 09:46 UTC, Derrell Lipman
no flags Details
2 x Pre processor output + diff + libsmbclient.h (474.86 KB, application/octet-stream)
2009-01-04 18:14 UTC, Fred Houweling
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Joosten 2008-07-08 06:46:20 UTC
Hi,

Today I tried to install the new 3.2.0 release, but that fails :-(

onfig.status: executing rm-stdbool.h commands
Using FLAGS      =  -O -D_SAMBA_BUILD_=3 -I/opt/include
-I/usr/disk1/samba-3.2.0/source/popt
-I/usr/disk1/samba-3.2.0/source/iniparser/src -Iinclude -I./include  -I.
-I. -I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns
-I./librpc -DHAVE_CONFIG_H  -Iinclude -I./include -I. -I. -I./lib/replace
-I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -I./popt
-I/include -I/usr/disk1/samba-3.2.0/source/lib -D_SAMBA_BUILD_=3
      PICFLAG    = -fPIC -DPIC
      LIBS       = -lcrypt
      LDFLAGS    = -pie -Wl,-z,relro -L/opt/lib -Wl,-R/opt/lib -L/opt/lib
-L./bin
      DYNEXP     = -Wl,--export-dynamic
      LDSHFLAGS  = -shared -Wl,-z,relro -L/opt/lib -Wl,-R/opt/lib
-L/opt/lib -L./bin
      SHLIBEXT   = so
      SONAMEFLAG = -Wl,-soname,
Generating smbd/build_options.c
Building include/proto.h
creating /usr/disk1/samba-3.2.0/source/include/proto.h
Building include/build_env.h
creating /usr/disk1/samba-3.2.0/source/winbindd/winbindd_proto.h
creating /usr/disk1/samba-3.2.0/source/web/swat_proto.h
creating /usr/disk1/samba-3.2.0/source/libnet/libnet_proto.h
creating /usr/disk1/samba-3.2.0/source/client/client_proto.h
creating /usr/disk1/samba-3.2.0/source/utils/net_proto.h
creating /usr/disk1/samba-3.2.0/source/utils/ntlm_auth_proto.h
Compiling lib/talloc/talloc.c
Linking non-shared library bin/libtalloc.a
Compiling lib/replace/replace.c
Compiling lib/replace/snprintf.c
Compiling lib/replace/getpass.c
Compiling lib/replace/strptime.c
Compiling lib/replace/repdir_getdirentries.c
creating /usr/disk1/samba-3.2.0/source/exports/libtalloc.syms
Linking shared library bin/libtalloc.so
Compiling lib/tdb/common/tdb.c
Compiling lib/tdb/common/dump.c
Compiling lib/tdb/common/transaction.c
Compiling lib/tdb/common/error.c
Compiling lib/tdb/common/traverse.c
Compiling lib/tdb/common/freelist.c
Compiling lib/tdb/common/freelistcheck.c
Compiling lib/tdb/common/io.c
Compiling lib/tdb/common/lock.c
Compiling lib/tdb/common/open.c
Linking non-shared library bin/libtdb.a
creating /usr/disk1/samba-3.2.0/source/exports/libtdb.syms
Linking shared library bin/libtdb.so
Compiling nsswitch/libwbclient/wbclient.c
Compiling nsswitch/libwbclient/wbc_util.c
Compiling nsswitch/libwbclient/wbc_pwd.c
Compiling nsswitch/libwbclient/wbc_idmap.c
Compiling nsswitch/libwbclient/wbc_sid.c
Compiling nsswitch/libwbclient/wbc_pam.c
Compiling nsswitch/wb_common.c
creating /usr/disk1/samba-3.2.0/source/exports/libwbclient.syms
Linking shared library bin/libwbclient.so
Compiling libsmb/libsmb_cache.c
In file included from libsmb/libsmb_cache.c:25:
include/libsmb_internal.h:176: error: expected specifier-qualifier-list
before 'smbc_smb_encrypt_level'
libsmb/libsmb_cache.c: In function 'SMBC_add_cached_server':
libsmb/libsmb_cache.c:91: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:91: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:91: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:91: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:91: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c: In function 'SMBC_get_cached_server':
libsmb/libsmb_cache.c:121: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:163: error: called object
'smbc_getFunctionRemoveCachedServer(context)' is not a function
libsmb/libsmb_cache.c:178: error: called object
'smbc_getFunctionRemoveCachedServer(context)' is not a function
libsmb/libsmb_cache.c: In function 'SMBC_remove_cached_server':
libsmb/libsmb_cache.c:203: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:207: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:207: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:207: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:207: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:207: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c: In function 'SMBC_purge_cached_servers':
libsmb/libsmb_cache.c:232: error: dereferencing pointer to incomplete type
The following command failed:
gcc -I. -I/usr/disk1/samba-3.2.0/source  -O -D_SAMBA_BUILD_=3
-I/opt/include -I/usr/disk1/samba-3.2.0/source/popt
-I/usr/disk1/samba-3.2.0/source/iniparser/src -Iinclude -I./include  -I.
-I. -I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns
-I./librpc -DHAVE_CONFIG_H  -Iinclude -I./include -I. -I. -I./lib/replace
-I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -I./popt
-I/include -I/usr/disk1/samba-3.2.0/source/lib -D_SAMBA_BUILD_=3 -fPIC
-DPIC -c libsmb/libsmb_cache.c -o libsmb/libsmb_cache.o
gmake: *** [libsmb/libsmb_cache.o] Error 1

I'd run configure like this:
LDFLAGS="-L/opt/lib" ./configure --prefix=/opt --enable-cups

uname -a:
FreeBSD duts.intranet.erje.net 7.0-RELEASE-p1 FreeBSD 7.0-RELEASE-p1 #0: Thu
 May  1 18:19:15 CEST 2008 root@duts.intranet.erje.net:/usr/obj/usr/src/sys/DUTS  i386

Any help or insight ? Compiling/making 3.0.29 this way ran okay, last
week. E-mail me for more details.

Regards,
Robert

PS: No version 3.2 in bugzilla or should I cleanup my glasses ?
Comment 1 Fred Houweling 2009-01-03 06:57:42 UTC
Hi All,
This problem seems to be related to the order 2 header files are included in multiple source files in libsmb.

This involved reordering the lines (usually around line 27)

from:
#include "libsmbclient.h"
#include "libsmb_internal.h"

to:
#include "libsmb_internal.h"
#include "libsmbclient.h"

for the following files:-
libsmb/libsmb_cache.c
libsmb/libsmb_context.c
libsmb/libsmb_dir.c
libsmb/libsmb_file.c
libsmb/libsmb_misc.c
libsmb/libsmb_path.c
libsmb/libsmb_printjob.c
libsmb/libsmb_server.c
libsmb/libsmb_stat.c
libsmb/libsmb_xattr.c
libsmb/libsmb_setget.c

This resulted in a successful compile.

A quicker (untested) way to fix this may be to add an include for the file 
"libsmb_internal.h" in "libsmbclient.h"
But to minimise potential impact to the rest of the build I altered the effected source files instead.

My guess is that there is something in libsmb_internal.h that is referenced by the libsmbclient.h include. 

I'm using the following versions
FreeBSD 6.2-RELEASE
GCC	gcc (GCC) 3.4.6 [FreeBSD] 20060305
Samba 3.2.6
Comment 2 Derrell Lipman 2009-01-03 08:26:59 UTC
Reordering the lines is not a viable solution.  Applications depend on libsmbclient.h yet have no access to libsmb_internal.h so can't include it.  It must be possible to include libsmbclient.h BEFORE libsmb_internal.h in these internal files or there's a much bigger problem afoot.

I will look into this later today.

Derrell
Comment 3 Derrell Lipman 2009-01-03 09:46:43 UTC
Created attachment 3847 [details]
Patch to hopefully solve the problem.

It looks like maybe the FreeBSD compiler is not accepting a reference to an undefined structure as an implicit declaration of that structure, and instead creating a local (to the block) structure which is not resolved to the global declaration later.  I'd have to study the C spec to determine if the FreeBSD compiler is broken or if most other compilers are simply too lenient.  In any case, I need to make this work for FreeBSD, so please try the attached patch to see if it fixes your problem.

Thanks,

Derrell
Comment 4 Fred Houweling 2009-01-03 20:42:50 UTC
Hi Derrell,
Thanks for taking the time,
Applied the patch to a clean source extract but the compile failure remains.
Compile log follows, happy to keep the patch cycle going as long as you need.

Regards

Fred
...
Compiling libads/ldap_schema.c
Compiling libads/util.c
Compiling libads/ndr.c
Compiling lib/privileges_basic.c
creating /usr/lsrc/samba-3.2.6/source/exports/libnetapi.syms
Linking shared library bin/libnetapi.so.0
Compiling libsmb/libsmb_cache.c
In file included from libsmb/libsmb_cache.c:25:
include/libsmb_internal.h:157: error: syntax error before "smbc_share_mode"
include/libsmb_internal.h:176: error: syntax error before "smbc_smb_encrypt_level"
include/libsmb_internal.h:194: error: syntax error before "smbc_ftruncate_fn"
libsmb/libsmb_cache.c: In function `SMBC_add_cached_server':
libsmb/libsmb_cache.c:91: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:91: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:91: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:91: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:91: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c: In function `SMBC_get_cached_server':
libsmb/libsmb_cache.c:121: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:163: error: called object is not a function
libsmb/libsmb_cache.c:178: error: called object is not a function
libsmb/libsmb_cache.c: In function `SMBC_remove_cached_server':
libsmb/libsmb_cache.c:203: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:207: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:207: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:207: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:207: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c:207: error: dereferencing pointer to incomplete type
libsmb/libsmb_cache.c: In function `SMBC_purge_cached_servers':
libsmb/libsmb_cache.c:232: error: dereferencing pointer to incomplete type
The following command failed:
gcc -I. -I/usr/lsrc/samba-3.2.6/source  -O -D_SAMBA_BUILD_=3 -I/usr/local/include  -I/usr/lsrc/samba-3.2.6/source/iniparser/src -Iinclude -I./include  -I. -I. -I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -DHAVE_CONFIG_H  -Iinclude -I./include -I. -I. -I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -I./popt -DLDAP_DEPRECATED   -I/include -I/usr/lsrc/samba-3.2.6/source/lib -D_SAMBA_BUILD_=3 -fPIC -DPIC -c libsmb/libsmb_cache.c -o libsmb/libsmb_cache.o
gmake: *** [libsmb/libsmb_cache.o] Error 1
Comment 5 Derrell Lipman 2009-01-03 21:40:10 UTC
Ok, that compiler seems to be acting very strange.  Let's try the following:

% cd source
% rm libsmb/libsmb_cache.o
% make

Note that it will display a long line something like this:
Using FLAGS      =  -O -g -D_SAMBA_BUILD_=3 -g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER -Wdeclaration-after-statement -Werror-implicit-function-declaration  -I/home/derrell/=/samba.git/v3-2-test/source/iniparser/src -Iinclude -I./include  -I. -I. -I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -DHAVE_CONFIG_H  -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Iinclude -I./include -I. -I. -I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -I./popt -DLDAP_DEPRECATED   -I/include -I/home/derrell/=/samba.git/v3-2-test/source/lib -D_SAMBA_BUILD_=3

Copy everything it prints that follow "FLAGS =", prepend -E to it (assuming that -E with your compiler means display the preprocessor output; if not, replace that with whatever option does generate preprocessor output), and run the compiler (actually, just the preprocessor) on libsmb/libsmb_cache.c.  With my example line above, I'd do this:

% gcc -E -O -g -D_SAMBA_BUILD_=3 -g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER -Wdeclaration-after-statement -Werror-implicit-function-declaration  -I/home/derrell/=/samba.git/v3-2-test/source/iniparser/src -Iinclude -I./include  -I. -I. -I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -DHAVE_CONFIG_H  -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Iinclude -I./include -I. -I. -I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -I./popt -DLDAP_DEPRECATED   -I/include -I/home/derrell/=/samba.git/v3-2-test/source/lib -D_SAMBA_BUILD_=3 libsmb/libsmb_cache.c

The output will be the preprocessed file including all of its include files, hopefully with file and line numbers interspersed. Attach the output to this bug.  I want to see what your compiler is actually having trouble with.

Derrell
Comment 6 Fred Houweling 2009-01-04 02:11:47 UTC
Hi Derrell,
It's not a pre processor fault, It completes without error.
If I get some more time I'll also explore this.

Your requested output follows:
server# gcc -E -I. -I/usr/lsrc/samba-3.2.6/source -O -D_SAMBA_BUILD_=3 -I/usr/local/include -I/usr/lsrc/samba-3.2.6/source/iniparser/src -Iinclude -I./include -I. -I. -I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -DHAVE_CONFIG_H -Iinclude -I./include -I. -I. -I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -I./popt -DLDAP_DEPRECATED -I/include -I/usr/lsrc/samba-3.2.6/source/lib -D_SAMBA_BUILD_=3 -fPIC -DPIC -c libsmb/libsmb_cache.c -o libsmb/libsmb_cache.o
server#
Comment 7 Fred Houweling 2009-01-04 03:30:53 UTC
Hi Derrell,
I think I found the problem,
It is probably one that has been encountered before.
I have a legacy file libsmb_client.h file in /usr/local/include from release 3.0.25a.
I believe this is the file that is being included instead of the one from the build directory, I have moved it to another name and am currently trying to rebuild after a make clean.
I suspect the include search order may need to be reviewed to ensure the build directory include paths are first.
I'll get back to you.
Comment 8 Derrell Lipman 2009-01-04 09:34:49 UTC
Right.  I didn't expect the preprocessor to be the problem.  Rather, I expected the preprocessor output to show what was actually get compiled in the next step, which could possibly include the wrong header file being included (as it seems you've found).

We're already using quoted #include file names (vs. enclosed in angle brackets) so the manual include path "should" be used as opposed to the system include path.  I've heard of this problem once before on FreeBSD, so I suspect that the preprocessor does not interpret the include path like other compilers do.

Please confirm that removing the file in /usr/local/include solves the problem.

Derrell
Comment 9 Robert Joosten 2009-01-04 11:50:16 UTC
Hi,

Last friday I observed samba 3.2.6 does compile flawless on a vanilla freebsd 7.0release box, so I got back to that specific intranet box and moved all samba-related files from /lib, /usr/lib, /usr/local/lib, /opt/lib etc etc. That didn't help either.

Today, I observed the advice of moving libsmbclient.h out of the way. I did that and now the compiling succeeds without any error.

Regards,
Robert
Comment 10 Sergey 2009-01-04 13:17:53 UTC
I have installed samba-3.0.32_2,1 and cann't make build /usr/ports/net/samba32-devel (PORTVERSION?=3.2.4).
After removing /usr/local/include/libsmbclient.h at another place make build finished successfully.
uname -a
FreeBSD acc.acc.tula.ru 7.0-RELEASE-p7 FreeBSD 7.0-RELEASE-p7 #62: Tue Dec 23 12:57:54 MSK 2008     root@acc.acc.tula.ru:/usr/obj/usr/src/sys/Z  i386
Comment 11 Fred Houweling 2009-01-04 17:30:20 UTC
Hi All,
My compile also completed without error.
I guess it could be something configure could check for?
Or a special Makefile target?

In any case, I'd say the cause has been located, now it's just up to the developers to decide how to handle such an issue.

Thank you Derrell for your valued assistance.

And thank you to everyone who confirmed a successful build.

Regards
Fred
Comment 12 Fred Houweling 2009-01-04 18:00:04 UTC
Hi Derrell,
As a side note, there was no pre processor output because I left the -o flag in, I appologise that was my mistake.
If for completness you still want the failing output please let me know and I'll redo that step with the rogue header file still in /usr/local/include

Regards

Fred
(In reply to comment #8)
> Right.  I didn't expect the preprocessor to be the problem.  Rather, I expected
> the preprocessor output to show what was actually get compiled in the next
> step, which could possibly include the wrong header file being included (as it
> seems you've found).
> We're already using quoted #include file names (vs. enclosed in angle brackets)
> so the manual include path "should" be used as opposed to the system include
> path.  I've heard of this problem once before on FreeBSD, so I suspect that the
> preprocessor does not interpret the include path like other compilers do.
> Please confirm that removing the file in /usr/local/include solves the problem.
> Derrell

Comment 13 Fred Houweling 2009-01-04 18:14:08 UTC
Created attachment 3849 [details]
2 x Pre processor output + diff + libsmbclient.h

This tar.gz file contains:
1. Output of the preprocessor with the errant libsmbclient.h file in /usr/local/include
2. Output of the preprocessor without the errant libsmbclient.h file.
3. A diff of the file 1 against file 2.
4. A copy of the errant libsmbclient.h from /usr/local/include
Comment 14 Derrell Lipman 2009-01-04 19:41:24 UTC
Jelmer, Metze,

This is the second report we've had of FreeBSD problems compiling libsmbclient due to an errant libsmbclient.h somewhere on the system (e.g. /usr/local/include), and the compiler using that one instead of the one in the source tree's include directory.  I've checked that the code is properly using double quotes for included header files, not angle brackets.  I considered version numbers or something for the header files to match compatibility, but that seems like going overboard (and not terribly easy to do with git, I think).  Is there anything we can put into the configure tests or build system to detect a libsmbclient.h sitting someplace where it shouldn't be used but will be?

I've switched this bug to Component: Build Environment.  If there's nothing you can do easily, set it back to libsmbclient and I'll just put a big comment in the header file at the point where it has been complaining, warning people of what to look for should they get an error there.

Thanks.

Derrell
Comment 15 Timur Bakeyev 2009-01-25 21:20:23 UTC
Hi!
Fred Houweling correctly found the problem(Thanks!) and it is a result of the way, how CFLAGS and CPPFLAGS are calculated in the configure.
Basically, autodetection of such dependencies as CUPS alter CFLAGS and add -I/usr/local/include to the search path.
Due the way how compilation flags assembled in the Makefile, this path becomes the firs one in the search order, bringing legacy libsmbclient.h in front.
I spent a whole day trying to figure the easiest way to work around this problem and here are the least intrusive solutions:

1. and the best one - in the Makefile.in just swap CFLAGS and CPPFLAGS, so:
-FLAGS1 = $(CFLAGS) @FLAGS1@ @SAMBA_CPPFLAGS@ $(CPPFLAGS)
+FLAGS1 = @FLAGS1@ @SAMBA_CPPFLAGS@ $(CPPFLAGS) $(CFLAGS)

That seems enforces the correct order of the include path, making sure that local dirs are scaned before system wide ones.

2. Adding construction like "-idirafter /usr/local/include" to the CFLAGS seems also helps, but I do prefer 1 varian due to it's simplisity.

Hope, this will be included both into the next 3.2 and 3.3 release.

And it's(1) used in the samba3[23] port already.