Bug 7385 - can't compile. Undefined symbol 'main'
Summary: can't compile. Undefined symbol 'main'
Status: CLOSED FIXED
Alias: None
Product: Samba 3.5
Classification: Unclassified
Component: Build environment (show other bugs)
Version: 3.5.3
Hardware: Sparc Solaris
: P3 minor
Target Milestone: ---
Assignee: Björn Jacke
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-22 06:11 UTC by Alexandr
Modified: 2013-02-18 13:30 UTC (History)
0 users

See Also:
metze: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandr 2010-04-22 06:11:35 UTC
with 3.4.x versions of samba and same config options and environment - normal compilation.

but in 3.5.x versions:

===> build samba for 64-bit
cd /big1/home/devel/build/net/samba/64/samba-3.5.2/source3;  /bin/env CONFIG_SHELL="/bin/bash"   SHELL="/bin/sh"                 PATH="/bin:/usr/bin:/usr/ccs/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/gcc/bin:/big1/home/devel/ports/Tools:/opt/SUNWspro/bin"                  TMP="/big1/home/devel/tmp"                                      CC="gcc -m64 -mcpu=v9"          CXX="g++ -m64 -mcpu=v9"         LD_RUN_PATH="/usr/local/lib/64"         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/local/include -I/usr/X/include -DLDAP_DEPRECATED"           CFLAGS="-m64 -mcpu=v9 -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/local/include -I/usr/X/include -DLDAP_DEPRECATED -Os -pipe "            CXXFLAGS="-m64 -mcpu=v9 -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/local/include -I/usr/X/include -DLDAP_DEPRECATED -Os -pipe  "                 LDFLAGS="-L/lib/sparcv9 -L/usr/lib/sparcv9 -L/usr/local/lib/sparcv9" LDEMULATION="elf64_sparc" /usr/local/bin/gmake
Using CFLAGS     = -I/usr/local/include -lldap_r -I/usr/local/include -I. -I/big1/home/devel/build/net/samba/64/samba-3.5.2/source3 -Iinclude -I./include  -I. -I. -I./../lib/replace -I./../lib/tevent -I./libaddns -I./librpc -I./.. -I./../lib/talloc -I../lib/tdb/include -DHAVE_CONFIG_H  -I/usr/local/include -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/local/include -I/usr/X/include -DLDAP_DEPRECATED -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DLDAP_DEPRECATED -DSUNOS5  -I/big1/home/devel/build/net/samba/64/samba-3.5.2/source3/lib -I.. -I../source4 -D_SAMBA_BUILD_=3 -D_SAMBA_BUILD_=3
      PICFLAG    = -fPIC
      LIBS       = -lsendfile -lresolv -lrt -lnsl -lsocket -liconv -laio
      LDFLAGS    = -pie  -L/usr/local/lib/sparcv9 -Wl,-z,ignore -L/lib/sparcv9 -L/usr/lib/sparcv9 -L/usr/local/lib/sparcv9 -lthread -R/usr/local/lib/sparcv9 -L/usr/local/lib/sparcv9 -L./bin
      DYNEXP     =
      LDSHFLAGS  = -G  -L/usr/local/lib/sparcv9 -Wl,-z,ignore -L/lib/sparcv9 -L/usr/lib/sparcv9 -L/usr/local/lib/sparcv9 -lthread -R/usr/local/lib/sparcv9 -L/usr/local/lib/sparcv9 -L./bin -lc -Wl,-z,defs
      SHLIBEXT   = so
      SONAMEFLAG = -Wl,-soname=
mkdir bin
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/timegm.c
Compiling ../lib/replace/getifaddrs.c
creating /big1/home/devel/build/net/samba/64/samba-3.5.2/source3/exports/libtalloc.syms
Linking shared library bin/libtalloc.so.2
ld: warning: option -o appears more than once, first setting taken
Undefined                       first referenced
 symbol                             in file
main                                /usr/local/lib/gcc/sparc-sun-solaris2.10/4.4.3/sparcv9/crt1.o
ld: fatal: Symbol referencing errors. No output written to bin/libtalloc.so.2
collect2: ld returned 1 exit status
gmake: *** [bin/libtalloc.so.2] Error 1
*** Error code 2

Stop.
===================

with dirty workaround 

void main(void) {}

in 
../lib/talloc/talloc.c
..lib/tdb/common/tdb.c

compilation continues, but stumble on libnetapi

===============================================

creating /big1/home/devel/build/net/samba/64/samba-3.5.2/source3/exports/libnetapi.syms
Linking shared library bin/libnetapi.so.0
ld: warning: option -o appears more than once, first setting taken
ld: fatal: symbol `main' is multiply-defined:
        (file bin/libtalloc.a(talloc.o) type=FUNC; file bin/libtdb.a(tdb.o) type=FUNC);
ld: fatal: File processing errors. No output written to bin/libnetapi.so.0
collect2: ld returned 1 exit status
gmake: *** [bin/libnetapi.so.0] Error 1
*** Error code 2
Comment 1 Björn Jacke 2010-04-22 06:26:27 UTC
this is a braindead gcc library on Solaris. If you can't get a sane gcc version on Solaris which does not have an unresolved main symbol, you can export LDFLAGS=-Wl,-z,nodefs and then run configure/make again. On Solaris you're better advised to use the Sun Studio compiler anyway.
Comment 2 Björn Jacke 2010-05-05 07:29:10 UTC
actually, while looking into what kind of problem gcc has on Solaris, I notived that on Solaris the compiler flags are screwed up quite a bit. The shared libs are linked like binaries - so finally gcc is not so wrong to expect a main symbol. The composition of C- and LDFLAGS really needs some cleanups.
Comment 3 Björn Jacke 2010-05-05 18:02:23 UTC
fixed in master by 1969b4acc3fd7c124e288d0495b9b4665d4b42db

This needs to get in to 3.5.
Comment 4 Björn Jacke 2010-05-09 14:40:47 UTC
to fix numerous "multiple -o option" warnings on gcc on Solaris also this one should be picked to 3.5:

358a3855c20153d7fe742ca2e6b9bd8a9c92e525
Comment 5 Stefan Metzmacher 2010-05-10 06:20:17 UTC
Björn,

can you add git format-patch output for the backports?
Comment 6 Björn Jacke 2010-05-10 08:12:10 UTC
git cherry-pick the two mentioned commits without further twaeks should work without a problem.
Comment 7 Stefan Metzmacher 2010-05-10 08:23:17 UTC
Ok
Comment 8 Karolin Seeger 2010-05-11 07:47:06 UTC
Pushed to v3-5-test.
Closing out bug report.

Thanks!
Comment 9 Alexandr 2010-05-20 06:16:22 UTC
Compiling libads/ldap_utils.c
Compiling libads/ldap_schema.c
Compiling libads/util.c
Compiling libads/ndr.c
Compiling lib/privileges_basic.c
Compiling auth/token_util.c
creating /big1/home/devel/build/net/samba/64/samba-3.5.3/source3/exports/libnetapi.syms
Linking shared library bin/libnetapi.so.0
Undefined                       first referenced
 symbol                             in file
main                                /usr/local/lib/sparcv9/libwbclient.so
ld: fatal: Symbol referencing errors. No output written to bin/libnetapi.so.0
collect2: ld returned 1 exit status
gmake: *** [bin/libnetapi.so.0] Error 1
*** Error code 2
Comment 10 Björn Jacke 2010-05-20 10:49:37 UTC
is the /usr/local/lib/sparcv9/libwbclient.so from a previously old broken build your problem? Can you please try the build in a "cleaned up" environment?
Comment 11 Björn Jacke 2010-05-20 11:21:21 UTC
http://build.samba.org/?function=View+Build;host=sunX;tree=samba_3_next;compiler=gcc

as the build farm shows that it actually works, I'll close this again.

Thanks for testing!