Summary:ASTERISK-15640: Incorrect linker flags used on OpenSolaris
Reporter:Ben Klang (bklang)Labels:
Date Opened:2010-02-16 13:15:22.000-0600Date Closed:2020-09-03 11:32:02
Versions:Frequency of
Description:While Asterisk itself builds cleanly on OpenSolaris, asterisk-addons does not due to invalid linker flags.

gmake[1]: Entering directory `/export/home/admin/asterisk-addons-1.6.2.svn/cdr'
  [CC] cdr_addon_mysql.c -> cdr_addon_mysql.o
  [LD] cdr_addon_mysql.o -> cdr_addon_mysql.so
usage: ld [-6:abc:d:e:f:h:il:mo:p:rstu:z:B:CD:F:GI:L:M:N:P:Q:R:S:VW:Y:?] file(s)
<...ld usage output removed...>

I can still manually link the objects with the following commands:
gcc -pg -shared -o cdr_addon_mysql.so -L/opt/SUNWspro/lib -lCrun -lrt -L/usr/mysql/5.0/lib/mysql -R/usr/mysql/5.0/lib/mysql -lmysqlclient -lz -lgen -lsocket -lnsl -lm cdr_addon_mysql.o
Comments:By: John Todd (jtodd) 2010-03-03 09:00:08.000-0600

Can you perhaps provide a patch for this?  Testing is difficult without OpenSolaris on hand.

By: Ben Klang (bklang) 2010-03-23 13:00:59

@jtodd, unfortunately I have to claim ignorance.  I did try looking in the makefile for asterisk-addons, but could not find a suitable place to define linker flags.  As best I can tell, it's referencing the options created by the asterisk build, but I couldn't find a suitable place there either.

I can offer two options though: 1) if someone can point me in the right direction where to make those changes, I will work on a patch; or 2) I can provide SSH access to an OpenSolaris host on which test builds can be made.

By: Jason Parker (jparker) 2010-03-23 13:10:12

Can you run gmake with NOISY_BUILD=yes?  Would be helpful to see what ld is trying to do.

By: Ben Klang (bklang) 2010-03-23 14:21:08

Here is the output from NOISY_BUILD when linking:

gcc  -o cdr_addon_mysql.so   -shared -Xlinker -x cdr_addon_mysql.o
usage: ld [-6:abc:d:e:f:h:il:mo:p:rstu:z:B:CD:F:GI:L:M:N:P:Q:R:S:VW:Y:?] file(s)
... lots of "ld" output removed ...

I note a couple things here:
1) It's not using the MySQL client library information from makeopts.  My makeopts has
MYSQLCLIENT_LIB=-L/opt/SUNWspro/lib -lCrun -lrt -L/usr/mysql/5.0/lib/mysql -R/usr/mysql/5.0/lib/mysql -lmysqlclient -lz -lgen -lsocket -lnsl -lm

2) As noted originally, these linker flags are not valid for Solaris' ld (specifically -Xlinker and -x)

By: Ben Klang (bklang) 2011-02-06 11:17:13.000-0600

Now that the MySQL modules have been moved back in-tree with Asterisk 1.8, this issue is mostly resolved.

There is still a problem on OpenSolaris because the CFLAGS reported by mysql_config are for Sun Studio's CC and are incompatible with GCC.  However by removing all the "-x" args manually from makeopts after running ./configure I have working mysql modules.

It's not Asterisk's fault that mysql_config reports unusable flags.  If anyone else has a bright idea about working around this I'd love to hear it, but at this point I've got a functional (if manual) build.

By: Sean Bright (seanbright) 2020-01-14 12:07:11.548-0600

Are you still experiencing this problem? It looks like OpenSolaris no longer exists, is this still reproducible on one of the derivatives/forks?

By: Sean Bright (seanbright) 2020-09-03 11:31:44.085-0500

Suspended due to lack of activity. Please request a bug marshal in #asterisk-bugs on the IRC network irc.freenode.net to reopen the issue should you have the additional information requested. Further information on issue tracker usage can be found in the Asterisk Issue Guidlines [1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines