Bug 213345 - [PATCH] net/samba44: build fails because files from ${LOCALBASE} get included before files of the same name in the port source tree on FreeBSD-11
Summary: [PATCH] net/samba44: build fails because files from ${LOCALBASE} get included...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Timur I. Bakeyev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-09 19:56 UTC by Igor Pavlov
Modified: 2017-12-18 04:36 UTC (History)
6 users (show)

See Also:
bugzilla: maintainer-feedback? (timur)


Attachments
Patch swaps system & local include folders order to resolve the net/samba44 build issue due to conflict with the net/samba-libsmbclient (639 bytes, patch)
2016-10-21 01:29 UTC, Igor Pavlov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Pavlov 2016-10-09 19:56:33 UTC
Full log: https://pastebin.com/wD7YThd2

There are some errors:


In file included from ../source3/libsmb/libsmb_cache.c:26:
../source3/include/libsmb_internal.h:249:17: error: unknown type name 'smbc_splice_fn'
                smbc_splice_fn                  splice_fn;
                ^
../source3/include/libsmb_internal.h:250:3: error: unknown type name 'smbc_notify_fn'
                smbc_notify_fn                  notify_fn;
                ^
1 warning generated.
../source3/include/libsmb_internal.h:351:3: error: unknown type name 'smbc_notify_callback_fn'
                smbc_notify_callback_fn cb, void *private_data);
                ^
[2086/3430] Compiling source3/libsmb/libsmb_file.c
3 errors generated.
In file included from ../source3/libsmb/libsmb_context.c:28:
../source3/include/libsmb_internal.h:249:17: error: unknown type name 'smbc_splice_fn'
                smbc_splice_fn                  splice_fn;
                ^
../source3/include/libsmb_internal.h:250:3: error: unknown type name 'smbc_notify_fn'
                smbc_notify_fn                  notify_fn;
                ^
../source3/include/libsmb_internal.h:351:3: error: unknown type name 'smbc_notify_callback_fn'
                smbc_notify_callback_fn cb, void *private_data);
                ^
../source3/libsmb/libsmb_context.c:170:9: warning: implicit declaration of function 'smbc_setPort' is invalid in C99
      [-Wimplicit-function-declaration]
        smbc_setPort(context, 0);
        ^
../source3/libsmb/libsmb_context.c:197:9: warning: implicit declaration of function 'smbc_setFunctionSplice' is invalid in C99
      [-Wimplicit-function-declaration]
        smbc_setFunctionSplice(context, SMBC_splice_ctx);
        ^
../source3/libsmb/libsmb_context.c:217:9: warning: implicit declaration of function 'smbc_setFunctionNotify' is invalid in C99
      [-Wimplicit-function-declaration]
        smbc_setFunctionNotify(context, SMBC_notify_ctx);
        ^
3 warnings and 3 errors generated.
In file included from ../source3/libsmb/libsmb_dir.c:29:
../source3/include/libsmb_internal.h:249:17: error: unknown type name 'smbc_splice_fn'
                smbc_splice_fn                  splice_fn;
                ^
../source3/include/libsmb_internal.h:250:3: error: unknown type name 'smbc_notify_fn'
                smbc_notify_fn                  notify_fn;
                ^
../source3/include/libsmb_internal.h:351:3: error: unknown type name 'smbc_notify_callback_fn'
                smbc_notify_callback_fn cb, void *private_data);
                ^
In file included from ../source3/libsmb/libsmb_file.c:28:
../source3/include/libsmb_internal.h:249:17: error: unknown type name 'smbc_splice_fn'
                smbc_splice_fn                  splice_fn;
                ^
../source3/include/libsmb_internal.h:250:3: error: unknown type name 'smbc_notify_fn'
                smbc_notify_fn                  notify_fn;
                ^
../source3/include/libsmb_internal.h:351:3: error: unknown type name 'smbc_notify_callback_fn'
                smbc_notify_callback_fn cb, void *private_data);
                ^
3 errors generated.
../source3/libsmb/libsmb_dir.c:2059:2: error: unknown type name 'smbc_notify_callback_fn'
        smbc_notify_callback_fn cb;
        ^
../source3/libsmb/libsmb_dir.c:2070:2: error: unknown type name 'smbc_notify_callback_fn'
        smbc_notify_callback_fn cb, void *private_data)
        ^
../source3/libsmb/libsmb_dir.c:2130:45: error: array has incomplete element type 'struct smbc_notify_callback_action'
                struct smbc_notify_callback_action actions[num_changes];
                                                          ^
../source3/libsmb/libsmb_dir.c:2130:10: note: forward declaration of 'struct smbc_notify_callback_action'
                struct smbc_notify_callback_action actions[num_changes];
                       ^
../source3/libsmb/libsmb_dir.c:2197:11: error: unknown type name 'smbc_notify_callback_fn'
                               smbc_notify_callback_fn cb, void *private_data)
                               ^
../source3/libsmb/libsmb_dir.c:2227:3: error: unknown type name 'smbc_notify_callback_fn'
                smbc_notify_callback_fn cb, void *private_data)
                ^
8 errors generated.


And there are some weird warnings, like this:
[2067/3430] Compiling source4/torture/vfs/fruit.c
../source4/torture/vfs/fruit.c:2836:9: warning: address of array 'h1.data' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if (h1.data) {
        ~~  ~~~^~~~


samba43 has the same issues on FreeBSD-11.0 but it builds fine on FreeBSD-10.3.
Comment 1 shark 2016-10-14 12:25:06 UTC
I get the same compile error after my system upgrade from 10.3 to 11.
Comment 2 Igor Pavlov 2016-10-21 00:15:22 UTC
I've found that build fails due to installed net/samba-libsmbclient port. Build gets wrong libsmbclient.h header from the /usr/local/include folder instead of the local source folder.
Comment 3 Igor Pavlov 2016-10-21 00:27:24 UTC
Anyway, it would be good to fix build script so that it will include /usr/local/include after its local folders.
Comment 4 Igor Pavlov 2016-10-21 01:29:29 UTC
Created attachment 176001 [details]
Patch swaps system & local include folders order to resolve the net/samba44 build issue due to conflict with the net/samba-libsmbclient
Comment 5 Igor Pavlov 2016-10-21 01:31:33 UTC
Please, approve the patch.
Comment 6 shark 2016-10-21 11:14:21 UTC
I applied the patch inside the directory /usr/ports/net/samba44/work/samba-4.4.5/ and it solved the compile error. Patch approved.

Thank you!  :-)
Comment 7 michael.kristofic 2016-12-20 09:38:04 UTC
Hi, after upgrading FreeBSD 10.2 to 11.0p2 I'm trying to upgrade samba41 to samba44. I was getting the same error as mentioned in this bug report. 

After applying the patch and running the portmaster command (portmaster -RoC net/samba44 samba41-4.1.22_2) I got the following error:

//usr/local/lib/samba/liberrors.so: undefined reference to `DEBUGLEVEL_CLASS@SAMBA_UTIL_0.0.1'
//usr/local/lib/samba/liberrors.so: undefined reference to `dbgtext@SAMBA_UTIL_0.0.1'
//usr/local/lib/samba/liberrors.so: undefined reference to `dbghdrclass@SAMBA_UTIL_0.0.1'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
Waf: Leaving directory `/usr/ports/net/samba44/work/samba-4.4.5/bin'
Build failed:  -> task failed (err #1):
        {task: cc_link async_sock_1.o,async_connect_send_test_2.o -> async_connect_send_test}
  File "buildtools/bin/waf", line 76, in <module>
        Scripting.prepare(t, cwd, VERSION, wafdir)
  File "/usr/ports/net/samba44/work/samba-4.4.5/third_party/waf/wafadmin/Scripting.py", line 147, in prepare
        error(str(e))
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/net/samba44
*** Error code 1

Stop.
make: stopped in /usr/ports/net/samba44

===>>> make build failed for net/samba44
===>>> Aborting update

Currently I have these 2 ports installed:
samba36-libsmbclient-3.6.25_2  Shared lib from the samba package
samba41-4.1.22_2               Free SMB/CIFS and AD/DC server and client for Unix

Many thanks for any advice.

Michael
Comment 8 Igor Pavlov 2016-12-21 14:27:14 UTC
Have you tried to do the full rebuild?
# cd /usr/ports/net/samba44/ && make clean install clean
Comment 9 michael.kristofic 2016-12-24 13:34:59 UTC
I did pkg delete for both samba36-libsmbclient-3.6.25_2 and
samba41-4.1.22_2 , after that I ran make clean install clean from the samba44 port directory and it installed successfully. Thanks and Merry Christmas! ;)
Comment 10 Igor Pavlov 2016-12-28 22:00:16 UTC
Dear Timur,
Is there any reason to ignore this patch?
Comment 11 John Hein 2016-12-29 23:55:44 UTC
Whether this patch is the right one or not, I tracked down why this fails on FreeBSD 11.x and does not fail on 10.x.

samba44/Makefile has USES=readline and on 11.x there is no /usr/lib/libreadline.so.  This triggers a dependency (see Uses/readline.mk) on the readline port on 11.x and, more importantly, adds -I${LOCALBASE}/include to CPPFLAGS.

On 10.x, by default, there is a /usr/lib/libreadline.so, so the -I${LOCALBASE}/include is not added to CPPFLAGS.

FWIW, if security/krb5 is installed, the samba44 (tested after the latest samba-4.4.8 update) port build fails even earlier [1] on 11.x.  This is because /usr/local/include/gssapi.h is included rather than samba's version of gssapi.h (source4/heimdal/lib/gssapi/gssapi/gssapi.h).

Igor's patch addresses this issue by moving CPPFLAGS later in the list of flags passed to the compiler.

Using Igor's patch fixes the above build problem as well (i.e., if krb5 is installed).

I think it's reasonable to inquire upstream if they will accept the patch (perhaps even moving _CCINCFLAGS and _CCDEFFLAGS before CCFLAGS as well).  It could be seen to be more correct to have the internally defined flags come first.

Perhaps we should change the description for this bug to point out that it's not just a problem associated with net/samba-libsmbclient.  The underlying issue is that files from ${LOCALBASE} are getting included before files of the same name in the samba source tree.


[1]
==================
 .
 .
[ 664/3733] Compiling lib/addns/dnsrecord.c
runner cc -pipe -fno-omit-frame-pointer -DLIBICONV_PLUG -fno-color-diagnostics -g -fstack-protector -fno-strict-aliasing -fPIC -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DSTATIC_addns_MODULES=NULL -DSTATIC_addns_MODULES_PROTO=extern void __addns_dummy_module_proto(void) -MD -I/usr/local/include -DLIBICONV_PLUG -DLDAP_DEPRECATED -Idefault/lib/addns -I../lib/addns -Idefault/include/public -I../include/public -Idefault/source4 -I../source4 -Idefault/lib -I../lib -Idefault/source4/lib -I../source4/lib -Idefault/source4/include -I../source4/include -Idefault/include -I../include -Idefault/lib/replace -I../lib/replace -Idefault -I.. -Idefault/source4/heimdal/lib/krb5 -I../source4/heimdal/lib/krb5 -Idefault/source4/heimdal/lib/asn1 -I../source4/heimdal/lib/asn1 -Idefault/source4/heimdal/include -I../source4/heimdal/include -Idefault/source4/heimdal_build -I../source4/heimdal_build -Idefault/source4/heimdal/lib/gssapi -I../source4/heimdal/lib/gssapi -Idefault/lib/util/charset -I../lib/util/charset -Idefault/source4/heimdal/lib/roken -I../source4/heimdal/lib/roken -Idefault/source4/heimdal/lib/wind -I../source4/heimdal/lib/wind -Idefault/source4/heimdal/lib/hcrypto/libtommath -I../source4/heimdal/lib/hcrypto/libtommath -Idefault/source4/heimdal/lib/gssapi/gssapi -I../source4/heimdal/lib/gssapi/gssapi -Idefault/source4/heimdal/lib/gssapi/spnego -I../source4/heimdal/lib/gssapi/spnego -Idefault/source4/heimdal/lib/gssapi/krb5 -I../source4/heimdal/lib/gssapi/krb5 -Idefault/source4/heimdal/lib/gssapi/mech -I../source4/heimdal/lib/gssapi/mech -Idefault/libcli/util -I../libcli/util -Idefault/source4/heimdal/base -I../source4/heimdal/base -Idefault/source4/heimdal/lib/hx509 -I../source4/heimdal/lib/hx509 -Idefault/source3 -I../source3 -Idefault/source3/include -I../source3/include -Idefault/source3/lib -I../source3/lib -Idefault/source4/heimdal/lib/com_err -I../source4/heimdal/lib/com_err -Idefault/bin/default/source4/heimdal/lib/asn1 -Idefault/source4/heimdal/lib/asn1 -Idefault/source4/heimdal/lib/hcrypto -I../source4/heimdal/lib/hcrypto -Idefault/source4/heimdal/lib -I../source4/heimdal/lib -Idefault/librpc -I../librpc -Idefault/lib/crypto -I../lib/crypto -Idefault/dynconfig -I../dynconfig -I/usr/local/include -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H=1 -D_GNU_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 ../lib/addns/dnsrecord.c -c -o default/lib/addns/dnsrecord_1.o
In file included from ../lib/addns/dnsrecord.c:24:
In file included from ../lib/addns/dns.h:31:
In file included from ../lib/replace/system/gssapi.h:47:
../source4/heimdal/lib/gssapi/gssapi/gssapi_spnego.h:41:1: error: unknown type name 'GSSAPI_CPP_START'
GSSAPI_CPP_START
^
../source4/heimdal/lib/gssapi/gssapi/gssapi_spnego.h:49:1: error: expected identifier or '('
extern GSSAPI_LIB_VARIABLE gss_OID_desc __gss_spnego_mechanism_oid_desc;
^
../source4/heimdal/lib/gssapi/gssapi/gssapi_spnego.h:53:1: error: unknown type name 'GSSAPI_CPP_END'
GSSAPI_CPP_END
^
In file included from ../lib/addns/dnsrecord.c:24:
In file included from ../lib/addns/dns.h:41:
/usr/include/fcntl.h:271:1: error: expected identifier or '('
struct flock {
^
4 errors generated.
 .
 .
==================
Comment 12 outbackdingo 2016-12-30 21:47:33 UTC
i can confirm also this patch does fix the kerberus build issue
Comment 13 Timur I. Bakeyev freebsd_committer freebsd_triage 2017-01-03 16:51:52 UTC
(In reply to Igor Pavlov from comment #10)

Hi, Igor!

Sorry, seems I've missed your patch, as you hijacked the old bug-report. I've tried it recently and it seems it does the trick.

I'm thankful to you for spotting the right place where to apply that magical "one beat with a hammer" that fixes that long-standing problem.

Please add your patch to the https://bugzilla.samba.org/show_bug.cgi?id=10515 or open a new bug report there with your patch.

With best regards,
Timur
Comment 14 Igor Pavlov 2017-01-03 17:05:55 UTC
Timur, as I see, you have already added the patch to the https://bugzilla.samba.org/show_bug.cgi?id=10515, thanks.
Comment 15 Timur I. Bakeyev freebsd_committer freebsd_triage 2017-01-03 17:07:39 UTC
(In reply to Igor Pavlov from comment #14)

But you should indicate that you are the author :)
Comment 16 Igor Pavlov 2017-01-03 17:10:33 UTC
I can live without it :)
Comment 17 Timur I. Bakeyev freebsd_committer freebsd_triage 2017-12-18 04:36:43 UTC
Fixed in the ports.