[ZBX-15915] round() undefined in Solaris 9 8/03 (SPARC), linking fails Created: 2019 Apr 01 Updated: 2019 May 24 Resolved: 2019 May 21 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Agent (G) |
Affects Version/s: | 3.0.26 |
Fix Version/s: | 3.0.28rc1, 4.0.8rc1, 4.2.2rc1, 4.4.0alpha1, 4.4 (plan) |
Type: | Problem report | Priority: | Blocker |
Reporter: | Saulius Krasuckas | Assignee: | Andrejs Kozlovs |
Resolution: | Fixed | Votes: | 0 |
Labels: | agent, libm, round, solaris | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Solaris 9 8/03 s9s_u4wos_08a SPARC |
Attachments: | Sol9_SPARC_zabbix_3.0.26__config.log Sol9_SPARC_zabbix_3.0.26__configure_OK.txt Sol9_SPARC_zabbix_3.0.26__make_fails.txt |
Team: | Team A |
Sprint: | Sprint 51 (Apr 2019), Sprint 52 (May 2019) |
Story Points: | 0.5 |
Description |
Steps to reproduce:
LDFLAGS="-L/opt/csw/lib/sparcv9 -L/.SUNWnative/lib/sparcv9" ./configure --enable-agent
Result: Linking zabbix_agentd fails: gcc -DHAVE_CONFIG_H -I. -I../../include -DZABBIX_DAEMON -DSYSCONFDIR="\"/usr/local/etc\"" -DLIBDIR="\"/usr/local/lib\"" -g -O2 -MT zabbix_agentd-zabbix_agentd.o -MD -MP -MF .deps/zabbix_agentd-zabbix_agentd.Tpo -c -o zabbix_agentd-zabbix_agentd.o `test -f 'zabbix_agentd.c' || echo './'`zabbix_agentd.c I would transform this into a one liner: Undefined symbol round first referenced }}{{in file }}{{zabbix_agentd-procstat.o Expected: |
Comments |
Comment by Saulius Krasuckas [ 2019 Apr 01 ] |
As we've haven't found libm on our Sol9 systems, I've copied some CDDL licensed code from lib/libm/common/m9x/round.c (and related header) of the illlumos project. It compiled then. But I am not sure about the right solution (legally and technically correct). |
Comment by dimir [ 2019 Apr 02 ] |
One of the solutions I see is adding availability of round() check to autotools. |
Comment by Glebs Ivanovskis [ 2019 Apr 02 ] |
It is interesting that it does not fail during compilation, so there is round() somewhere in header files... |
Comment by Saulius Krasuckas [ 2019 Apr 02 ] |
> there is round() somewhere in header files... If I could get list of the headers being included, I would grep through them and see. |
Comment by Glebs Ivanovskis [ 2019 Apr 02 ] |
It should be in math.h |
Comment by Andrejs Sitals [ 2019 Apr 03 ] |
While math.h has to be included for round() to be available during compile time, it doesn't necessarily mean that it is declared in math.h. E.g., I have it in /usr/include/x86_64-linux-gnu/bits/mathcalls.h (which is included in math.h) on my development PC (Ubuntu) and it is declared using __MATHCALLX macro: __MATHCALLX (round,, (_Mdouble_ __x), (__const__)); |
Comment by Glebs Ivanovskis [ 2019 Apr 03 ] |
Argh, I forgot that missing function prototype is just a warning in C. Ignore my words. |
Comment by Saulius Krasuckas [ 2019 Apr 03 ] |
My bad: I recalled the old thing a bit wrongly. Actually, we have the math lib installed, but it's version is low: libm.so.1 And it doesn't seem to contain round() : [root@testlab02 zabbix-3.0.26]# /usr/ccs/bin/nm -D /usr/lib/libm.so.1 | wc -l And libm.so.2 seems to be supported only from Solaris 10 and up: https://stackoverflow.com/questions/33553982/solaris-version-that-uses-libm-so-2/#33584938 Maybe installing "C9X patch cluster" would help on Solaris 9, but "appropriate service contract" for these machines are long gone now: https://mail.haskell.org/pipermail/glasgow-haskell-users/2009-March/016833.html
Has building Zabbix agent v3.x ever worked on Solaris 9 for you? We would go back in time and compile earlier 3.x version.
@Glebs, I renamed function into zround() and well, it didn't even gave me a warning: make[2]: Entering directory `/zabbix-3.0.26/src/zabbix_agent' Which I find to be a bit strange (but OK with me as I haven't investigated into configured warnings threshold for this gcc 3.4.6 installation). |
Comment by Saulius Krasuckas [ 2019 Apr 05 ] |
I would like to repeat the question: Has building Zabbix agent v3.x ever worked on Solaris 9 for you ? : ) |
Comment by Glebs Ivanovskis [ 2019 Apr 08 ] |
Looks like round() was introduced in Index: procstat.c =================================================================== --- procstat.c (revision 65790) +++ procstat.c (revision 65789) @@ -1103,7 +1101,8 @@ /* 1e9 (nanoseconds) * 1e2 (percent) * 1e1 (one digit decimal place) */ ticks_diff *= __UINT64_C(1000000000000); - *value = round((double)ticks_diff / (time_diff * sysconf(_SC_CLK_TCK))) / 10; + ticks_diff /= time_diff * sysconf(_SC_CLK_TCK); + *value = (double)ticks_diff / 10; ret = SUCCEED; out: |
Comment by Saulius Krasuckas [ 2019 Apr 26 ] |
Thanks. Another way would be to import round() on the source code level. Eg. musl contains friendly licensed (MIT) implementation: Although I haven't tested this implementation on Sol9. |
Comment by Andrejs Kozlovs [ 2019 May 03 ] |
As mentioned above, this situation happens on old Solaris OS and old math library. And this problem is actual for agent only. We can got HAVE_ROUND define after minor modification of configure.ac and do the following using it: #ifndef HAVE_ROUND double round( double x) { if (x >= 0) x = x + 0.5; else x = x - 0.5; return (double)((int)x); } #endif or #ifdef HAVE_ROUND *value = round((double)ticks_diff / (time_diff * sysconf(_SC_CLK_TCK))) / 10; #else *value = (int)((double)ticks_diff / (time_diff * sysconf(_SC_CLK_TCK)) + 0.5) / 10.0; #endif |
Comment by Andrejs Kozlovs [ 2019 May 21 ] |
Fixed in:
|